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 | 8b662704dc68e56e5df3763bb6816f0a07930fbb (patch) | |
| tree | 84334c3b5b80d2efe7eb2d61fa5ab4f8498f8c6d /clang/lib/StaticAnalyzer/Checkers | |
| parent | c2aa348dd0ab28df2974f9c94c750277d04a5e8a (diff) | |
| download | bcm5719-llvm-8b662704dc68e56e5df3763bb6816f0a07930fbb.tar.gz bcm5719-llvm-8b662704dc68e56e5df3763bb6816f0a07930fbb.zip | |
[analyzer] For now assume all standard global 'operator new' functions allocate memory in heap.
+ Improved test coverage for cplusplus.NewDelete checker.
llvm-svn: 178244
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers')
| -rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index 068f9ce822a..25984458665 100644 --- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/clang/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. |

