aboutsummaryrefslogtreecommitdiff
path: root/include/clang
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-07-02 22:21:47 +0000
committerJordan Rose <jordan_rose@apple.com>2012-07-02 22:21:47 +0000
commit70cbf3cc09eb21db1108396d30a414ea66d842cc (patch)
tree616162322cc763100a3285634585fcadab7c6b2c /include/clang
parent879a4334e4c4cab0c22ba91492ffc2838bbc21fc (diff)
[analyzer] Introduce CXXAllocatorCall to handle placement arg invalidation.
This is NOT full-blown support for operator new, but removes some nasty duplicated code introduced in r158784. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159608 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang')
-rw-r--r--include/clang/StaticAnalyzer/Core/PathSensitive/Calls.h32
1 files changed, 31 insertions, 1 deletions
diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/Calls.h b/include/clang/StaticAnalyzer/Core/PathSensitive/Calls.h
index f5d6309884..f2c251f86f 100644
--- a/include/clang/StaticAnalyzer/Core/PathSensitive/Calls.h
+++ b/include/clang/StaticAnalyzer/Core/PathSensitive/Calls.h
@@ -33,8 +33,9 @@ enum CallEventKind {
CE_BEG_SIMPLE_CALLS = CE_Function,
CE_END_SIMPLE_CALLS = CE_Block,
CE_CXXConstructor,
+ CE_CXXAllocator,
CE_BEG_FUNCTION_CALLS = CE_Function,
- CE_END_FUNCTION_CALLS = CE_CXXConstructor,
+ CE_END_FUNCTION_CALLS = CE_CXXAllocator,
CE_ObjCMessage,
CE_ObjCPropertyAccess,
CE_BEG_OBJC_CALLS = CE_ObjCMessage,
@@ -337,6 +338,35 @@ public:
}
};
+class CXXAllocatorCall : public AnyFunctionCall {
+ const CXXNewExpr *E;
+
+public:
+ CXXAllocatorCall(const CXXNewExpr *e, ProgramStateRef St,
+ const LocationContext *LCtx)
+ : AnyFunctionCall(St, LCtx, CE_CXXAllocator), E(e) {}
+
+ const CXXNewExpr *getOriginExpr() const { return E; }
+ SourceRange getSourceRange() const { return E->getSourceRange(); }
+
+ const FunctionDecl *getDecl() const {
+ return E->getOperatorNew();
+ }
+
+ unsigned getNumArgs() const { return E->getNumPlacementArgs() + 1; }
+
+ const Expr *getArgExpr(unsigned Index) const {
+ // The first argument of an allocator call is the size of the allocation.
+ if (Index == 0)
+ return 0;
+ return E->getPlacementArg(Index - 1);
+ }
+
+ static bool classof(const CallEvent *CE) {
+ return CE->getKind() == CE_CXXAllocator;
+ }
+};
+
/// \brief Represents any expression that calls an Objective-C method.
class ObjCMethodCall : public CallEvent {
const ObjCMessageExpr *Msg;