]> granicus.if.org Git - clang/commitdiff
Add TypedViewRegion::isBoundable() to indicate whether or not the
authorTed Kremenek <kremenek@apple.com>
Wed, 11 Mar 2009 21:57:34 +0000 (21:57 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 11 Mar 2009 21:57:34 +0000 (21:57 +0000)
TypedViewRegion has a valid rvalue type. Also renamed instance variable 'T' to
'LvalueType' to make it unambiguous of its purpose.

This fixes some crashes I was seeing after:

http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20090309/013771.html

This is because 'isBoundable()' is defined in TypedRegion (the parent class) in
terms of the rvalue type (which could be null), while for TypedViewRegion it
should be defined in terms of the lvalue type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66712 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathSensitive/MemRegion.h
lib/Analysis/MemRegion.cpp

index 10bef309ac39cc7210d7842ee280b49bd6983157..b6e4ccb2745dc3504b9c52bc35a5fad9b5ff8eaf 100644 (file)
@@ -239,10 +239,10 @@ public:
 class TypedViewRegion : public TypedRegion {
   friend class MemRegionManager;
 
-  QualType T;
+  QualType LValueType;
 
-  TypedViewRegion(QualType t, const MemRegion* sreg)
-    : TypedRegion(sreg, TypedViewRegionKind), T(t) {}
+  TypedViewRegion(QualType lvalueType, const MemRegion* sreg)
+    : TypedRegion(sreg, TypedViewRegionKind), LValueType(lvalueType) {}
 
   static void ProfileRegion(llvm::FoldingSetNodeID& ID, QualType T, 
                             const MemRegion* superRegion);
@@ -252,13 +252,17 @@ public:
   void print(llvm::raw_ostream& os) const;
   
   QualType getRValueType(ASTContext&) const {
-    const PointerType* PTy = T->getAsPointerType();
+    const PointerType* PTy = LValueType->getAsPointerType();
     assert(PTy);
     return PTy->getPointeeType();
   }
+  
+  bool isBoundable(ASTContext &C) const {
+    return isa<PointerType>(LValueType);
+  }  
 
   void Profile(llvm::FoldingSetNodeID& ID) const {
-    ProfileRegion(ID, T, superRegion);
+    ProfileRegion(ID, LValueType, superRegion);
   }
 
   static bool classof(const MemRegion* R) {
@@ -561,7 +565,8 @@ public:
   ObjCIvarRegion* getObjCIvarRegion(const ObjCIvarDecl* ivd,
                                     const MemRegion* superRegion);
 
-  TypedViewRegion* getTypedViewRegion(QualType t, const MemRegion* superRegion);
+  TypedViewRegion* getTypedViewRegion(QualType LValueType,
+                                      const MemRegion* superRegion);
 
   bool hasStackStorage(const MemRegion* R);
 
index c304b659b697332a5b1501e8d705a2bcb77bad9e..5bfc989eb8051c3cae9cef280d322384ccffeed6 100644 (file)
@@ -172,7 +172,7 @@ void AllocaRegion::print(llvm::raw_ostream& os) const {
 }
 
 void TypedViewRegion::print(llvm::raw_ostream& os) const {
-  os << "typed_view{" << T.getAsString() << ',';
+  os << "typed_view{" << LValueType.getAsString() << ',';
   getSuperRegion()->print(os);
   os << '}';
 }