diff options
author | Anton Yartsev <anton.yartsev@gmail.com> | 2013-03-28 16:10:38 +0000 |
---|---|---|
committer | Anton Yartsev <anton.yartsev@gmail.com> | 2013-03-28 16:10:38 +0000 |
commit | 697462881c4b9b704c7859f4bab0a6116c684bb1 (patch) | |
tree | b80287ad1d017e8c8773445845370d61457ded97 /lib/StaticAnalyzer/Checkers/MallocChecker.cpp | |
parent | 829d187e2100d2cfd85acefc2e867d12336e393f (diff) |
[analyzer] For now assume all standard global 'operator new' functions allocate memory in heap.
+ Improved test coverage for cplusplus.NewDelete checker.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178244 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Checkers/MallocChecker.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Checkers/MallocChecker.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index 068f9ce822..2598445866 100644 --- a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -457,6 +457,10 @@ bool MallocChecker::isFreeFunction(const FunctionDecl *FD, ASTContext &C) const return false; } +// Tells if the callee is one of the following: +// 1) A global non-placement new/delete operator function. +// 2) A global placement operator function with the single placement argument +// of type std::nothrow_t. bool MallocChecker::isStandardNewDelete(const FunctionDecl *FD, ASTContext &C) const { if (!FD) @@ -467,9 +471,8 @@ bool MallocChecker::isStandardNewDelete(const FunctionDecl *FD, Kind != OO_Delete && Kind != OO_Array_Delete) return false; - // Skip custom new operators. - if (!FD->isImplicit() && - !C.getSourceManager().isInSystemHeader(FD->getLocStart())) + // Skip all operator new/delete methods. + if (isa<CXXMethodDecl>(FD)) return false; // Return true if tested operator is a standard placement nothrow operator. |