[cfe-commits] r173545 - [analyzer] Add 'prune-paths' config option to disable path pruning.

Jordan Rose jordan_rose at apple.com
Fri Jan 25 17:28:15 PST 2013


Author: jrose
Date: Fri Jan 25 19:28:15 2013
New Revision: 173545

URL: http://llvm.org/viewvc/llvm-project?rev=173545&view=rev
Log:
[analyzer] Add 'prune-paths' config option to disable path pruning.

This should be used for testing only. Path pruning is still on by default.

Added:
    cfe/trunk/test/Analysis/diagnostics/no-prune-paths.c
Modified:
    cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
    cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
    cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=173545&r1=173544&r2=173545&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Fri Jan 25 19:28:15 2013
@@ -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.
   //

Modified: cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp?rev=173545&r1=173544&r2=173545&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp Fri Jan 25 19:28:15 2013
@@ -186,3 +186,7 @@ unsigned AnalyzerOptions::getMaxTimesInl
 bool AnalyzerOptions::shouldSynthesizeBodies() {
   return getBooleanOption("faux-bodies", true);
 }
+
+bool AnalyzerOptions::shouldPrunePaths() {
+  return getBooleanOption("prune-paths", true);
+}

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=173545&r1=173544&r2=173545&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Fri Jan 25 19:28:15 2013
@@ -2123,7 +2123,8 @@ bool GRBugReporter::generatePathDiagnost
     // 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);

Added: cfe/trunk/test/Analysis/diagnostics/no-prune-paths.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/diagnostics/no-prune-paths.c?rev=173545&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/diagnostics/no-prune-paths.c (added)
+++ cfe/trunk/test/Analysis/diagnostics/no-prune-paths.c Fri Jan 25 19:28:15 2013
@@ -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 at -2 {{Calling 'helper'}}
+  // expected-note at -3 {{Returning from 'helper'}}
+#endif
+
+  *(volatile int *)0 = 1; // expected-warning {{Dereference of null pointer}}
+  // expected-note at -1 {{Dereference of null pointer}}
+}





More information about the cfe-commits mailing list