diff options
author | Anna Zaks <ganna@apple.com> | 2011-12-06 23:12:27 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2011-12-06 23:12:27 +0000 |
commit | c25efccc8b448341f1aa124bb6fcc37a72dc0a46 (patch) | |
tree | 6970913705d29c650913f8730007d96f4f5105b2 /clang/lib/StaticAnalyzer/Core/Store.cpp | |
parent | 8629c0a4d07f2247ca151174bbdb8f0efc778fab (diff) | |
download | bcm5719-llvm-c25efccc8b448341f1aa124bb6fcc37a72dc0a46.tar.gz bcm5719-llvm-c25efccc8b448341f1aa124bb6fcc37a72dc0a46.zip |
[analyzer] Propagate taint through NonLoc to NonLoc casts.
- Created a new SymExpr type - SymbolCast.
- SymbolCast is created when we don't know how to simplify a NonLoc to
NonLoc casts.
- A bit of code refactoring: introduced dispatchCast to have better
code reuse, remove a goto.
- Updated the test case to showcase the new taint flow.
llvm-svn: 145985
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/Store.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/Store.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/Store.cpp b/clang/lib/StaticAnalyzer/Core/Store.cpp index 48a6f4f60f8..5d152d4d533 100644 --- a/clang/lib/StaticAnalyzer/Core/Store.cpp +++ b/clang/lib/StaticAnalyzer/Core/Store.cpp @@ -212,7 +212,7 @@ const MemRegion *StoreManager::castRegion(const MemRegion *R, QualType CastToTy) SVal StoreManager::CastRetrievedVal(SVal V, const TypedValueRegion *R, QualType castTy, bool performTestOnly) { - if (castTy.isNull()) + if (castTy.isNull() || V.isUnknownOrUndef()) return V; ASTContext &Ctx = svalBuilder.getContext(); @@ -227,12 +227,8 @@ SVal StoreManager::CastRetrievedVal(SVal V, const TypedValueRegion *R, return V; } - if (const Loc *L = dyn_cast<Loc>(&V)) - return svalBuilder.evalCastFromLoc(*L, castTy); - else if (const NonLoc *NL = dyn_cast<NonLoc>(&V)) - return svalBuilder.evalCastFromNonLoc(*NL, castTy); - - return V; + assert(isa<Loc>(&V) || isa<NonLoc>(&V)); + return svalBuilder.dispatchCast(V, castTy); } SVal StoreManager::getLValueFieldOrIvar(const Decl *D, SVal Base) { |