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 | 11d704839fc46f65556d674113043a86f54ca4e8 (patch) | |
tree | 57c60211cc55452802df63224771540cc7be5db1 /clang/lib/AST/DeclBase.cpp | |
parent | f1c3beecb253bf10d0d8da4a96a1c008b05f4e94 (diff) | |
download | bcm5719-llvm-11d704839fc46f65556d674113043a86f54ca4e8.tar.gz bcm5719-llvm-11d704839fc46f65556d674113043a86f54ca4e8.zip |
[index] Fix forward declarations interfering with USR generation of external source symbols
Patch by Nathan Hawes.
https://reviews.llvm.org/D33346
llvm-svn: 303484
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index f6f81692611..81cd1cc4265 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/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>(); } |