aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Index/USRGeneration.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Index/USRGeneration.cpp')
-rw-r--r--clang/lib/Index/USRGeneration.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Index/USRGeneration.cpp b/clang/lib/Index/USRGeneration.cpp
index 77b05b6..06a3717 100644
--- a/clang/lib/Index/USRGeneration.cpp
+++ b/clang/lib/Index/USRGeneration.cpp
@@ -1141,6 +1141,15 @@ bool clang::index::generateUSRForDecl(const Decl *D,
// C++'s operator new function, can have invalid locations but it is fine to
// create USRs that can identify them.
+ // Check if the declaration has explicit external USR specified.
+ auto *CD = D->getCanonicalDecl();
+ if (auto *ExternalSymAttr = CD->getAttr<ExternalSourceSymbolAttr>()) {
+ if (!ExternalSymAttr->getUSR().empty()) {
+ llvm::raw_svector_ostream Out(Buf);
+ Out << ExternalSymAttr->getUSR();
+ return false;
+ }
+ }
USRGenerator UG(&D->getASTContext(), Buf);
UG.Visit(D);
return UG.ignoreResults();