[clang] 699ae92 - [Index] Add various missing USR generation
Ben Barham via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 28 11:51:17 PST 2022
Author: Ben Barham
Date: 2022-11-28T11:51:08-08:00
New Revision: 699ae92f045331b555394b8b9757d7e0fbf97100
URL: https://github.com/llvm/llvm-project/commit/699ae92f045331b555394b8b9757d7e0fbf97100
DIFF: https://github.com/llvm/llvm-project/commit/699ae92f045331b555394b8b9757d7e0fbf97100.diff
LOG: [Index] Add various missing USR generation
Over the years there's been many builtin types added without
corresponding USRs. Add a `@BT@<name>` USR for all these types. Also add
a comment so that hopefully this doesn't continue happening.
`MSGuid` was also missing a USR, use `@MG at GUID{<uuid>}` for it.
Resolves rdar://102198268.
Differential Revision: https://reviews.llvm.org/D138322
Added:
clang/test/Index/index-builtin-fixedpoint.c
clang/test/Index/index-builtin-opencl.clcpp
clang/test/Index/index-builtin-ppc.cpp
clang/test/Index/index-builtin-riscv.c
clang/test/Index/index-builtin-sve.cpp
clang/test/Index/index-msguid.cpp
Modified:
clang/lib/Index/USRGeneration.cpp
Removed:
################################################################################
diff --git a/clang/lib/Index/USRGeneration.cpp b/clang/lib/Index/USRGeneration.cpp
index 19b8ff9d51207..d41c54348ac89 100644
--- a/clang/lib/Index/USRGeneration.cpp
+++ b/clang/lib/Index/USRGeneration.cpp
@@ -168,6 +168,8 @@ class USRGenerator : public ConstDeclVisitor<USRGenerator> {
void VisitTemplateName(TemplateName Name);
void VisitTemplateArgument(const TemplateArgument &Arg);
+ void VisitMSGuidDecl(const MSGuidDecl *D);
+
/// Emit a Decl's name using NamedDecl::printName() and return true if
/// the decl had no name.
bool EmitDeclName(const NamedDecl *D);
@@ -658,120 +660,157 @@ void USRGenerator::VisitType(QualType T) {
}
if (const BuiltinType *BT = T->getAs<BuiltinType>()) {
- unsigned char c = '\0';
switch (BT->getKind()) {
case BuiltinType::Void:
- c = 'v'; break;
+ Out << 'v'; break;
case BuiltinType::Bool:
- c = 'b'; break;
+ Out << 'b'; break;
case BuiltinType::UChar:
- c = 'c'; break;
+ Out << 'c'; break;
case BuiltinType::Char8:
- c = 'u'; break; // FIXME: Check this doesn't collide
+ Out << 'u'; break;
case BuiltinType::Char16:
- c = 'q'; break;
+ Out << 'q'; break;
case BuiltinType::Char32:
- c = 'w'; break;
+ Out << 'w'; break;
case BuiltinType::UShort:
- c = 's'; break;
+ Out << 's'; break;
case BuiltinType::UInt:
- c = 'i'; break;
+ Out << 'i'; break;
case BuiltinType::ULong:
- c = 'l'; break;
+ Out << 'l'; break;
case BuiltinType::ULongLong:
- c = 'k'; break;
+ Out << 'k'; break;
case BuiltinType::UInt128:
- c = 'j'; break;
+ Out << 'j'; break;
case BuiltinType::Char_U:
case BuiltinType::Char_S:
- c = 'C'; break;
+ Out << 'C'; break;
case BuiltinType::SChar:
- c = 'r'; break;
+ Out << 'r'; break;
case BuiltinType::WChar_S:
case BuiltinType::WChar_U:
- c = 'W'; break;
+ Out << 'W'; break;
case BuiltinType::Short:
- c = 'S'; break;
+ Out << 'S'; break;
case BuiltinType::Int:
- c = 'I'; break;
+ Out << 'I'; break;
case BuiltinType::Long:
- c = 'L'; break;
+ Out << 'L'; break;
case BuiltinType::LongLong:
- c = 'K'; break;
+ Out << 'K'; break;
case BuiltinType::Int128:
- c = 'J'; break;
+ Out << 'J'; break;
case BuiltinType::Float16:
case BuiltinType::Half:
- c = 'h'; break;
+ Out << 'h'; break;
case BuiltinType::Float:
- c = 'f'; break;
+ Out << 'f'; break;
case BuiltinType::Double:
- c = 'd'; break;
- case BuiltinType::Ibm128: // FIXME: Need separate tag
+ Out << 'd'; break;
case BuiltinType::LongDouble:
- c = 'D'; break;
+ Out << 'D'; break;
case BuiltinType::Float128:
- c = 'Q'; break;
+ Out << 'Q'; break;
case BuiltinType::NullPtr:
- c = 'n'; break;
-#define BUILTIN_TYPE(Id, SingletonId)
-#define PLACEHOLDER_TYPE(Id, SingletonId) case BuiltinType::Id:
-#include "clang/AST/BuiltinTypes.def"
- case BuiltinType::Dependent:
+ Out << 'n'; break;
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
- case BuiltinType::Id:
+ case BuiltinType::Id: \
+ Out << "@BT@" << #Suffix << "_" << #ImgType; break;
#include "clang/Basic/OpenCLImageTypes.def"
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
- case BuiltinType::Id:
+ case BuiltinType::Id: \
+ Out << "@BT@" << #ExtType; break;
#include "clang/Basic/OpenCLExtensionTypes.def"
case BuiltinType::OCLEvent:
+ Out << "@BT at OCLEvent"; break;
case BuiltinType::OCLClkEvent:
+ Out << "@BT at OCLClkEvent"; break;
case BuiltinType::OCLQueue:
+ Out << "@BT at OCLQueue"; break;
case BuiltinType::OCLReserveID:
+ Out << "@BT at OCLReserveID"; break;
case BuiltinType::OCLSampler:
+ Out << "@BT at OCLSampler"; break;
#define SVE_TYPE(Name, Id, SingletonId) \
- case BuiltinType::Id:
+ case BuiltinType::Id: \
+ Out << "@BT@" << Name; break;
#include "clang/Basic/AArch64SVEACLETypes.def"
#define PPC_VECTOR_TYPE(Name, Id, Size) \
- case BuiltinType::Id:
+ case BuiltinType::Id: \
+ Out << "@BT@" << #Name; break;
#include "clang/Basic/PPCTypes.def"
-#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
+#define RVV_TYPE(Name, Id, SingletonId) \
+ case BuiltinType::Id: \
+ Out << "@BT@" << Name; break;
#include "clang/Basic/RISCVVTypes.def"
case BuiltinType::ShortAccum:
+ Out << "@BT at ShortAccum"; break;
case BuiltinType::Accum:
+ Out << "@BT at Accum"; break;
case BuiltinType::LongAccum:
+ Out << "@BT at LongAccum"; break;
case BuiltinType::UShortAccum:
+ Out << "@BT at UShortAccum"; break;
case BuiltinType::UAccum:
+ Out << "@BT at UAccum"; break;
case BuiltinType::ULongAccum:
+ Out << "@BT at ULongAccum"; break;
case BuiltinType::ShortFract:
+ Out << "@BT at ShortFract"; break;
case BuiltinType::Fract:
+ Out << "@BT at Fract"; break;
case BuiltinType::LongFract:
+ Out << "@BT at LongFract"; break;
case BuiltinType::UShortFract:
+ Out << "@BT at UShortFract"; break;
case BuiltinType::UFract:
+ Out << "@BT at UFract"; break;
case BuiltinType::ULongFract:
+ Out << "@BT at ULongFract"; break;
case BuiltinType::SatShortAccum:
+ Out << "@BT at SatShortAccum"; break;
case BuiltinType::SatAccum:
+ Out << "@BT at SatAccum"; break;
case BuiltinType::SatLongAccum:
+ Out << "@BT at SatLongAccum"; break;
case BuiltinType::SatUShortAccum:
+ Out << "@BT at SatUShortAccum"; break;
case BuiltinType::SatUAccum:
+ Out << "@BT at SatUAccum"; break;
case BuiltinType::SatULongAccum:
+ Out << "@BT at SatULongAccum"; break;
case BuiltinType::SatShortFract:
+ Out << "@BT at SatShortFract"; break;
case BuiltinType::SatFract:
+ Out << "@BT at SatFract"; break;
case BuiltinType::SatLongFract:
+ Out << "@BT at SatLongFract"; break;
case BuiltinType::SatUShortFract:
+ Out << "@BT at SatUShortFract"; break;
case BuiltinType::SatUFract:
+ Out << "@BT at SatUFract"; break;
case BuiltinType::SatULongFract:
+ Out << "@BT at SatULongFract"; break;
case BuiltinType::BFloat16:
- IgnoreResults = true;
- return;
+ Out << "@BT at __bf16"; break;
+ case BuiltinType::Ibm128:
+ Out << "@BT at __ibm128"; break;
case BuiltinType::ObjCId:
- c = 'o'; break;
+ Out << 'o'; break;
case BuiltinType::ObjCClass:
- c = 'O'; break;
+ Out << 'O'; break;
case BuiltinType::ObjCSel:
- c = 'e'; break;
+ Out << 'e'; break;
+#define BUILTIN_TYPE(Id, SingletonId)
+#define PLACEHOLDER_TYPE(Id, SingletonId) case BuiltinType::Id:
+#include "clang/AST/BuiltinTypes.def"
+ case BuiltinType::Dependent:
+ // If you're adding a new builtin type, please add its name prefixed
+ // with "@BT@" to `Out` (see cases above).
+ IgnoreResults = true;
+ break;
}
- Out << c;
return;
}
@@ -1017,6 +1056,12 @@ void USRGenerator::VisitConceptDecl(const ConceptDecl *D) {
EmitDeclName(D);
}
+void USRGenerator::VisitMSGuidDecl(const MSGuidDecl *D) {
+ VisitDeclContext(D->getDeclContext());
+ Out << "@MG@";
+ D->NamedDecl::printName(Out);
+}
+
//===----------------------------------------------------------------------===//
// USR generation functions.
//===----------------------------------------------------------------------===//
diff --git a/clang/test/Index/index-builtin-fixedpoint.c b/clang/test/Index/index-builtin-fixedpoint.c
new file mode 100644
index 0000000000000..5fe09dadd1e14
--- /dev/null
+++ b/clang/test/Index/index-builtin-fixedpoint.c
@@ -0,0 +1,5 @@
+__attribute__((overloadable))
+void testFixedPoint(_Accum);
+// CHECK: USR: c:@F at testFixedPoint#@BT at Accum#
+
+// RUN: c-index-test -index-file %s -ffixed-point | FileCheck %s
diff --git a/clang/test/Index/index-builtin-opencl.clcpp b/clang/test/Index/index-builtin-opencl.clcpp
new file mode 100644
index 0000000000000..c934712ab50ff
--- /dev/null
+++ b/clang/test/Index/index-builtin-opencl.clcpp
@@ -0,0 +1,7 @@
+void testImage(read_only image1d_t);
+// CHECK: USR: c:@F at testImage#@BT at ro_image1d#
+
+void testExt(intel_sub_group_avc_mce_payload_t) {}
+// CHECK: USR: c:@F at testExt#@BT at intel_sub_group_avc_mce_payload_t#
+
+// RUN: c-index-test -index-file %s --target=spir | FileCheck %s
diff --git a/clang/test/Index/index-builtin-ppc.cpp b/clang/test/Index/index-builtin-ppc.cpp
new file mode 100644
index 0000000000000..1a7358b6cef37
--- /dev/null
+++ b/clang/test/Index/index-builtin-ppc.cpp
@@ -0,0 +1,7 @@
+void testPpc(__vector_quad);
+// CHECK: USR: c:@F at testPpc#@BT at __vector_quad#
+
+void testIBM(__ibm128);
+// CHECK: USR: c:@F at testIBM#@BT at __ibm128#
+//
+// RUN: c-index-test -index-file %s --target=powerpc64 -target-cpu pwr10 | FileCheck %s
diff --git a/clang/test/Index/index-builtin-riscv.c b/clang/test/Index/index-builtin-riscv.c
new file mode 100644
index 0000000000000..46690a7e7cf0c
--- /dev/null
+++ b/clang/test/Index/index-builtin-riscv.c
@@ -0,0 +1,5 @@
+__attribute__((overloadable))
+void testRiscv(__rvv_int8mf8_t);
+// CHECK: USR: c:@F at testRiscv#@BT at __rvv_int8mf8_t#
+
+// RUN: c-index-test -index-file %s --target=riscv64 -target-feature +v | FileCheck %s
diff --git a/clang/test/Index/index-builtin-sve.cpp b/clang/test/Index/index-builtin-sve.cpp
new file mode 100644
index 0000000000000..cc148a21578fa
--- /dev/null
+++ b/clang/test/Index/index-builtin-sve.cpp
@@ -0,0 +1,7 @@
+void testSve(__SVInt8_t sve);
+// CHECK: USR: c:@F at testSve#@BT at __SVInt8_t#
+
+void testBf16(__bf16);
+// CHECK: USR: c:@F at testBf16#@BT at __bf16#
+
+// RUN: c-index-test -index-file %s --target=aarch64 -target-feature +bf16 -target-feature +sve -std=c++11 | FileCheck %s
diff --git a/clang/test/Index/index-msguid.cpp b/clang/test/Index/index-msguid.cpp
new file mode 100644
index 0000000000000..4b1ceb7916a22
--- /dev/null
+++ b/clang/test/Index/index-msguid.cpp
@@ -0,0 +1,14 @@
+template <class T, const _GUID &ID = __uuidof(T)>
+class GUIDHolder {
+public:
+ virtual ~GUIDHolder() {}
+};
+
+class __declspec(uuid("12345678-1234-5678-ABCD-12345678ABCD")) GUIDInterface {};
+
+class GUIDUse : public GUIDHolder<GUIDInterface> {
+ ~GUIDUse() {}
+ // CHECK: RelOver | ~GUIDHolder | c:@S at GUIDHolder>#$@S at GUIDInterface#@MG at GUID{12345678-1234-5678-abcd-12345678abcd}@F@~GUIDHolder#
+};
+
+// RUN: c-index-test core -print-source-symbols -- -std=c++11 -fms-extensions %s | FileCheck %s
More information about the cfe-commits
mailing list