Skip to content

Commit 52482d3

Browse files
committed
fixup! [Clang] Add __type_list_dedup builtin to deduplicate types in template arguments
Rename type_list_dedup to __builtin_type_pack_dedup
1 parent 1ad5858 commit 52482d3

File tree

16 files changed

+54
-54
lines changed

16 files changed

+54
-54
lines changed

clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ TEST_F(TargetDeclTest, BuiltinTemplates) {
734734

735735
Code = R"cpp(
736736
template <template <class...> class Templ, class... Types>
737-
using type_list_dedup = [[__type_list_dedup]]<Templ, Types...>;
737+
using __builtin_type_pack_dedup = [[__builtin_type_pack_dedup]]<Templ, Types...>;
738738
)cpp";
739739
EXPECT_DECLS("TemplateSpecializationTypeLoc", );
740740
}

clang/include/clang/AST/ASTContext.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,8 @@ class ASTContext : public RefCountedBase<ASTContext> {
403403
/// The identifier '__type_pack_element'.
404404
mutable IdentifierInfo *TypePackElementName = nullptr;
405405

406-
/// The identifier '__type_list_dedup'.
407-
mutable IdentifierInfo *TypeListDedupName = nullptr;
406+
/// The identifier '__builtin_type_pack_dedup'.
407+
mutable IdentifierInfo *TypePackDedupName = nullptr;
408408

409409
QualType ObjCConstantStringType;
410410
mutable RecordDecl *CFConstantStringTagDecl = nullptr;
@@ -613,7 +613,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
613613
mutable ExternCContextDecl *ExternCContext = nullptr;
614614
mutable BuiltinTemplateDecl *MakeIntegerSeqDecl = nullptr;
615615
mutable BuiltinTemplateDecl *TypePackElementDecl = nullptr;
616-
mutable BuiltinTemplateDecl *TypeListDedupDecl = nullptr;
616+
mutable BuiltinTemplateDecl *TypePackDedupDecl = nullptr;
617617

618618
/// The associated SourceManager object.
619619
SourceManager &SourceMgr;
@@ -1121,7 +1121,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
11211121
ExternCContextDecl *getExternCContextDecl() const;
11221122
BuiltinTemplateDecl *getMakeIntegerSeqDecl() const;
11231123
BuiltinTemplateDecl *getTypePackElementDecl() const;
1124-
BuiltinTemplateDecl *getTypeListDedupDecl() const;
1124+
BuiltinTemplateDecl *getTypePackDedupDecl() const;
11251125

11261126
// Builtin Types.
11271127
CanQualType VoidTy;
@@ -2013,10 +2013,10 @@ class ASTContext : public RefCountedBase<ASTContext> {
20132013
return TypePackElementName;
20142014
}
20152015

2016-
IdentifierInfo *getTypeListDedupName() const {
2017-
if (!TypeListDedupName)
2018-
TypeListDedupName = &Idents.get("__type_list_dedup");
2019-
return TypeListDedupName;
2016+
IdentifierInfo *getTypePackDedupName() const {
2017+
if (!TypePackDedupName)
2018+
TypePackDedupName = &Idents.get("__builtin_type_pack_dedup");
2019+
return TypePackDedupName;
20202020
}
20212021

20222022
/// Retrieve the Objective-C "instancetype" type, if already known;

clang/include/clang/AST/DeclID.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ enum PredefinedDeclIDs {
8383
/// The internal '__type_pack_element' template.
8484
PREDEF_DECL_TYPE_PACK_ELEMENT_ID,
8585

86-
/// The internal '__type_list_dedup' template.
87-
PREDEF_DECL_TYPE_LIST_DEDUP_ID,
86+
/// The internal '__builtin_type_pack_dedup' template.
87+
PREDEF_DECL___builtin_type_pack_dedup_ID,
8888

8989
/// The number of declaration IDs that are predefined.
9090
NUM_PREDEF_DECL_IDS

clang/include/clang/Basic/Builtins.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ enum BuiltinTemplateKind : int {
311311
/// This names the __type_pack_element BuiltinTemplateDecl.
312312
BTK__type_pack_element,
313313

314-
/// This names the __type_list_dedup BuiltinTemplateDecl.
315-
BTK__type_list_dedup,
314+
/// This names the __builtin_type_pack_dedup BuiltinTemplateDecl.
315+
BTK__type_pack_dedup,
316316
};
317317

318318
} // end namespace clang

clang/lib/AST/ASTContext.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,11 +1170,11 @@ ASTContext::getTypePackElementDecl() const {
11701170
return TypePackElementDecl;
11711171
}
11721172

1173-
BuiltinTemplateDecl *ASTContext::getTypeListDedupDecl() const {
1174-
if (!TypeListDedupDecl)
1175-
TypeListDedupDecl =
1176-
buildBuiltinTemplateDecl(BTK__type_list_dedup, getTypeListDedupName());
1177-
return TypeListDedupDecl;
1173+
BuiltinTemplateDecl *ASTContext::getTypePackDedupDecl() const {
1174+
if (!TypePackDedupDecl)
1175+
TypePackDedupDecl =
1176+
buildBuiltinTemplateDecl(BTK__type_pack_dedup, getTypePackDedupName());
1177+
return TypePackDedupDecl;
11781178
}
11791179

11801180
RecordDecl *ASTContext::buildImplicitRecord(StringRef Name,

clang/lib/AST/ASTImporter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5467,8 +5467,8 @@ ExpectedDecl ASTNodeImporter::VisitBuiltinTemplateDecl(BuiltinTemplateDecl *D) {
54675467
case BuiltinTemplateKind::BTK__type_pack_element:
54685468
ToD = Importer.getToContext().getTypePackElementDecl();
54695469
break;
5470-
case BuiltinTemplateKind::BTK__type_list_dedup:
5471-
ToD = Importer.getToContext().getTypeListDedupDecl();
5470+
case BuiltinTemplateKind::BTK__type_pack_dedup:
5471+
ToD = Importer.getToContext().getTypePackDedupDecl();
54725472
break;
54735473
}
54745474
assert(ToD && "BuiltinTemplateDecl of unsupported kind!");

clang/lib/AST/DeclTemplate.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,7 +1609,7 @@ createTypePackElementParameterList(const ASTContext &C, DeclContext *DC) {
16091609
}
16101610

16111611
static TemplateParameterList *
1612-
createTypeListDedupParameterList(const ASTContext &C, DeclContext *DC) {
1612+
createTypePackDedupParameterList(const ASTContext &C, DeclContext *DC) {
16131613
// template <typename ...> typename Templ
16141614
auto *InnerTs = TemplateTypeParmDecl::Create(
16151615
C, DC, SourceLocation(), SourceLocation(), /*Depth=*/1, /*Position=*/0,
@@ -1644,8 +1644,8 @@ static TemplateParameterList *createBuiltinTemplateParameterList(
16441644
return createMakeIntegerSeqParameterList(C, DC);
16451645
case BTK__type_pack_element:
16461646
return createTypePackElementParameterList(C, DC);
1647-
case BTK__type_list_dedup:
1648-
return createTypeListDedupParameterList(C, DC);
1647+
case BTK__type_pack_dedup:
1648+
return createTypePackDedupParameterList(C, DC);
16491649
}
16501650

16511651
llvm_unreachable("unhandled BuiltinTemplateKind!");

clang/lib/Lex/PPMacroExpansion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1836,7 +1836,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
18361836
// Report builtin templates as being builtins.
18371837
.Case("__make_integer_seq", getLangOpts().CPlusPlus)
18381838
.Case("__type_pack_element", getLangOpts().CPlusPlus)
1839-
.Case("__type_list_dedup", getLangOpts().CPlusPlus)
1839+
.Case("__builtin_type_pack_dedup", getLangOpts().CPlusPlus)
18401840
// Likewise for some builtin preprocessor macros.
18411841
// FIXME: This is inconsistent; we usually suggest detecting
18421842
// builtin macros via #ifdef. Don't add more cases here.

clang/lib/Sema/SemaLookup.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,8 +933,8 @@ bool Sema::LookupBuiltin(LookupResult &R) {
933933
R.addDecl(getASTContext().getTypePackElementDecl());
934934
return true;
935935
}
936-
if (II == getASTContext().getTypeListDedupName()) {
937-
R.addDecl(getASTContext().getTypeListDedupDecl());
936+
if (II == getASTContext().getTypePackDedupName()) {
937+
R.addDecl(getASTContext().getTypePackDedupDecl());
938938
return true;
939939
}
940940
}

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3161,9 +3161,9 @@ checkBuiltinTemplateIdType(Sema &SemaRef, BuiltinTemplateDecl *BTD,
31613161
int64_t N = Index.getExtValue();
31623162
return Ts.getPackAsArray()[N].getAsType();
31633163
}
3164-
case BTK__type_list_dedup: {
3164+
case BTK__type_pack_dedup: {
31653165
assert(Converted.size() == 2 &&
3166-
"__type_list_dedup should be given a template and a parameter pack");
3166+
"__builtin_type_pack_dedup should be given a template and a parameter pack");
31673167
TemplateArgument Template = Converted[0];
31683168
TemplateArgument Ts = Converted[1];
31693169
if (Template.isDependent() || Ts.isDependent())

0 commit comments

Comments
 (0)