From bf1a66764a12f6cceb6ba8b349d4b74996e3786b Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Tue, 12 Apr 2011 00:44:31 +0000 Subject: [PATCH] RegionStoreManager::invalidateRegions: treat classes the same as structs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129333 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/StaticAnalyzer/Core/RegionStore.cpp | 6 +++--- test/Analysis/misc-ps-region-store.cpp | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/StaticAnalyzer/Core/RegionStore.cpp b/lib/StaticAnalyzer/Core/RegionStore.cpp index f14b8ad94f..4522f976e6 100644 --- a/lib/StaticAnalyzer/Core/RegionStore.cpp +++ b/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/test/Analysis/misc-ps-region-store.cpp b/test/Analysis/misc-ps-region-store.cpp index e01c348e32..aaf1381099 100644 --- a/test/Analysis/misc-ps-region-store.cpp +++ b/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 +} + -- 2.40.0