diff options
Diffstat (limited to 'clang/lib/Index')
| -rw-r--r-- | clang/lib/Index/IndexBody.cpp | 20 | ||||
| -rw-r--r-- | clang/lib/Index/IndexDecl.cpp | 1 | ||||
| -rw-r--r-- | clang/lib/Index/IndexSymbol.cpp | 1 | ||||
| -rw-r--r-- | clang/lib/Index/USRGeneration.cpp | 16 |
4 files changed, 30 insertions, 8 deletions
diff --git a/clang/lib/Index/IndexBody.cpp b/clang/lib/Index/IndexBody.cpp index 8b8235c13302..e5f1764550ff 100644 --- a/clang/lib/Index/IndexBody.cpp +++ b/clang/lib/Index/IndexBody.cpp @@ -203,9 +203,12 @@ public: bool VisitDesignatedInitExpr(DesignatedInitExpr *E) { for (DesignatedInitExpr::Designator &D : llvm::reverse(E->designators())) { - if (D.isFieldDesignator() && D.getField()) - return IndexCtx.handleReference(D.getField(), D.getFieldLoc(), Parent, - ParentDC, SymbolRoleSet(), {}, E); + if (D.isFieldDesignator()) { + if (const FieldDecl *FD = D.getFieldDecl()) { + return IndexCtx.handleReference(FD, D.getFieldLoc(), Parent, + ParentDC, SymbolRoleSet(), {}, E); + } + } } return true; } @@ -417,10 +420,13 @@ public: auto visitSyntacticDesignatedInitExpr = [&](DesignatedInitExpr *E) -> bool { for (DesignatedInitExpr::Designator &D : llvm::reverse(E->designators())) { - if (D.isFieldDesignator() && D.getField()) - return IndexCtx.handleReference(D.getField(), D.getFieldLoc(), - Parent, ParentDC, SymbolRoleSet(), - {}, E); + if (D.isFieldDesignator()) { + if (const FieldDecl *FD = D.getFieldDecl()) { + return IndexCtx.handleReference(FD, D.getFieldLoc(), Parent, + ParentDC, SymbolRoleSet(), + /*Relations=*/{}, E); + } + } } return true; }; diff --git a/clang/lib/Index/IndexDecl.cpp b/clang/lib/Index/IndexDecl.cpp index 882e02836d4f..1c04aa17d53f 100644 --- a/clang/lib/Index/IndexDecl.cpp +++ b/clang/lib/Index/IndexDecl.cpp @@ -705,6 +705,7 @@ public: IndexCtx.handleReference(C->getNamedConcept(), C->getConceptNameLoc(), Parent, TTP->getLexicalDeclContext()); } else if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(TP)) { + IndexCtx.indexTypeSourceInfo(NTTP->getTypeSourceInfo(), Parent); if (NTTP->hasDefaultArgument()) IndexCtx.indexBody(NTTP->getDefaultArgument(), Parent); } else if (const auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(TP)) { diff --git a/clang/lib/Index/IndexSymbol.cpp b/clang/lib/Index/IndexSymbol.cpp index a40c218a3c43..d7316538f606 100644 --- a/clang/lib/Index/IndexSymbol.cpp +++ b/clang/lib/Index/IndexSymbol.cpp @@ -71,7 +71,6 @@ bool index::isFunctionLocalSymbol(const Decl *D) { return true; case VisibleNoLinkage: case UniqueExternalLinkage: - case ModuleInternalLinkage: llvm_unreachable("Not a sema linkage"); case ModuleLinkage: case ExternalLinkage: diff --git a/clang/lib/Index/USRGeneration.cpp b/clang/lib/Index/USRGeneration.cpp index d41c54348ac8..b10028a526ed 100644 --- a/clang/lib/Index/USRGeneration.cpp +++ b/clang/lib/Index/USRGeneration.cpp @@ -226,6 +226,11 @@ void USRGenerator::VisitFunctionDecl(const FunctionDecl *D) { if (ShouldGenerateLocation(D) && GenLoc(D, /*IncludeOffset=*/isLocal(D))) return; + if (D->getType().isNull()) { + IgnoreResults = true; + return; + } + const unsigned StartSize = Buf.size(); VisitDeclContext(D->getDeclContext()); if (Buf.size() == StartSize) @@ -744,6 +749,8 @@ void USRGenerator::VisitType(QualType T) { case BuiltinType::Id: \ Out << "@BT@" << Name; break; #include "clang/Basic/RISCVVTypes.def" +#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id: +#include "clang/Basic/WebAssemblyReferenceTypes.def" case BuiltinType::ShortAccum: Out << "@BT@ShortAccum"; break; case BuiltinType::Accum: @@ -1139,6 +1146,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(); |
