Skip to content

Commit fb647b4

Browse files
author
git apple-llvm automerger
committed
Merge commit '03cc174e0307' from llvm.org/release/19.x into stable/20240723
2 parents 726f964 + 03cc174 commit fb647b4

File tree

7 files changed

+23
-109
lines changed

7 files changed

+23
-109
lines changed

clang/include/clang/AST/ASTContext.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,13 +1834,6 @@ class ASTContext : public RefCountedBase<ASTContext> {
18341834
QualType DeducedType,
18351835
bool IsDependent) const;
18361836

1837-
private:
1838-
QualType getDeducedTemplateSpecializationTypeInternal(TemplateName Template,
1839-
QualType DeducedType,
1840-
bool IsDependent,
1841-
QualType Canon) const;
1842-
1843-
public:
18441837
/// Return the unique reference to the type for the specified TagDecl
18451838
/// (struct/union/class/enum) decl.
18461839
QualType getTagDeclType(const TagDecl *Decl) const;

clang/include/clang/AST/TemplateName.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,7 @@ class TemplateName {
347347
/// error.
348348
void dump() const;
349349

350-
void Profile(llvm::FoldingSetNodeID &ID) {
351-
ID.AddPointer(Storage.getOpaqueValue());
352-
}
350+
void Profile(llvm::FoldingSetNodeID &ID);
353351

354352
/// Retrieve the template name as a void pointer.
355353
void *getAsVoidPointer() const { return Storage.getOpaqueValue(); }

clang/include/clang/AST/Type.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6436,27 +6436,30 @@ class DeducedTemplateSpecializationType : public DeducedType,
64366436

64376437
DeducedTemplateSpecializationType(TemplateName Template,
64386438
QualType DeducedAsType,
6439-
bool IsDeducedAsDependent, QualType Canon)
6439+
bool IsDeducedAsDependent)
64406440
: DeducedType(DeducedTemplateSpecialization, DeducedAsType,
64416441
toTypeDependence(Template.getDependence()) |
64426442
(IsDeducedAsDependent
64436443
? TypeDependence::DependentInstantiation
64446444
: TypeDependence::None),
6445-
Canon),
6445+
DeducedAsType.isNull() ? QualType(this, 0)
6446+
: DeducedAsType.getCanonicalType()),
64466447
Template(Template) {}
64476448

64486449
public:
64496450
/// Retrieve the name of the template that we are deducing.
64506451
TemplateName getTemplateName() const { return Template;}
64516452

6452-
void Profile(llvm::FoldingSetNodeID &ID) const {
6453+
void Profile(llvm::FoldingSetNodeID &ID) {
64536454
Profile(ID, getTemplateName(), getDeducedType(), isDependentType());
64546455
}
64556456

64566457
static void Profile(llvm::FoldingSetNodeID &ID, TemplateName Template,
64576458
QualType Deduced, bool IsDependent) {
64586459
Template.Profile(ID);
6459-
Deduced.Profile(ID);
6460+
QualType CanonicalType =
6461+
Deduced.isNull() ? Deduced : Deduced.getCanonicalType();
6462+
ID.AddPointer(CanonicalType.getAsOpaquePtr());
64606463
ID.AddBoolean(IsDependent || Template.isDependent());
64616464
}
64626465

clang/lib/AST/ASTContext.cpp

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6299,9 +6299,11 @@ QualType ASTContext::getUnconstrainedType(QualType T) const {
62996299
return T;
63006300
}
63016301

6302-
QualType ASTContext::getDeducedTemplateSpecializationTypeInternal(
6303-
TemplateName Template, QualType DeducedType, bool IsDependent,
6304-
QualType Canon) const {
6302+
/// Return the uniqued reference to the deduced template specialization type
6303+
/// which has been deduced to the given type, or to the canonical undeduced
6304+
/// such type, or the canonical deduced-but-dependent such type.
6305+
QualType ASTContext::getDeducedTemplateSpecializationType(
6306+
TemplateName Template, QualType DeducedType, bool IsDependent) const {
63056307
// Look in the folding set for an existing type.
63066308
void *InsertPos = nullptr;
63076309
llvm::FoldingSetNodeID ID;
@@ -6312,8 +6314,7 @@ QualType ASTContext::getDeducedTemplateSpecializationTypeInternal(
63126314
return QualType(DTST, 0);
63136315

63146316
auto *DTST = new (*this, alignof(DeducedTemplateSpecializationType))
6315-
DeducedTemplateSpecializationType(Template, DeducedType, IsDependent,
6316-
Canon);
6317+
DeducedTemplateSpecializationType(Template, DeducedType, IsDependent);
63176318
llvm::FoldingSetNodeID TempID;
63186319
DTST->Profile(TempID);
63196320
assert(ID == TempID && "ID does not match");
@@ -6322,20 +6323,6 @@ QualType ASTContext::getDeducedTemplateSpecializationTypeInternal(
63226323
return QualType(DTST, 0);
63236324
}
63246325

6325-
/// Return the uniqued reference to the deduced template specialization type
6326-
/// which has been deduced to the given type, or to the canonical undeduced
6327-
/// such type, or the canonical deduced-but-dependent such type.
6328-
QualType ASTContext::getDeducedTemplateSpecializationType(
6329-
TemplateName Template, QualType DeducedType, bool IsDependent) const {
6330-
QualType Canon = DeducedType.isNull()
6331-
? getDeducedTemplateSpecializationTypeInternal(
6332-
getCanonicalTemplateName(Template), QualType(),
6333-
IsDependent, QualType())
6334-
: DeducedType.getCanonicalType();
6335-
return getDeducedTemplateSpecializationTypeInternal(Template, DeducedType,
6336-
IsDependent, Canon);
6337-
}
6338-
63396326
/// getAtomicType - Return the uniqued reference to the atomic type for
63406327
/// the given value type.
63416328
QualType ASTContext::getAtomicType(QualType T) const {

clang/lib/AST/TemplateName.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,15 @@ bool TemplateName::containsUnexpandedParameterPack() const {
264264
return getDependence() & TemplateNameDependence::UnexpandedPack;
265265
}
266266

267+
void TemplateName::Profile(llvm::FoldingSetNodeID &ID) {
268+
if (const auto* USD = getAsUsingShadowDecl())
269+
ID.AddPointer(USD->getCanonicalDecl());
270+
else if (const auto *TD = getAsTemplateDecl())
271+
ID.AddPointer(TD->getCanonicalDecl());
272+
else
273+
ID.AddPointer(Storage.getOpaqueValue());
274+
}
275+
267276
void TemplateName::print(raw_ostream &OS, const PrintingPolicy &Policy,
268277
Qualified Qual) const {
269278
auto handleAnonymousTTP = [](TemplateDecl *TD, raw_ostream &OS) {

clang/unittests/AST/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ add_clang_unittest(ASTTests
3131
EvaluateAsRValueTest.cpp
3232
ExternalASTSourceTest.cpp
3333
NamedDeclPrinterTest.cpp
34-
ProfilingTest.cpp
3534
RandstructTest.cpp
3635
RecursiveASTVisitorTest.cpp
3736
SizelessTypesTest.cpp

clang/unittests/AST/ProfilingTest.cpp

Lines changed: 0 additions & 75 deletions
This file was deleted.

0 commit comments

Comments
 (0)