aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/DeclBase.cpp
diff options
context:
space:
mode:
authorYaron Keren <yaron.keren@gmail.com>2017-04-17 08:51:20 +0000
committerYaron Keren <yaron.keren@gmail.com>2017-04-17 08:51:20 +0000
commit27e2ff964fc3e18c27488e15dc74b44ef32d2fe0 (patch)
tree7ea962556c927a86fc590391ea20320b75fed0f0 /clang/lib/AST/DeclBase.cpp
parent11d9c4f691b68f8abcba85345abd4d3067cbee3f (diff)
downloadllvm-27e2ff964fc3e18c27488e15dc74b44ef32d2fe0.zip
llvm-27e2ff964fc3e18c27488e15dc74b44ef32d2fe0.tar.gz
llvm-27e2ff964fc3e18c27488e15dc74b44ef32d2fe0.tar.bz2
Address http://bugs.llvm.org/pr30994 so that a non-friend can properly replace a friend, and a visible friend can properly replace an invisible friend but not vice verse, and definitions are not replaced. This fixes the two FIXME in SemaTemplate/friend-template.cpp.
The code implements Richard Smith suggestion in comment 3 of the PR. reviewer: Vassil Vassilev Differential Revision: https://reviews.llvm.org/D31540 llvm-svn: 300443
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r--clang/lib/AST/DeclBase.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index cda70c5..ae74445 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -861,6 +861,21 @@ const FunctionType *Decl::getFunctionType(bool BlocksToo) const {
return Ty->getAs<FunctionType>();
}
+bool Decl::isThisDeclarationADefinition() const {
+ if (auto *TD = dyn_cast<TagDecl>(this))
+ return TD->isThisDeclarationADefinition();
+ if (auto *FD = dyn_cast<FunctionDecl>(this))
+ return FD->isThisDeclarationADefinition();
+ if (auto *VD = dyn_cast<VarDecl>(this))
+ return VD->isThisDeclarationADefinition();
+ if (auto *CTD = dyn_cast<ClassTemplateDecl>(this))
+ return CTD->isThisDeclarationADefinition();
+ if (auto *FTD = dyn_cast<FunctionTemplateDecl>(this))
+ return FTD->isThisDeclarationADefinition();
+ if (auto *VTD = dyn_cast<VarTemplateDecl>(this))
+ return VTD->isThisDeclarationADefinition();
+ return false;
+}
/// Starting at a given context (a Decl or DeclContext), look for a
/// code context that is not a closure (a lambda, block, etc.).