diff options
| author | Anna Zaks <ganna@apple.com> | 2012-05-10 21:49:52 +0000 |
|---|---|---|
| committer | Anna Zaks <ganna@apple.com> | 2012-05-10 21:49:52 +0000 |
| commit | fe1ccee0f5f59dd833fa1a5e826fe3484a991c9e (patch) | |
| tree | a365c6db4ee1801d18872634a6afd15eadae648b /clang | |
| parent | ed51b9ec0bc3c3887f64b74793cd7997039fefe2 (diff) | |
| download | bcm5719-llvm-fe1ccee0f5f59dd833fa1a5e826fe3484a991c9e.tar.gz bcm5719-llvm-fe1ccee0f5f59dd833fa1a5e826fe3484a991c9e.zip | |
[analyzer] Exit early if constraint solver is given a non-integer symbol
to reason about.
As part of taint propagation, we now allow creation of non-integer
symbolic expressions like a cast from int to float.
Addresses PR12511 (radar://11215362).
llvm-svn: 156578
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp | 5 | ||||
| -rw-r--r-- | clang/test/Analysis/casts.c | 8 |
2 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp b/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp index 92a8eb1a7aa..5568f1ca555 100644 --- a/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp +++ b/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp @@ -137,6 +137,11 @@ SimpleConstraintManager::assumeAuxForSymbol(ProgramStateRef State, SymbolRef Sym, bool Assumption) { BasicValueFactory &BVF = getBasicVals(); QualType T = Sym->getType(BVF.getContext()); + + // None of the constraint solvers currently support non-integer types. + if (!T->isIntegerType()) + return State; + const llvm::APSInt &zero = BVF.getValue(0, T); if (Assumption) return assumeSymNE(State, Sym, zero, zero); diff --git a/clang/test/Analysis/casts.c b/clang/test/Analysis/casts.c index 8b88a2db432..f862ddf5731 100644 --- a/clang/test/Analysis/casts.c +++ b/clang/test/Analysis/casts.c @@ -65,3 +65,11 @@ void pr6013_6035_test(void *p) { foo = ((long)(p)); (void) foo; } + +// PR12511 and radar://11215362 - Test that we support SymCastExpr, which represents symbolic int to float cast. +char ttt(int intSeconds) { + double seconds = intSeconds; + if (seconds) + return 0; + return 0; +} |

