diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-10-13 01:55:36 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-10-13 01:55:36 +0000 |
commit | 5b34958b46dc14267d1b06099c3bd43e748716fc (patch) | |
tree | c3e9bded9164d23dfcc44b90914d040d087e18e5 /clang/lib/AST/Decl.cpp | |
parent | ad38fbffad842c3baf4589139271d16d14af0357 (diff) | |
download | bcm5719-llvm-5b34958b46dc14267d1b06099c3bd43e748716fc.tar.gz bcm5719-llvm-5b34958b46dc14267d1b06099c3bd43e748716fc.zip |
Support for destroying operator delete, per C++2a proposal P0722.
This feature is not (yet) approved by the C++ committee, so this is liable to
be reverted or significantly modified based on committee feedback.
No functionality change intended for existing code (a new type must be defined
in namespace std to take advantage of this feature).
llvm-svn: 315662
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r-- | clang/lib/AST/Decl.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 4a9b9bea830..9b0d976ebb2 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -2732,6 +2732,20 @@ bool FunctionDecl::isReplaceableGlobalAllocationFunction(bool *IsAligned) const return Params == FPT->getNumParams(); } +bool FunctionDecl::isDestroyingOperatorDelete() const { + // C++ P0722: + // Within a class C, a single object deallocation function with signature + // (T, std::destroying_delete_t, <more params>) + // is a destroying operator delete. + if (!isa<CXXMethodDecl>(this) || getOverloadedOperator() != OO_Delete || + getNumParams() < 2) + return false; + + auto *RD = getParamDecl(1)->getType()->getAsCXXRecordDecl(); + return RD && RD->isInStdNamespace() && RD->getIdentifier() && + RD->getIdentifier()->isStr("destroying_delete_t"); +} + LanguageLinkage FunctionDecl::getLanguageLinkage() const { return getDeclLanguageLinkage(*this); } |