diff options
author | Yaron Keren <yaron.keren@gmail.com> | 2017-04-17 08:51:20 +0000 |
---|---|---|
committer | Yaron Keren <yaron.keren@gmail.com> | 2017-04-17 08:51:20 +0000 |
commit | eb26f1e4a82d9e76c643e9253115a364e508610b (patch) | |
tree | b68c8f3410e885ebaaa0ccd5cdf9ba4fb551fdd5 /lib/AST/DeclBase.cpp | |
parent | 7b2a25cbbdb9d8495c576f86739d13cd055260de (diff) |
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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300443 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclBase.cpp')
-rw-r--r-- | lib/AST/DeclBase.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index cda70c5edc..ae7444579b 100644 --- a/lib/AST/DeclBase.cpp +++ b/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.). |