diff options
| author | Jordan Rose <jordan_rose@apple.com> | 2012-08-13 23:59:07 +0000 |
|---|---|---|
| committer | Jordan Rose <jordan_rose@apple.com> | 2012-08-13 23:59:07 +0000 |
| commit | e521f932250d5a72096eb0a43a6fbf0a80c0d59c (patch) | |
| tree | f0b2bf1c8629189f3d3d70d4f0d7f45dbc3aa633 /clang/lib | |
| parent | ce6c99a559821f6073b1a990f91510cf57ebdaad (diff) | |
| download | bcm5719-llvm-e521f932250d5a72096eb0a43a6fbf0a80c0d59c.tar.gz bcm5719-llvm-e521f932250d5a72096eb0a43a6fbf0a80c0d59c.zip | |
[analyzer] Look up DynamicTypeInfo by region instead of symbol.
This allows us to store type info for non-symbolic regions.
No functionality change.
llvm-svn: 161811
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/StaticAnalyzer/Core/ProgramState.cpp | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ProgramState.cpp b/clang/lib/StaticAnalyzer/Core/ProgramState.cpp index 0e5ff785bff..dc988cc5f1f 100644 --- a/clang/lib/StaticAnalyzer/Core/ProgramState.cpp +++ b/clang/lib/StaticAnalyzer/Core/ProgramState.cpp @@ -737,38 +737,34 @@ bool ProgramState::isTainted(SymbolRef Sym, TaintTagType Kind) const { /// symbol to it's most likely type. namespace clang { namespace ento { -struct DynamicTypeMap {}; -typedef llvm::ImmutableMap<SymbolRef, DynamicTypeInfo> DynamicTypeMapImpl; +typedef llvm::ImmutableMap<const MemRegion *, DynamicTypeInfo> DynamicTypeMap; template<> struct ProgramStateTrait<DynamicTypeMap> - : public ProgramStatePartialTrait<DynamicTypeMapImpl> { + : public ProgramStatePartialTrait<DynamicTypeMap> { static void *GDMIndex() { static int index; return &index; } }; }} DynamicTypeInfo ProgramState::getDynamicTypeInfo(const MemRegion *Reg) const { - if (const TypedRegion *TR = dyn_cast<TypedRegion>(Reg)) - return DynamicTypeInfo(TR->getLocationType()); + // Look up the dynamic type in the GDM. + const DynamicTypeInfo *GDMType = get<DynamicTypeMap>(Reg); + if (GDMType) + return *GDMType; + + // Otherwise, fall back to what we know about the region. + if (const TypedValueRegion *TR = dyn_cast<TypedValueRegion>(Reg)) + return DynamicTypeInfo(TR->getValueType()); if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(Reg)) { SymbolRef Sym = SR->getSymbol(); - // Lookup the dynamic type in the GDM. - const DynamicTypeInfo *GDMType = get<DynamicTypeMap>(Sym); - if (GDMType) - return *GDMType; - - // Else, lookup the type at point of symbol creation. return DynamicTypeInfo(Sym->getType(getStateManager().getContext())); } + return DynamicTypeInfo(); } ProgramStateRef ProgramState::setDynamicTypeInfo(const MemRegion *Reg, DynamicTypeInfo NewTy) const { - if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(Reg)) { - SymbolRef Sym = SR->getSymbol(); - ProgramStateRef NewState = set<DynamicTypeMap>(Sym, NewTy); - assert(NewState); - return NewState; - } - return this; + ProgramStateRef NewState = set<DynamicTypeMap>(Reg, NewTy); + assert(NewState); + return NewState; } |

