summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
authorArtem Belevich <tra@google.com>2018-09-21 17:29:33 +0000
committerArtem Belevich <tra@google.com>2018-09-21 17:29:33 +0000
commit78929efb4dcbb2c8aeba46eee912a614d4ecebb9 (patch)
treed8ae6e44b0267bf826d68a01e9ad339e984d9cc0 /clang/lib/AST
parenta3d0f409647a2051c1cd1546c48369f9f9ce3f27 (diff)
downloadbcm5719-llvm-78929efb4dcbb2c8aeba46eee912a614d4ecebb9.tar.gz
bcm5719-llvm-78929efb4dcbb2c8aeba46eee912a614d4ecebb9.zip
[CUDA] Ignore uncallable functions when we check for usual deallocators.
Previously clang considered function variants from both sides of compilation and that resulted in picking up wrong deallocation function. Differential Revision: https://reviews.llvm.org/D51808 llvm-svn: 342749
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/DeclCXX.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 8582b543dfb..5c708694913 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -2005,7 +2005,9 @@ CXXMethodDecl *CXXMethodDecl::getDevirtualizedMethod(const Expr *Base,
return nullptr;
}
-bool CXXMethodDecl::isUsualDeallocationFunction() const {
+bool CXXMethodDecl::isUsualDeallocationFunction(
+ SmallVectorImpl<const FunctionDecl *> &PreventedBy) const {
+ assert(PreventedBy.empty() && "PreventedBy is expected to be empty");
if (getOverloadedOperator() != OO_Delete &&
getOverloadedOperator() != OO_Array_Delete)
return false;
@@ -2063,14 +2065,16 @@ bool CXXMethodDecl::isUsualDeallocationFunction() const {
// This function is a usual deallocation function if there are no
// single-parameter deallocation functions of the same kind.
DeclContext::lookup_result R = getDeclContext()->lookup(getDeclName());
- for (DeclContext::lookup_result::iterator I = R.begin(), E = R.end();
- I != E; ++I) {
- if (const auto *FD = dyn_cast<FunctionDecl>(*I))
- if (FD->getNumParams() == 1)
- return false;
+ bool Result = true;
+ for (const auto *D : R) {
+ if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
+ if (FD->getNumParams() == 1) {
+ PreventedBy.push_back(FD);
+ Result = false;
+ }
+ }
}
-
- return true;
+ return Result;
}
bool CXXMethodDecl::isCopyAssignmentOperator() const {
OpenPOWER on IntegriCloud