[Lldb-commits] [clang-tools-extra] [clang] [lldb] [clang][NFC] Refactor `TagTypeKind` (PR #71160)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Nov 3 02:29:23 PDT 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clangd
@llvm/pr-subscribers-clang-codegen
Author: Vlad Serebrennikov (Endilll)
<details>
<summary>Changes</summary>
This patch converts TagTypeKind into scoped enum. Among other benefits, this allows us to forward-declare it where necessary.
I plan to land this patch as soon as pre-commit CI passes, probably not waiting for Windows bot.
---
Patch is 117.53 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/71160.diff
63 Files Affected:
- (modified) clang-tools-extra/clang-doc/BitcodeReader.cpp (+6-6)
- (modified) clang-tools-extra/clang-doc/Generators.cpp (+5-5)
- (modified) clang-tools-extra/clang-doc/Representation.h (+1-1)
- (modified) clang-tools-extra/clang-doc/YAMLGenerator.cpp (+5-5)
- (modified) clang-tools-extra/clangd/refactor/InsertionPoint.cpp (+1-1)
- (modified) clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp (+1-1)
- (modified) clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp (+1-1)
- (modified) clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp (+1-1)
- (modified) clang-tools-extra/unittests/clang-doc/MergeTest.cpp (+3-3)
- (modified) clang-tools-extra/unittests/clang-doc/SerializeTest.cpp (+13-13)
- (modified) clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp (+1-1)
- (modified) clang/include/clang/AST/ASTContext.h (+3-2)
- (modified) clang/include/clang/AST/Decl.h (+8-6)
- (modified) clang/include/clang/AST/Type.h (+6-6)
- (modified) clang/lib/AST/ASTContext.cpp (+6-6)
- (modified) clang/lib/AST/Decl.cpp (+6-6)
- (modified) clang/lib/AST/DeclCXX.cpp (+11-11)
- (modified) clang/lib/AST/DeclTemplate.cpp (+1-1)
- (modified) clang/lib/AST/MicrosoftMangle.cpp (+54-50)
- (modified) clang/lib/AST/RecordLayoutBuilder.cpp (+6-3)
- (modified) clang/lib/AST/Type.cpp (+20-15)
- (modified) clang/lib/CodeGen/CGObjCMac.cpp (+6-8)
- (modified) clang/lib/CodeGen/CGOpenMPRuntime.cpp (+1-1)
- (modified) clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp (+1-1)
- (modified) clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp (+18-19)
- (modified) clang/lib/Frontend/Rewrite/RewriteObjC.cpp (+16-16)
- (modified) clang/lib/Index/IndexSymbol.cpp (+5-5)
- (modified) clang/lib/Index/USRGeneration.cpp (+31-15)
- (modified) clang/lib/Sema/HLSLExternalSemaSource.cpp (+3-3)
- (modified) clang/lib/Sema/Sema.cpp (+3-2)
- (modified) clang/lib/Sema/SemaCodeComplete.cpp (+14-13)
- (modified) clang/lib/Sema/SemaDecl.cpp (+62-50)
- (modified) clang/lib/Sema/SemaDeclAttr.cpp (+1-1)
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+14-11)
- (modified) clang/lib/Sema/SemaDeclObjC.cpp (+1-1)
- (modified) clang/lib/Sema/SemaExprCXX.cpp (+4-5)
- (modified) clang/lib/Sema/SemaStmt.cpp (+3-2)
- (modified) clang/lib/Sema/SemaTemplate.cpp (+10-6)
- (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+2-2)
- (modified) clang/lib/Sema/SemaType.cpp (+21-9)
- (modified) clang/lib/Sema/TreeTransform.h (+6-4)
- (modified) clang/lib/Serialization/ASTReaderDecl.cpp (+2-2)
- (modified) clang/lib/Serialization/ASTWriter.cpp (+1-1)
- (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+2-1)
- (modified) clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp (+1-1)
- (modified) clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp (+1-1)
- (modified) clang/tools/libclang/CIndexCXX.cpp (+9-5)
- (modified) clang/unittests/AST/ASTImporterTest.cpp (+3-2)
- (modified) clang/utils/ClangVisualizers/clang.natvis (+5-5)
- (modified) lldb/source/Plugins/Language/ObjC/NSDictionary.cpp (+2-1)
- (modified) lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp (+2-2)
- (modified) lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp (+3-3)
- (modified) lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp (+4-4)
- (modified) lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp (+5-5)
- (modified) lldb/source/Plugins/RegisterTypeBuilder/RegisterTypeBuilderClang.cpp (+2-1)
- (modified) lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp (+7-7)
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (+6-5)
- (modified) lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp (+12-11)
- (modified) lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp (+4-4)
- (modified) lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp (+7-7)
- (modified) lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp (+2-1)
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+3-2)
- (modified) lldb/unittests/Symbol/TestTypeSystemClang.cpp (+17-10)
``````````diff
diff --git a/clang-tools-extra/clang-doc/BitcodeReader.cpp b/clang-tools-extra/clang-doc/BitcodeReader.cpp
index 9ac60fa73a782b4..cc7719f4630f00a 100644
--- a/clang-tools-extra/clang-doc/BitcodeReader.cpp
+++ b/clang-tools-extra/clang-doc/BitcodeReader.cpp
@@ -68,12 +68,12 @@ llvm::Error decodeRecord(const Record &R, AccessSpecifier &Field,
llvm::Error decodeRecord(const Record &R, TagTypeKind &Field,
llvm::StringRef Blob) {
switch (R[0]) {
- case TTK_Struct:
- case TTK_Interface:
- case TTK_Union:
- case TTK_Class:
- case TTK_Enum:
- Field = (TagTypeKind)R[0];
+ case TagTypeKind::Struct:
+ case TagTypeKind::Interface:
+ case TagTypeKind::Union:
+ case TagTypeKind::Class:
+ case TagTypeKind::Enum:
+ Field = static_cast<TagTypeKind>(R[0]);
return llvm::Error::success();
default:
return llvm::createStringError(llvm::inconvertibleErrorCode(),
diff --git a/clang-tools-extra/clang-doc/Generators.cpp b/clang-tools-extra/clang-doc/Generators.cpp
index da19c05ab67b9c7..a3986b66f3c7421 100644
--- a/clang-tools-extra/clang-doc/Generators.cpp
+++ b/clang-tools-extra/clang-doc/Generators.cpp
@@ -28,15 +28,15 @@ findGeneratorByName(llvm::StringRef Format) {
std::string getTagType(TagTypeKind AS) {
switch (AS) {
- case TagTypeKind::TTK_Class:
+ case TagTypeKind::Class:
return "class";
- case TagTypeKind::TTK_Union:
+ case TagTypeKind::Union:
return "union";
- case TagTypeKind::TTK_Interface:
+ case TagTypeKind::Interface:
return "interface";
- case TagTypeKind::TTK_Struct:
+ case TagTypeKind::Struct:
return "struct";
- case TagTypeKind::TTK_Enum:
+ case TagTypeKind::Enum:
return "enum";
}
llvm_unreachable("Unknown TagTypeKind");
diff --git a/clang-tools-extra/clang-doc/Representation.h b/clang-tools-extra/clang-doc/Representation.h
index aa5fa7f07083eba..a6b144eb7fa2a21 100644
--- a/clang-tools-extra/clang-doc/Representation.h
+++ b/clang-tools-extra/clang-doc/Representation.h
@@ -350,7 +350,7 @@ struct RecordInfo : public SymbolInfo {
void merge(RecordInfo &&I);
// Type of this record (struct, class, union, interface).
- TagTypeKind TagType = TagTypeKind::TTK_Struct;
+ TagTypeKind TagType = TagTypeKind::Struct;
// Full qualified name of this record, including namespaces and template
// specializations.
diff --git a/clang-tools-extra/clang-doc/YAMLGenerator.cpp b/clang-tools-extra/clang-doc/YAMLGenerator.cpp
index 57cb294e0ab6949..b612380a3cfa7fa 100644
--- a/clang-tools-extra/clang-doc/YAMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/YAMLGenerator.cpp
@@ -47,11 +47,11 @@ template <> struct ScalarEnumerationTraits<clang::AccessSpecifier> {
template <> struct ScalarEnumerationTraits<clang::TagTypeKind> {
static void enumeration(IO &IO, clang::TagTypeKind &Value) {
- IO.enumCase(Value, "Struct", clang::TagTypeKind::TTK_Struct);
- IO.enumCase(Value, "Interface", clang::TagTypeKind::TTK_Interface);
- IO.enumCase(Value, "Union", clang::TagTypeKind::TTK_Union);
- IO.enumCase(Value, "Class", clang::TagTypeKind::TTK_Class);
- IO.enumCase(Value, "Enum", clang::TagTypeKind::TTK_Enum);
+ IO.enumCase(Value, "Struct", clang::TagTypeKind::Struct);
+ IO.enumCase(Value, "Interface", clang::TagTypeKind::Interface);
+ IO.enumCase(Value, "Union", clang::TagTypeKind::Union);
+ IO.enumCase(Value, "Class", clang::TagTypeKind::Class);
+ IO.enumCase(Value, "Enum", clang::TagTypeKind::Enum);
}
};
diff --git a/clang-tools-extra/clangd/refactor/InsertionPoint.cpp b/clang-tools-extra/clangd/refactor/InsertionPoint.cpp
index 4b04021a5bd46d7..31440a05826a82f 100644
--- a/clang-tools-extra/clangd/refactor/InsertionPoint.cpp
+++ b/clang-tools-extra/clangd/refactor/InsertionPoint.cpp
@@ -85,7 +85,7 @@ SourceLocation endLoc(const DeclContext &DC) {
}
AccessSpecifier getAccessAtEnd(const CXXRecordDecl &C) {
- AccessSpecifier Spec = (C.getTagKind() == TTK_Class ? AS_private : AS_public);
+ AccessSpecifier Spec = (C.getTagKind() == Class ? AS_private : AS_public);
for (const auto *D : C.decls())
if (const auto *ASD = llvm::dyn_cast<AccessSpecDecl>(D))
Spec = ASD->getAccess();
diff --git a/clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp b/clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp
index 53e84b18144530d..5b9745af7810a9a 100644
--- a/clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp
+++ b/clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp
@@ -81,7 +81,7 @@ TEST(BitcodeTest, emitRecordInfoBitcode) {
I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
I.Members.emplace_back(TypeInfo("int"), "X", AccessSpecifier::AS_private);
- I.TagType = TagTypeKind::TTK_Class;
+ I.TagType = TagTypeKind::Class;
I.IsTypeDef = true;
I.Bases.emplace_back(EmptySID, "F", "path/to/F", true,
AccessSpecifier::AS_public, true);
diff --git a/clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp b/clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
index 51412591616533b..9aabb1ed30e4265 100644
--- a/clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ b/clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -154,7 +154,7 @@ TEST(HTMLGeneratorTest, emitRecordHTML) {
SmallString<16> PathTo;
llvm::sys::path::native("path/to", PathTo);
I.Members.emplace_back(TypeInfo("int"), "X", AccessSpecifier::AS_private);
- I.TagType = TagTypeKind::TTK_Class;
+ I.TagType = TagTypeKind::Class;
I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record, "F", PathTo);
I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record);
diff --git a/clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp b/clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
index 1bbd24eebb784a2..d3567efd82283cd 100644
--- a/clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
+++ b/clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
@@ -86,7 +86,7 @@ TEST(MDGeneratorTest, emitRecordMD) {
I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
I.Members.emplace_back(TypeInfo("int"), "X", AccessSpecifier::AS_private);
- I.TagType = TagTypeKind::TTK_Class;
+ I.TagType = TagTypeKind::Class;
I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record);
I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record);
diff --git a/clang-tools-extra/unittests/clang-doc/MergeTest.cpp b/clang-tools-extra/unittests/clang-doc/MergeTest.cpp
index 51fddb97decf0ea..9aa76524194b3b0 100644
--- a/clang-tools-extra/unittests/clang-doc/MergeTest.cpp
+++ b/clang-tools-extra/unittests/clang-doc/MergeTest.cpp
@@ -84,7 +84,7 @@ TEST(MergeTest, mergeRecordInfos) {
One.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
One.Members.emplace_back(TypeInfo("int"), "X", AccessSpecifier::AS_private);
- One.TagType = TagTypeKind::TTK_Class;
+ One.TagType = TagTypeKind::Class;
One.Parents.emplace_back(EmptySID, "F", InfoType::IT_record);
One.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record);
@@ -105,7 +105,7 @@ TEST(MergeTest, mergeRecordInfos) {
Two.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
- Two.TagType = TagTypeKind::TTK_Class;
+ Two.TagType = TagTypeKind::Class;
Two.Children.Records.emplace_back(NonEmptySID, "SharedChildStruct",
InfoType::IT_record, "path");
@@ -128,7 +128,7 @@ TEST(MergeTest, mergeRecordInfos) {
Expected->Members.emplace_back(TypeInfo("int"), "X",
AccessSpecifier::AS_private);
- Expected->TagType = TagTypeKind::TTK_Class;
+ Expected->TagType = TagTypeKind::Class;
Expected->Parents.emplace_back(EmptySID, "F", InfoType::IT_record);
Expected->VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record);
Expected->Bases.emplace_back(EmptySID, "F", "path/to/F", true,
diff --git a/clang-tools-extra/unittests/clang-doc/SerializeTest.cpp b/clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
index ca370de5a516e4a..5df42b9f5bca0b0 100644
--- a/clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
+++ b/clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
@@ -167,7 +167,7 @@ typedef struct {} G;)raw",
RecordInfo ExpectedE(EmptySID, /*Name=*/"E", /*Path=*/"GlobalNamespace");
ExpectedE.Namespace.emplace_back(EmptySID, "GlobalNamespace",
InfoType::IT_namespace);
- ExpectedE.TagType = TagTypeKind::TTK_Class;
+ ExpectedE.TagType = TagTypeKind::Class;
ExpectedE.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
ExpectedE.Members.emplace_back(TypeInfo("int"), "value",
AccessSpecifier::AS_public);
@@ -210,7 +210,7 @@ typedef struct {} G;)raw",
RecordInfo ExpectedF(EmptySID, /*Name=*/"F", /*Path=*/"GlobalNamespace");
ExpectedF.Namespace.emplace_back(EmptySID, "GlobalNamespace",
InfoType::IT_namespace);
- ExpectedF.TagType = TagTypeKind::TTK_Struct;
+ ExpectedF.TagType = TagTypeKind::Struct;
ExpectedF.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
CheckRecordInfo(&ExpectedF, F);
@@ -253,7 +253,7 @@ typedef struct {} G;)raw",
RecordInfo ExpectedG(EmptySID, /*Name=*/"G", /*Path=*/"GlobalNamespace");
ExpectedG.Namespace.emplace_back(EmptySID, "GlobalNamespace",
InfoType::IT_namespace);
- ExpectedG.TagType = TagTypeKind::TTK_Struct;
+ ExpectedG.TagType = TagTypeKind::Struct;
ExpectedG.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
ExpectedG.IsTypeDef = true;
CheckRecordInfo(&ExpectedG, G);
@@ -295,7 +295,7 @@ TEST(SerializeTest, emitUndefinedRecordInfo) {
RecordInfo ExpectedE(EmptySID, /*Name=*/"E", /*Path=*/"GlobalNamespace");
ExpectedE.Namespace.emplace_back(EmptySID, "GlobalNamespace",
InfoType::IT_namespace);
- ExpectedE.TagType = TagTypeKind::TTK_Class;
+ ExpectedE.TagType = TagTypeKind::Class;
ExpectedE.Loc.emplace_back(0, llvm::SmallString<16>{"test.cpp"});
CheckRecordInfo(&ExpectedE, E);
}
@@ -308,7 +308,7 @@ TEST(SerializeTest, emitRecordMemberInfo) {
RecordInfo ExpectedE(EmptySID, /*Name=*/"E", /*Path=*/"GlobalNamespace");
ExpectedE.Namespace.emplace_back(EmptySID, "GlobalNamespace",
InfoType::IT_namespace);
- ExpectedE.TagType = TagTypeKind::TTK_Struct;
+ ExpectedE.TagType = TagTypeKind::Struct;
ExpectedE.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
ExpectedE.Members.emplace_back(TypeInfo("int"), "I",
AccessSpecifier::AS_public);
@@ -324,7 +324,7 @@ TEST(SerializeTest, emitInternalRecordInfo) {
ExpectedE.Namespace.emplace_back(EmptySID, "GlobalNamespace",
InfoType::IT_namespace);
ExpectedE.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
- ExpectedE.TagType = TagTypeKind::TTK_Class;
+ ExpectedE.TagType = TagTypeKind::Class;
CheckRecordInfo(&ExpectedE, E);
RecordInfo *G = InfoAsRecord(Infos[2].get());
@@ -332,7 +332,7 @@ TEST(SerializeTest, emitInternalRecordInfo) {
llvm::sys::path::native(ExpectedGPath);
RecordInfo ExpectedG(EmptySID, /*Name=*/"G", /*Path=*/ExpectedGPath);
ExpectedG.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
- ExpectedG.TagType = TagTypeKind::TTK_Class;
+ ExpectedG.TagType = TagTypeKind::Class;
ExpectedG.Namespace.emplace_back(EmptySID, "E", InfoType::IT_record);
ExpectedG.Namespace.emplace_back(EmptySID, "GlobalNamespace",
InfoType::IT_namespace);
@@ -391,7 +391,7 @@ class J : public I<int> {} ;)raw",
RecordInfo ExpectedF(EmptySID, /*Name=*/"F", /*Path=*/"GlobalNamespace");
ExpectedF.Namespace.emplace_back(EmptySID, "GlobalNamespace",
InfoType::IT_namespace, "");
- ExpectedF.TagType = TagTypeKind::TTK_Class;
+ ExpectedF.TagType = TagTypeKind::Class;
ExpectedF.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
CheckRecordInfo(&ExpectedF, F);
@@ -399,7 +399,7 @@ class J : public I<int> {} ;)raw",
RecordInfo ExpectedG(EmptySID, /*Name=*/"G", /*Path=*/"GlobalNamespace");
ExpectedG.Namespace.emplace_back(EmptySID, "GlobalNamespace",
InfoType::IT_namespace);
- ExpectedG.TagType = TagTypeKind::TTK_Class;
+ ExpectedG.TagType = TagTypeKind::Class;
ExpectedG.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
ExpectedG.Members.emplace_back(TypeInfo("int"), "I",
AccessSpecifier::AS_protected);
@@ -446,14 +446,14 @@ class J : public I<int> {} ;)raw",
ExpectedE.Bases.back().Members.emplace_back(TypeInfo("int"), "I",
AccessSpecifier::AS_private);
ExpectedE.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
- ExpectedE.TagType = TagTypeKind::TTK_Class;
+ ExpectedE.TagType = TagTypeKind::Class;
CheckRecordInfo(&ExpectedE, E);
RecordInfo *H = InfoAsRecord(Infos[8].get());
RecordInfo ExpectedH(EmptySID, /*Name=*/"H", /*Path=*/"GlobalNamespace");
ExpectedH.Namespace.emplace_back(EmptySID, "GlobalNamespace",
InfoType::IT_namespace);
- ExpectedH.TagType = TagTypeKind::TTK_Class;
+ ExpectedH.TagType = TagTypeKind::Class;
ExpectedH.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
ExpectedH.Parents.emplace_back(EmptySID, /*Name=*/"E", InfoType::IT_record,
/*QualName=*/"E", /*Path=*/"GlobalNamespace");
@@ -500,7 +500,7 @@ class J : public I<int> {} ;)raw",
RecordInfo ExpectedI(EmptySID, /*Name=*/"I", /*Path=*/"GlobalNamespace");
ExpectedI.Namespace.emplace_back(EmptySID, "GlobalNamespace",
InfoType::IT_namespace);
- ExpectedI.TagType = TagTypeKind::TTK_Class;
+ ExpectedI.TagType = TagTypeKind::Class;
ExpectedI.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
CheckRecordInfo(&ExpectedI, I);
@@ -514,7 +514,7 @@ class J : public I<int> {} ;)raw",
/*Path=*/"GlobalNamespace", false,
AccessSpecifier::AS_public, true);
ExpectedJ.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
- ExpectedJ.TagType = TagTypeKind::TTK_Class;
+ ExpectedJ.TagType = TagTypeKind::Class;
CheckRecordInfo(&ExpectedJ, J);
}
diff --git a/clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp b/clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp
index 535d49169b5dfff..9b1d87dfa013566 100644
--- a/clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp
+++ b/clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp
@@ -101,7 +101,7 @@ TEST(YAMLGeneratorTest, emitRecordYAML) {
Brief->Children.back()->Text = "Value of the thing.";
I.Members.back().Description.push_back(std::move(TopComment));
- I.TagType = TagTypeKind::TTK_Class;
+ I.TagType = TagTypeKind::Class;
I.Bases.emplace_back(EmptySID, "F", "path/to/F", true,
AccessSpecifier::AS_public, true);
I.Bases.back().Children.Functions.emplace_back();
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h
index e5f78dfdc22ab1b..6bb308247223989 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1197,8 +1197,9 @@ class ASTContext : public RefCountedBase<ASTContext> {
/// Create a new implicit TU-level CXXRecordDecl or RecordDecl
/// declaration.
- RecordDecl *buildImplicitRecord(StringRef Name,
- RecordDecl::TagKind TK = TTK_Struct) const;
+ RecordDecl *buildImplicitRecord(
+ StringRef Name,
+ RecordDecl::TagKind TK = RecordDecl::TagKind::Struct) const;
/// Create a new implicit TU-level typedef declaration.
TypedefDecl *buildImplicitTypedef(QualType T, StringRef Name) const;
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index d8ea8c1dfb4f292..d8495f2c34940c5 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -3703,13 +3703,15 @@ class TagDecl : public TypeDecl,
return static_cast<TagKind>(TagDeclBits.TagDeclKind);
}
- void setTagKind(TagKind TK) { TagDeclBits.TagDeclKind = TK; }
+ void setTagKind(TagKind TK) {
+ TagDeclBits.TagDeclKind = llvm::to_underlying(TK);
+ }
- bool isStruct() const { return getTagKind() == TTK_Struct; }
- bool isInterface() const { return getTagKind() == TTK_Interface; }
- bool isClass() const { return getTagKind() == TTK_Class; }
- bool isUnion() const { return getTagKind() == TTK_Union; }
- bool isEnum() const { return getTagKind() == TTK_Enum; }
+ bool isStruct() const { return getTagKind() == TagTypeKind::Struct; }
+ bool isInterface() const { return getTagKind() == TagTypeKind::Interface; }
+ bool isClass() const { return getTagKind() == TagTypeKind::Class; }
+ bool isUnion() const { return getTagKind() == TagTypeKind::Union; }
+ bool isEnum() const { return getTagKind() == TagTypeKind::Enum; }
/// Is this tag type named, either directly or via being defined in
/// a typedef of this type?
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index f64cd5e0ef64910..42e9b8f94b4e7b6 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -5718,21 +5718,21 @@ enum class ElaboratedTypeKeyword {
};
/// The kind of a tag type.
-enum TagTypeKind {
+enum class TagTypeKind {
/// The "struct" keyword.
- TTK_Struct,
+ Struct,
/// The "__interface" keyword.
- TTK_Interface,
+ Interface,
/// The "union" keyword.
- TTK_Union,
+ Union,
/// The "class" keyword.
- TTK_Class,
+ Class,
/// The "enum" keyword.
- TTK_Enum
+ Enum
};
/// A helper class for Type nodes having an ElaboratedTypeKeyword.
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 1cb81cffd37ea58..da90136752210b6 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -6525,12 +6525,12 @@ bool ASTContext::isSameEntity(const NamedDecl *X, const NamedDecl *Y) const {
if (const auto *TagX = dyn_cast<TagDecl>(X)) {
const auto *TagY = cast<TagDecl>(Y);
return (TagX->getTagKind() == TagY->getTagKind()) ||
- ((TagX->getTagKind() == TTK_Struct ||
- TagX->getTagKind() == TTK_Class ||
- TagX->getTagKind() == TTK_Interface) &&
- (TagY->getTagKind() == TTK_Struct ||
- TagY->getTagKind() == TTK_Class ||
- TagY->getTagKind() == TTK_Interface));
+ ((TagX->getTagKind() == TagTypeKind::Struct ||
+ TagX->getTagKind() == TagTypeKind::Class ||
+ TagX->getTagKind() == TagTypeKind::Interface) &&
+ (TagY->getTagKind() == TagTypeKind::Struct ||
+ TagY->getTagKind() == TagTypeKind::Class ||
+ TagY->getTagKind() == TagTypeKind::Interface));
}
// Functions with the same type and linkage match.
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index e8062b680fbc3ab..e1f8adb92134890 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -4638,8 +4638,8 @@ TagDecl::TagDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC,
SourceLocation StartL)
: TypeDecl(DK, DC, L, Id, StartL), DeclContext(DK), redeclarable_base(C),
TypedefNameDeclOrQualifier((TypedefNameDecl *)nullptr) {
- assert((DK != Enum || TK == TTK_Enum) &&
- "EnumDecl not matched with TTK_Enum");
+ assert((DK != Enum || TK == TagTypeKind::Enum) &&
+ "EnumDecl not matched with TagTypeKind::Enum");
setPreviousDecl(PrevDecl);
setTagKind(TK);
setCompleteDefinition(false);
@@ -4772,7 +4772,7 @@ void TagDecl::setTemplateParameterListsInfo(
EnumDecl::EnumDecl(ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl,
bool Scoped, bool ScopedUsingClassTag, bool Fixed)
- : TagDecl(Enum, TTK_Enum, C, DC, IdLoc, Id, PrevDecl, StartLoc) {
+ : TagDecl(Enum, TagTypeKind::Enum, C, DC, IdLoc, Id, PrevDecl, StartLoc) {
assert(Scoped || !ScopedUsingClassTag);
IntegerType = nullptr;
setNumPositiveBits(0);
@@ -4961,9 +4961,9 @@ RecordDecl *RecordDecl::Create(const ASTContext &C, TagKind TK, DeclContext *DC,
}
R...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/71160
More information about the lldb-commits
mailing list