summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorCsaba Dabis <dabis.csaba98@gmail.com>2019-03-16 10:06:06 +0000
committerCsaba Dabis <dabis.csaba98@gmail.com>2019-03-16 10:06:06 +0000
commite282b30c58e5d3387f86d7a78d5c5904950cc549 (patch)
treee17f142c087460e4e6dc11258f051af0313692cd /clang
parent0fe67a61cd4aec13c7969a179517f1cc06ab05cd (diff)
downloadbcm5719-llvm-e282b30c58e5d3387f86d7a78d5c5904950cc549.tar.gz
bcm5719-llvm-e282b30c58e5d3387f86d7a78d5c5904950cc549.zip
Revert "[analyzer] ConditionBRVisitor: Unknown condition evaluation support"
This reverts commit 0fe67a61cd4aec13c7969a179517f1cc06ab05cd. llvm-svn: 356320
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp21
-rw-r--r--clang/test/Analysis/diagnostics/macros.cpp3
-rw-r--r--clang/test/Analysis/uninit-vals.m11
3 files changed, 11 insertions, 24 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index 2c4277c8b70..bf7d330e4d5 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1815,6 +1815,12 @@ std::shared_ptr<PathDiagnosticPiece>
ConditionBRVisitor::VisitNodeImpl(const ExplodedNode *N,
BugReporterContext &BRC, BugReport &BR) {
ProgramPoint progPoint = N->getLocation();
+ ProgramStateRef CurrentState = N->getState();
+ ProgramStateRef PreviousState = N->getFirstPred()->getState();
+
+ // If the constraint information does not changed there is no assumption.
+ if (BRC.getStateManager().haveEqualConstraints(CurrentState, PreviousState))
+ return nullptr;
// If an assumption was made on a branch, it should be caught
// here by looking at the state transition.
@@ -1883,8 +1889,6 @@ std::shared_ptr<PathDiagnosticPiece> ConditionBRVisitor::VisitTerminator(
break;
}
- Cond = Cond->IgnoreParens();
-
// However, when we encounter a logical operator as a branch condition,
// then the condition is actually its RHS, because LHS would be
// the condition for the logical operator terminator.
@@ -1904,18 +1908,6 @@ std::shared_ptr<PathDiagnosticPiece>
ConditionBRVisitor::VisitTrueTest(const Expr *Cond, bool tookTrue,
BugReporterContext &BRC, BugReport &R,
const ExplodedNode *N) {
- ProgramStateRef CurrentState = N->getState();
- ProgramStateRef PreviousState = N->getFirstPred()->getState();
- const LocationContext *LCtx = N->getLocationContext();
-
- // If the constraint information is changed between the current and the
- // previous program state we assuming the newly seen constraint information.
- // If we cannot evaluate the condition (and the constraints are the same)
- // the analyzer has no information about the value and just assuming it.
- if (BRC.getStateManager().haveEqualConstraints(CurrentState, PreviousState) &&
- CurrentState->getSVal(Cond, LCtx).isValid())
- return nullptr;
-
// These will be modified in code below, but we need to preserve the original
// values in case we want to throw the generic message.
const Expr *CondTmp = Cond;
@@ -1951,6 +1943,7 @@ ConditionBRVisitor::VisitTrueTest(const Expr *Cond, bool tookTrue,
// Condition too complex to explain? Just say something so that the user
// knew we've made some path decision at this point.
+ const LocationContext *LCtx = N->getLocationContext();
PathDiagnosticLocation Loc(Cond, BRC.getSourceManager(), LCtx);
if (!Loc.isValid() || !Loc.asLocation().isValid())
return nullptr;
diff --git a/clang/test/Analysis/diagnostics/macros.cpp b/clang/test/Analysis/diagnostics/macros.cpp
index 67cdef7f389..5aa2c03ab0e 100644
--- a/clang/test/Analysis/diagnostics/macros.cpp
+++ b/clang/test/Analysis/diagnostics/macros.cpp
@@ -30,8 +30,7 @@ void testnullptrMacro(int *p) {
// There are no path notes on the comparison to float types.
void testDoubleMacro(double d) {
- if (d == DBL_MAX) { // expected-note {{Assuming 'd' is equal to DBL_MAX}}
- // expected-note@-1 {{Taking true branch}}
+ if (d == DBL_MAX) { // expected-note {{Taking true branch}}
char *p = NULL; // expected-note {{'p' initialized to a null pointer value}}
*p = 7; // expected-warning {{Dereference of null pointer (loaded from variable 'p')}}
diff --git a/clang/test/Analysis/uninit-vals.m b/clang/test/Analysis/uninit-vals.m
index 5b959c7bfe1..33352122ca5 100644
--- a/clang/test/Analysis/uninit-vals.m
+++ b/clang/test/Analysis/uninit-vals.m
@@ -164,8 +164,7 @@ void PR14765_test() {
// expected-note@-1{{TRUE}}
testObj->origin = makePoint(0.0, 0.0);
- if (testObj->size > 0) { ; } // expected-note{{Assuming the condition is false}}
- // expected-note@-1{{Taking false branch}}
+ if (testObj->size > 0) { ; } // expected-note{{Taking false branch}}
// FIXME: Assigning to 'testObj->origin' kills the default binding for the
// whole region, meaning that we've forgotten that testObj->size should also
@@ -219,14 +218,10 @@ void PR14765_test_int() {
// expected-note@-1{{TRUE}}
testObj->origin = makeIntPoint(1, 2);
- if (testObj->size > 0) { ; } // expected-note{{Assuming the condition is false}}
+ if (testObj->size > 0) { ; } // expected-note{{Taking false branch}}
// expected-note@-1{{Taking false branch}}
- // expected-note@-2{{Assuming the condition is false}}
+ // expected-note@-2{{Taking false branch}}
// expected-note@-3{{Taking false branch}}
- // expected-note@-4{{Assuming the condition is false}}
- // expected-note@-5{{Taking false branch}}
- // expected-note@-6{{Assuming the condition is false}}
- // expected-note@-7{{Taking false branch}}
// FIXME: Assigning to 'testObj->origin' kills the default binding for the
// whole region, meaning that we've forgotten that testObj->size should also
OpenPOWER on IntegriCloud