summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2016-10-07 10:56:44 +0000
committerArtem Dergachev <artem.dergachev@gmail.com>2016-10-07 10:56:44 +0000
commit5d9278ef00057d49349a42d28e3ea91f19bd22bf (patch)
treef221b69eb4e0f10beff6d54a97215e48d892ebf0 /clang/lib/StaticAnalyzer/Core/BugReporter.cpp
parentfc36b586fb07904dc9f0e311c9630a0d1c768e45 (diff)
downloadbcm5719-llvm-5d9278ef00057d49349a42d28e3ea91f19bd22bf.tar.gz
bcm5719-llvm-5d9278ef00057d49349a42d28e3ea91f19bd22bf.zip
Revert "[analyzer] Try to re-apply r283092 "Extend bug reports with extra notes"
Vector of smart pointers wasn't the thing that caused msvc crash. llvm-svn: 283537
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/BugReporter.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/BugReporter.cpp79
1 files changed, 18 insertions, 61 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index 9bc7470c61d..1800eff76bd 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -114,15 +114,15 @@ static void removeRedundantMsgs(PathPieces &path) {
path.pop_front();
switch (piece->getKind()) {
- case PathDiagnosticPiece::Call:
+ case clang::ento::PathDiagnosticPiece::Call:
removeRedundantMsgs(cast<PathDiagnosticCallPiece>(piece)->path);
break;
- case PathDiagnosticPiece::Macro:
+ case clang::ento::PathDiagnosticPiece::Macro:
removeRedundantMsgs(cast<PathDiagnosticMacroPiece>(piece)->subPieces);
break;
- case PathDiagnosticPiece::ControlFlow:
+ case clang::ento::PathDiagnosticPiece::ControlFlow:
break;
- case PathDiagnosticPiece::Event: {
+ case clang::ento::PathDiagnosticPiece::Event: {
if (i == N-1)
break;
@@ -142,8 +142,6 @@ static void removeRedundantMsgs(PathPieces &path) {
}
break;
}
- case PathDiagnosticPiece::Note:
- break;
}
path.push_back(piece);
}
@@ -201,9 +199,6 @@ static bool removeUnneededCalls(PathPieces &pieces, BugReport *R,
}
case PathDiagnosticPiece::ControlFlow:
break;
-
- case PathDiagnosticPiece::Note:
- break;
}
pieces.push_back(piece);
@@ -2559,12 +2554,6 @@ BugReport::~BugReport() {
while (!interestingSymbols.empty()) {
popInterestingSymbolsAndRegions();
}
-
- // FIXME: Replace Notes with a list of shared pointers.
- for (const auto *P: Notes) {
- delete P;
- }
- Notes.clear();
}
const Decl *BugReport::getDeclWithIssue() const {
@@ -3416,28 +3405,25 @@ void BugReporter::FlushReport(BugReport *exampleReport,
exampleReport->getUniqueingLocation(),
exampleReport->getUniqueingDecl()));
- if (exampleReport->isPathSensitive()) {
- // Generate the full path diagnostic, using the generation scheme
- // specified by the PathDiagnosticConsumer. Note that we have to generate
- // path diagnostics even for consumers which do not support paths, because
- // the BugReporterVisitors may mark this bug as a false positive.
- assert(!bugReports.empty());
-
- MaxBugClassSize =
- std::max(bugReports.size(), static_cast<size_t>(MaxBugClassSize));
+ MaxBugClassSize = std::max(bugReports.size(),
+ static_cast<size_t>(MaxBugClassSize));
+ // Generate the full path diagnostic, using the generation scheme
+ // specified by the PathDiagnosticConsumer. Note that we have to generate
+ // path diagnostics even for consumers which do not support paths, because
+ // the BugReporterVisitors may mark this bug as a false positive.
+ if (!bugReports.empty())
if (!generatePathDiagnostic(*D.get(), PD, bugReports))
return;
- MaxValidBugClassSize =
- std::max(bugReports.size(), static_cast<size_t>(MaxValidBugClassSize));
+ MaxValidBugClassSize = std::max(bugReports.size(),
+ static_cast<size_t>(MaxValidBugClassSize));
- // Examine the report and see if the last piece is in a header. Reset the
- // report location to the last piece in the main source file.
- AnalyzerOptions &Opts = getAnalyzerOptions();
- if (Opts.shouldReportIssuesInMainSourceFile() && !Opts.AnalyzeAll)
- D->resetDiagnosticLocationToMainFile();
- }
+ // Examine the report and see if the last piece is in a header. Reset the
+ // report location to the last piece in the main source file.
+ AnalyzerOptions& Opts = getAnalyzerOptions();
+ if (Opts.shouldReportIssuesInMainSourceFile() && !Opts.AnalyzeAll)
+ D->resetDiagnosticLocationToMainFile();
// If the path is empty, generate a single step path with the location
// of the issue.
@@ -3450,28 +3436,6 @@ void BugReporter::FlushReport(BugReport *exampleReport,
D->setEndOfPath(std::move(piece));
}
- PathPieces &Pieces = D->getMutablePieces();
- bool ShouldConvert = getAnalyzerOptions().shouldDisplayNotesAsEvents();
- // For path diagnostic consumers that don't support extra notes,
- // we may optionally convert those to path notes.
- for (auto I = exampleReport->getNotes().rbegin(),
- E = exampleReport->getNotes().rend(); I != E; ++I) {
- const PathDiagnosticNotePiece *Piece = *I;
- // FIXME: getNotes() was supposed to return a list of shared pointers,
- // and then we wouldn't normally create a new piece here,
- // unless ShouldConvert is set.
- PathDiagnosticPiece *ConvertedPiece =
- ShouldConvert
- ? static_cast<PathDiagnosticPiece *>(new PathDiagnosticEventPiece(
- Piece->getLocation(), Piece->getString()))
- : static_cast<PathDiagnosticPiece *>(new PathDiagnosticNotePiece(
- Piece->getLocation(), Piece->getString()));
- for (const auto &R : Piece->getRanges())
- ConvertedPiece->addRange(R);
-
- Pieces.push_front(ConvertedPiece);
- }
-
// Get the meta data.
const BugReport::ExtraTextList &Meta = exampleReport->getExtraText();
for (BugReport::ExtraTextList::const_iterator i = Meta.begin(),
@@ -3556,13 +3520,6 @@ LLVM_DUMP_METHOD void PathDiagnosticMacroPiece::dump() const {
// FIXME: Print which macro is being invoked.
}
-LLVM_DUMP_METHOD void PathDiagnosticNotePiece::dump() const {
- llvm::errs() << "NOTE\n--------------\n";
- llvm::errs() << getString() << "\n";
- llvm::errs() << " ---- at ----\n";
- getLocation().dump();
-}
-
LLVM_DUMP_METHOD void PathDiagnosticLocation::dump() const {
if (!isValid()) {
llvm::errs() << "<INVALID>\n";
OpenPOWER on IntegriCloud