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

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

llvm-svn: 173545
This commit is contained in:
Jordan Rose 2013-01-26 01:28:15 +00:00
parent 8de30305f6
commit 329bbe8e11
4 changed files with 34 additions and 1 deletions

View File

@ -297,6 +297,13 @@ public:
/// option, which accepts the values "true" and "false". /// option, which accepts the values "true" and "false".
bool shouldAvoidSuppressingNullArgumentPaths(); 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 // Returns the size of the functions (in basic blocks), which should be
// considered to be small enough to always inline. // considered to be small enough to always inline.
// //

View File

@ -186,3 +186,7 @@ unsigned AnalyzerOptions::getMaxTimesInlineLarge() {
bool AnalyzerOptions::shouldSynthesizeBodies() { bool AnalyzerOptions::shouldSynthesizeBodies() {
return getBooleanOption("faux-bodies", true); return getBooleanOption("faux-bodies", true);
} }
bool AnalyzerOptions::shouldPrunePaths() {
return getBooleanOption("prune-paths", true);
}

View File

@ -2123,7 +2123,8 @@ bool GRBugReporter::generatePathDiagnostic(PathDiagnostic& PD,
// Remove messages that are basically the same. // Remove messages that are basically the same.
removeRedundantMsgs(PD.getMutablePieces()); removeRedundantMsgs(PD.getMutablePieces());
if (R->shouldPrunePath()) { if (R->shouldPrunePath() &&
getEngine().getAnalysisManager().options.shouldPrunePaths()) {
bool hasSomethingInteresting = RemoveUnneededCalls(PD.getMutablePieces(), bool hasSomethingInteresting = RemoveUnneededCalls(PD.getMutablePieces(),
R); R);
assert(hasSomethingInteresting); assert(hasSomethingInteresting);

View File

@ -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}}
}