aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-01-26 01:28:15 +0000
committerJordan Rose <jordan_rose@apple.com>2013-01-26 01:28:15 +0000
commitaeca2cc3a6f486abff3fdfb4e82903cd3ca4267e (patch)
tree48e97d13a95f417354c075866e2abaff113ff481
parent7ee8906295d56ceb84b8b3da502cdc8770509868 (diff)
[analyzer] Add 'prune-paths' config option to disable path pruning.
This should be used for testing only. Path pruning is still on by default. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173545 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/StaticAnalyzer/Core/AnalyzerOptions.h7
-rw-r--r--lib/StaticAnalyzer/Core/AnalyzerOptions.cpp4
-rw-r--r--lib/StaticAnalyzer/Core/BugReporter.cpp3
-rw-r--r--test/Analysis/diagnostics/no-prune-paths.c21
4 files changed, 34 insertions, 1 deletions
diff --git a/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h b/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
index 4643c67b70..c84f6c3768 100644
--- a/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ b/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -297,6 +297,13 @@ public:
/// option, which accepts the values "true" and "false".
bool shouldAvoidSuppressingNullArgumentPaths();
+ /// Returns whether irrelevant parts of a bug report path should be pruned
+ /// out of the final output.
+ ///
+ /// This is controlled by the 'prune-paths' config option, which accepts the
+ /// values "true" and "false".
+ bool shouldPrunePaths();
+
// Returns the size of the functions (in basic blocks), which should be
// considered to be small enough to always inline.
//
diff --git a/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp b/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
index 193e3b875d..e2dedb4ac8 100644
--- a/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ b/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -186,3 +186,7 @@ unsigned AnalyzerOptions::getMaxTimesInlineLarge() {
bool AnalyzerOptions::shouldSynthesizeBodies() {
return getBooleanOption("faux-bodies", true);
}
+
+bool AnalyzerOptions::shouldPrunePaths() {
+ return getBooleanOption("prune-paths", true);
+}
diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp
index 38069a56ac..473472872b 100644
--- a/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -2123,7 +2123,8 @@ bool GRBugReporter::generatePathDiagnostic(PathDiagnostic& PD,
// Remove messages that are basically the same.
removeRedundantMsgs(PD.getMutablePieces());
- if (R->shouldPrunePath()) {
+ if (R->shouldPrunePath() &&
+ getEngine().getAnalysisManager().options.shouldPrunePaths()) {
bool hasSomethingInteresting = RemoveUnneededCalls(PD.getMutablePieces(),
R);
assert(hasSomethingInteresting);
diff --git a/test/Analysis/diagnostics/no-prune-paths.c b/test/Analysis/diagnostics/no-prune-paths.c
new file mode 100644
index 0000000000..fab5cf8205
--- /dev/null
+++ b/test/Analysis/diagnostics/no-prune-paths.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=text -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=text -analyzer-config prune-paths=false -DNPRUNE=1 -verify %s
+
+// "prune-paths" is a debug option only; this is just a simple test to see that
+// it's being honored.
+
+void helper() {
+ extern void foo();
+ foo();
+}
+
+void test() {
+ helper();
+#if NPRUNE
+ // expected-note@-2 {{Calling 'helper'}}
+ // expected-note@-3 {{Returning from 'helper'}}
+#endif
+
+ *(volatile int *)0 = 1; // expected-warning {{Dereference of null pointer}}
+ // expected-note@-1 {{Dereference of null pointer}}
+}