[cfe-commits] r128340 - in /cfe/trunk: lib/StaticAnalyzer/Core/BasicStore.cpp test/Analysis/cxx-crashes.cpp

Anders Carlsson andersca at mac.com
Sat Mar 26 07:30:44 PDT 2011


Author: andersca
Date: Sat Mar 26 09:30:44 2011
New Revision: 128340

URL: http://llvm.org/viewvc/llvm-project?rev=128340&view=rev
Log:
Don't add a symbolic region for 'this' if the member function is static.

Modified:
    cfe/trunk/lib/StaticAnalyzer/Core/BasicStore.cpp
    cfe/trunk/test/Analysis/cxx-crashes.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BasicStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BasicStore.cpp?rev=128340&r1=128339&r2=128340&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/BasicStore.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BasicStore.cpp Sat Mar 26 09:30:44 2011
@@ -429,12 +429,15 @@
   }
 
   if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(InitLoc->getDecl())) {
-    // For C++ methods add symbolic region for 'this' in initial stack frame.
-    QualType ThisT = MD->getThisType(StateMgr.getContext());
-    MemRegionManager &RegMgr = svalBuilder.getRegionManager();
-    const CXXThisRegion *ThisR = RegMgr.getCXXThisRegion(ThisT, InitLoc);
-    SVal ThisV = svalBuilder.getRegionValueSymbolVal(ThisR);
-    St = Bind(St.getStore(), svalBuilder.makeLoc(ThisR), ThisV);
+    // For C++ non-static member variables, add a symbolic region for 'this' in
+    // the initial stack frame.
+    if (MD->isInstance()) {
+      QualType ThisT = MD->getThisType(StateMgr.getContext());
+      MemRegionManager &RegMgr = svalBuilder.getRegionManager();
+      const CXXThisRegion *ThisR = RegMgr.getCXXThisRegion(ThisT, InitLoc);
+      SVal ThisV = svalBuilder.getRegionValueSymbolVal(ThisR);
+      St = Bind(St.getStore(), svalBuilder.makeLoc(ThisR), ThisV);
+    }
   }
 
   return St;

Modified: cfe/trunk/test/Analysis/cxx-crashes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cxx-crashes.cpp?rev=128340&r1=128339&r2=128340&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/cxx-crashes.cpp (original)
+++ cfe/trunk/test/Analysis/cxx-crashes.cpp Sat Mar 26 09:30:44 2011
@@ -43,3 +43,14 @@
 }
 
 }
+
+namespace {
+
+struct C { 
+  void *p;
+  static void f();
+};
+
+void C::f() { }
+
+}





More information about the cfe-commits mailing list