diff --git a/clang/include/clang/Index/IndexSymbol.h b/clang/include/clang/Index/IndexSymbol.h --- a/clang/include/clang/Index/IndexSymbol.h +++ b/clang/include/clang/Index/IndexSymbol.h @@ -76,6 +76,7 @@ UsingTypename, UsingValue, UsingEnum, + UnresolvedUsing, }; typedef uint16_t SymbolPropertySet; diff --git a/clang/lib/Index/IndexSymbol.cpp b/clang/lib/Index/IndexSymbol.cpp --- a/clang/lib/Index/IndexSymbol.cpp +++ b/clang/lib/Index/IndexSymbol.cpp @@ -334,6 +334,11 @@ Info.Lang = SymbolLanguage::CXX; Info.SubKind = SymbolSubKind::UsingEnum; break; + case Decl::UnresolvedUsingIfExists: + Info.Kind = SymbolKind::Using; + Info.SubKind = SymbolSubKind::UnresolvedUsing; + Info.Lang = SymbolLanguage::CXX; + break; case Decl::Binding: Info.Kind = SymbolKind::Variable; Info.Lang = SymbolLanguage::CXX; @@ -549,6 +554,8 @@ case SymbolSubKind::UsingValue: return "using-value"; case SymbolSubKind::UsingEnum: return "using-enum"; + case SymbolSubKind::UnresolvedUsing: + return "using-unresolved"; } llvm_unreachable("invalid symbol subkind"); } diff --git a/clang/lib/Index/USRGeneration.cpp b/clang/lib/Index/USRGeneration.cpp --- a/clang/lib/Index/USRGeneration.cpp +++ b/clang/lib/Index/USRGeneration.cpp @@ -103,6 +103,7 @@ void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D); void VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D); void VisitUnresolvedUsingTypenameDecl(const UnresolvedUsingTypenameDecl *D); + void VisitUnresolvedUsingIfExistsDecl(const UnresolvedUsingIfExistsDecl *D); void VisitLinkageSpecDecl(const LinkageSpecDecl *D) { IgnoreResults = true; // No USRs for linkage specs themselves. @@ -1007,7 +1008,14 @@ Out << D->getName(); // Simple name. } - +void USRGenerator::VisitUnresolvedUsingIfExistsDecl( + const UnresolvedUsingIfExistsDecl *D) { + if (ShouldGenerateLocation(D) && GenLoc(D, /*IncludeOffset=*/isLocal(D))) + return; + VisitDeclContext(D->getDeclContext()); + Out << "@UUIE@"; + Out << D->getName(); +} //===----------------------------------------------------------------------===// // USR generation functions. diff --git a/clang/test/Index/using_if_exists.cpp b/clang/test/Index/using_if_exists.cpp new file mode 100644 --- /dev/null +++ b/clang/test/Index/using_if_exists.cpp @@ -0,0 +1,9 @@ +// RUN: c-index-test core -print-source-symbols -- %s -target x86_64-unknown-unknown 2>&1 | FileCheck %s + +namespace ns { +// void foo(); +} + +using ns::foo __attribute__((using_if_exists)); +// CHECK: [[@LINE-1]]:11 | using/C++ | foo | c:@UD@foo | | Decl | rel: 0 +// CHECK: [[@LINE-2]]:11 | using/using-unresolved/C++ | foo | c:using_if_exists.cpp@UUIE@foo | | Ref | rel: 0