aboutsummaryrefslogtreecommitdiff
path: root/include/clang
diff options
context:
space:
mode:
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;