aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Analysis/PathSensitive
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-01-05 02:18:06 +0000
committerTed Kremenek <kremenek@apple.com>2010-01-05 02:18:06 +0000
commitde0d26310191215a6d1d189dc419f87af18ce6be (patch)
treecc02b6955e8dccac16a1af71f81a404044c5a2d0 /include/clang/Analysis/PathSensitive
parent6ffe643322949dd776285a6df60d3578f3918be4 (diff)
Make static analysis support for C++ 'this' expression context-sensitive. Essentially treat 'this' as a implicit parameter to the method call, and associate a region with it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92675 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Analysis/PathSensitive')
-rw-r--r--include/clang/Analysis/PathSensitive/MemRegion.h50
-rw-r--r--include/clang/Analysis/PathSensitive/Store.h3
2 files changed, 41 insertions, 12 deletions
diff --git a/include/clang/Analysis/PathSensitive/MemRegion.h b/include/clang/Analysis/PathSensitive/MemRegion.h
index b57cfd7b52..99aa3e15d7 100644
--- a/include/clang/Analysis/PathSensitive/MemRegion.h
+++ b/include/clang/Analysis/PathSensitive/MemRegion.h
@@ -65,6 +65,7 @@ public:
BlockTextRegionKind,
BlockDataRegionKind,
CompoundLiteralRegionKind,
+ CXXThisRegionKind,
StringRegionKind,
ElementRegionKind,
// Decl Regions.
@@ -99,17 +100,13 @@ public:
const MemRegion *StripCasts() const;
- bool hasStackStorage() const;
-
- bool hasParametersStorage() const;
-
- bool hasGlobalsStorage() const;
-
bool hasGlobalsOrParametersStorage() const;
- bool hasHeapStorage() const;
-
- bool hasHeapOrStackStorage() const;
+ bool hasStackStorage() const;
+
+ bool hasStackNonParametersStorage() const;
+
+ bool hasStackParametersStorage() const;
virtual void dumpToStream(llvm::raw_ostream& os) const;
@@ -634,6 +631,36 @@ public:
return R->getKind() == VarRegionKind;
}
};
+
+/// CXXThisRegion - Represents the region for the implicit 'this' parameter
+/// in a call to a C++ method. This region doesn't represent the object
+/// referred to by 'this', but rather 'this' itself.
+class CXXThisRegion : public TypedRegion {
+ friend class MemRegionManager;
+ CXXThisRegion(const PointerType *thisPointerTy,
+ const MemRegion *sReg)
+ : TypedRegion(sReg, CXXThisRegionKind), ThisPointerTy(thisPointerTy) {}
+
+ static void ProfileRegion(llvm::FoldingSetNodeID &ID,
+ const PointerType *PT,
+ const MemRegion *sReg);
+
+ void Profile(llvm::FoldingSetNodeID &ID) const;
+
+public:
+ QualType getValueType(ASTContext &C) const {
+ return QualType(ThisPointerTy, 0);
+ }
+
+ void dumpToStream(llvm::raw_ostream& os) const;
+
+ static bool classof(const MemRegion* R) {
+ return R->getKind() == CXXThisRegionKind;
+ }
+
+private:
+ const PointerType *ThisPointerTy;
+};
class FieldRegion : public DeclRegion {
friend class MemRegionManager;
@@ -824,6 +851,11 @@ public:
const CompoundLiteralRegion*
getCompoundLiteralRegion(const CompoundLiteralExpr* CL,
const LocationContext *LC);
+
+ /// getCXXThisRegion - Retrieve the [artifical] region associated with the
+ /// parameter 'this'.
+ const CXXThisRegion *getCXXThisRegion(QualType thisPointerTy,
+ const LocationContext *LC);
/// getSymbolicRegion - Retrieve or create a "symbolic" memory region.
const SymbolicRegion* getSymbolicRegion(SymbolRef sym);
diff --git a/include/clang/Analysis/PathSensitive/Store.h b/include/clang/Analysis/PathSensitive/Store.h
index 52d73da15b..aaf8223b66 100644
--- a/include/clang/Analysis/PathSensitive/Store.h
+++ b/include/clang/Analysis/PathSensitive/Store.h
@@ -103,9 +103,6 @@ public:
virtual SVal getLValueElement(QualType elementType, SVal offset, SVal Base)=0;
- // T - the object type.
- Loc getThisObject(QualType T);
-
// FIXME: Make out-of-line.
virtual DefinedOrUnknownSVal getSizeInElements(const GRState *state,
const MemRegion *region) {