summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2013-05-16 22:30:45 +0000
committerAnna Zaks <ganna@apple.com>2013-05-16 22:30:45 +0000
commitc5e2eca042b48498ade564e02549360a12a98036 (patch)
treeb19e27c96b93f29bcfbf7e4110e79414e2bd1a9d /clang/lib/StaticAnalyzer/Core/BugReporter.cpp
parenta3ee78df282b7ce39e23ee40176e0b6ecc8eeda1 (diff)
downloadbcm5719-llvm-c5e2eca042b48498ade564e02549360a12a98036.tar.gz
bcm5719-llvm-c5e2eca042b48498ade564e02549360a12a98036.zip
[analyzer] Add an option to use the last location in the main source file as the report location.
Previously, we’ve used the last location of the analyzer issue path as the location of the report. This might not provide the best user experience, when one analyzer a source file and the issue appears in the header. Introduce an option to use the last location of the path that is in the main source file as the report location. New option can be enabled with -analyzer-config report-in-main-source-file=true. llvm-svn: 182058
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/BugReporter.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/BugReporter.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index b43625f8069..8388e76f511 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -2661,7 +2661,7 @@ bool GRBugReporter::generatePathDiagnostic(PathDiagnostic& PD,
PathGenerationScheme ActiveScheme = PC.getGenerationScheme();
if (ActiveScheme == PathDiagnosticConsumer::Extensive) {
- AnalyzerOptions &options = getEngine().getAnalysisManager().options;
+ AnalyzerOptions &options = getAnalyzerOptions();
if (options.getBooleanOption("path-diagnostics-alternate", false)) {
ActiveScheme = PathDiagnosticConsumer::AlternateExtensive;
}
@@ -2757,8 +2757,7 @@ bool GRBugReporter::generatePathDiagnostic(PathDiagnostic& PD,
// Remove messages that are basically the same.
removeRedundantMsgs(PD.getMutablePieces());
- if (R->shouldPrunePath() &&
- getEngine().getAnalysisManager().options.shouldPrunePaths()) {
+ if (R->shouldPrunePath() && getAnalyzerOptions().shouldPrunePaths()) {
bool stillHasNotes = removeUnneededCalls(PD.getMutablePieces(), R, LCM);
assert(stillHasNotes);
(void)stillHasNotes;
@@ -2972,6 +2971,12 @@ void BugReporter::FlushReport(BugReport *exampleReport,
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();
+
// If the path is empty, generate a single step path with the location
// of the issue.
if (D->path.empty()) {
OpenPOWER on IntegriCloud