]> granicus.if.org Git - clang/commitdiff
RegionStoreManager::invalidateRegions: treat classes the same as structs.
authorTed Kremenek <kremenek@apple.com>
Tue, 12 Apr 2011 00:44:31 +0000 (00:44 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 12 Apr 2011 00:44:31 +0000 (00:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129333 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/RegionStore.cpp
test/Analysis/misc-ps-region-store.cpp

index f14b8ad94ff6fabe4579fef4abf5d3b3e0f703ea..4522f976e648f348adcc6c81fb3c69bdb0c49dc7 100644 (file)
@@ -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;
   }
index e01c348e3282053903cb6e46e7678995da158b01..aaf1381099060a2dfa6136135e55fe48496f0ea6 100644 (file)
@@ -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
+}
+