diff options
author | Anna Zaks <ganna@apple.com> | 2013-04-20 01:15:42 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2013-04-20 01:15:42 +0000 |
commit | 6c0c47ede56e38568f69261b28858b3d1faa9c92 (patch) | |
tree | 0c3f5b39a1a7856bf1398c8429698c00f6ead022 /clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp | |
parent | 390fb10a9ba759022c5cc57393f83124945a937f (diff) | |
download | bcm5719-llvm-6c0c47ede56e38568f69261b28858b3d1faa9c92.tar.gz bcm5719-llvm-6c0c47ede56e38568f69261b28858b3d1faa9c92.zip |
[analyzer] Ensure BugReporterTracking works on regions with pointer arithmetic
Introduce a new helper function, which computes the first symbolic region in
the base region chain. The corresponding symbol has been used for assuming that
a pointer is null. Now, it will also be used for checking if it is null.
This ensures that we are tracking a null pointer correctly in the BugReporter.
llvm-svn: 179916
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp b/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp index 34de3453ca3..a06268dd331 100644 --- a/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp +++ b/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp @@ -90,20 +90,15 @@ ProgramStateRef SimpleConstraintManager::assumeAux(ProgramStateRef state, case loc::MemRegionKind: { // FIXME: Should this go into the storemanager? - const MemRegion *R = Cond.castAs<loc::MemRegionVal>().getRegion(); - const SubRegion *SubR = dyn_cast<SubRegion>(R); - - while (SubR) { - // FIXME: now we only find the first symbolic region. - if (const SymbolicRegion *SymR = dyn_cast<SymbolicRegion>(SubR)) { - const llvm::APSInt &zero = getBasicVals().getZeroWithPtrWidth(); - if (Assumption) - return assumeSymNE(state, SymR->getSymbol(), zero, zero); - else - return assumeSymEQ(state, SymR->getSymbol(), zero, zero); - } - SubR = dyn_cast<SubRegion>(SubR->getSuperRegion()); + + // FIXME: now we only find the first symbolic region. + if (const SymbolicRegion *SymR = R->getSymbolicBase()) { + const llvm::APSInt &zero = getBasicVals().getZeroWithPtrWidth(); + if (Assumption) + return assumeSymNE(state, SymR->getSymbol(), zero, zero); + else + return assumeSymEQ(state, SymR->getSymbol(), zero, zero); } // FALL-THROUGH. |