diff options
author | Artem Dergachev <artem.dergachev@gmail.com> | 2018-01-17 23:46:13 +0000 |
---|---|---|
committer | Artem Dergachev <artem.dergachev@gmail.com> | 2018-01-17 23:46:13 +0000 |
commit | 13b2026ba46eb2b439cb8074e2f8ccc5473ec51d (patch) | |
tree | 2df7455d003dd3868bac74fb075a87313a391971 /clang/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp | |
parent | edae5a6e11308852af43115da0a81533ca7ef3a6 (diff) | |
download | bcm5719-llvm-13b2026ba46eb2b439cb8074e2f8ccc5473ec51d.tar.gz bcm5719-llvm-13b2026ba46eb2b439cb8074e2f8ccc5473ec51d.zip |
[analyzer] operator new: Add a new checker callback, check::NewAllocator.
The callback runs after operator new() and before the construction and allows
the checker to access the casted return value of operator new() (in the
sense of r322780) which is not available in the PostCall callback for the
allocator call.
Update MallocChecker to use the new callback instead of PostStmt<CXXNewExpr>,
which gets called after the constructor.
Differential Revision: https://reviews.llvm.org/D41406
rdar://problem/12180598
llvm-svn: 322787
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp b/clang/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp index 95b6c4d3775..ab1e2ec1f54 100644 --- a/clang/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp @@ -42,6 +42,7 @@ class CheckerDocumentation : public Checker< check::PreStmt<ReturnStmt>, check::PreCall, check::PostCall, check::BranchCondition, + check::NewAllocator, check::Location, check::Bind, check::DeadSymbols, @@ -126,6 +127,22 @@ public: /// \brief Pre-visit of the condition statement of a branch (such as IfStmt). void checkBranchCondition(const Stmt *Condition, CheckerContext &Ctx) const {} + /// \brief Post-visit the C++ operator new's allocation call. + /// + /// Execution of C++ operator new consists of the following phases: (1) call + /// default or overridden operator new() to allocate memory (2) cast the + /// return value of operator new() from void pointer type to class pointer + /// type, (3) assuming that the value is non-null, call the object's + /// constructor over this pointer, (4) declare that the value of the + /// new-expression is this pointer. This callback is called between steps + /// (2) and (3). Post-call for the allocator is called after step (1). + /// Pre-statement for the new-expression is called on step (4) when the value + /// of the expression is evaluated. + /// \param NE The C++ new-expression that triggered the allocation. + /// \param Target The allocated region, casted to the class type. + void checkNewAllocator(const CXXNewExpr *NE, SVal Target, + CheckerContext &) const {} + /// \brief Called on a load from and a store to a location. /// /// The method will be called each time a location (pointer) value is |