diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-04-12 00:44:31 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-04-12 00:44:31 +0000 |
commit | 4f939da02d068aa7448d85922b997edc598cd36c (patch) | |
tree | 8a5195b4d6d4d94832a9c8c45c8b021db851ef2a | |
parent | 471257c132b3b149419125b9a3a4319d672fd7cc (diff) | |
download | bcm5719-llvm-4f939da02d068aa7448d85922b997edc598cd36c.tar.gz bcm5719-llvm-4f939da02d068aa7448d85922b997edc598cd36c.zip |
RegionStoreManager::invalidateRegions: treat classes the same as structs.
llvm-svn: 129333
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/RegionStore.cpp | 6 | ||||
-rw-r--r-- | clang/test/Analysis/misc-ps-region-store.cpp | 14 |
2 files changed, 17 insertions, 3 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp index f14b8ad94ff..4522f976e64 100644 --- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp +++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -688,11 +688,11 @@ void invalidateRegionsWorker::VisitBaseRegion(const MemRegion *baseR) { QualType T = TR->getValueType(); // Invalidate the binding. - if (T->isStructureType()) { + if (T->isStructureOrClassType()) { // Invalidate the region by setting its default value to // conjured symbol. The type of the symbol is irrelavant. - DefinedOrUnknownSVal V = svalBuilder.getConjuredSymbolVal(baseR, Ex, Ctx.IntTy, - Count); + DefinedOrUnknownSVal V = + svalBuilder.getConjuredSymbolVal(baseR, Ex, Ctx.IntTy, Count); B = RM.addBinding(B, baseR, BindingKey::Default, V); return; } diff --git a/clang/test/Analysis/misc-ps-region-store.cpp b/clang/test/Analysis/misc-ps-region-store.cpp index e01c348e328..aaf13810990 100644 --- a/clang/test/Analysis/misc-ps-region-store.cpp +++ b/clang/test/Analysis/misc-ps-region-store.cpp @@ -346,3 +346,17 @@ float test_ref_double() { return Val; } +// Test invalidation of class fields. +class TestInvalidateClass { +public: + int x; +}; + +void test_invalidate_class_aux(TestInvalidateClass &x); + +int test_invalidate_class() { + TestInvalidateClass y; + test_invalidate_class_aux(y); + return y.x; // no-warning +} + |