diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2017-05-20 04:11:33 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2017-05-20 04:11:33 +0000 |
commit | 088eaf5b7b121f70b2fe6b4328b7d8819c9f2aab (patch) | |
tree | a8a413232d882ecbb75bb3777857e5f70e0d1200 /lib/AST/DeclBase.cpp | |
parent | c43ddad88323c190c3579268a24803d552e64a02 (diff) |
[index] Fix forward declarations interfering with USR generation of external source symbols
Patch by Nathan Hawes.
https://reviews.llvm.org/D33346
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303484 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclBase.cpp')
-rw-r--r-- | lib/AST/DeclBase.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index f6f8169261..81cd1cc426 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -407,6 +407,27 @@ bool Decl::isExported() const { return false; } +ExternalSourceSymbolAttr *Decl::getExternalSourceSymbolAttr() const { + const Decl *Definition = nullptr; + if (auto ID = dyn_cast<ObjCInterfaceDecl>(this)) { + Definition = ID->getDefinition(); + } else if (auto PD = dyn_cast<ObjCProtocolDecl>(this)) { + Definition = PD->getDefinition(); + } else if (auto TD = dyn_cast<TagDecl>(this)) { + Definition = TD->getDefinition(); + } + if (!Definition) + Definition = this; + + if (auto *attr = Definition->getAttr<ExternalSourceSymbolAttr>()) + return attr; + if (auto *dcd = dyn_cast<Decl>(getDeclContext())) { + return dcd->getAttr<ExternalSourceSymbolAttr>(); + } + + return nullptr; +} + bool Decl::hasDefiningAttr() const { return hasAttr<AliasAttr>() || hasAttr<IFuncAttr>(); } |