Index: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -2605,8 +2605,6 @@ // Register refutation visitors first, if they mark the bug invalid no // further analysis is required R->addVisitor(llvm::make_unique()); - if (Opts.shouldCrosscheckWithZ3()) - R->addVisitor(llvm::make_unique()); // Register additional node visitors. R->addVisitor(llvm::make_unique()); @@ -2619,9 +2617,24 @@ std::unique_ptr visitorNotes = generateVisitorsDiagnostics(R, ErrorNode, BRC); - if (R->isValid()) - return std::make_pair(R, std::move(visitorNotes)); + if (R->isValid()) { + if (Opts.shouldCrosscheckWithZ3()) { + // If crosscheck is enabled, remove all visitors, add the refutation + // visitor and check again + R->clearVisitors(); + R->addVisitor(llvm::make_unique()); + + // We don't overrite the notes inserted by other visitors because the + // refutation manager does not add any new note to the path + generateVisitorsDiagnostics(R, ErrorGraph.ErrorNode, BRC); + } + + // Check if the bug is still valid + if (R->isValid()) + return std::make_pair(R, std::move(visitorNotes)); + } } + return std::make_pair(nullptr, llvm::make_unique()); }