Skip to content

Commit 62e4b50

Browse files
committed
1 parent bb9b964 commit 62e4b50

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+362
-1868
lines changed

clang/include/clang/AST/ASTContext.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ class AtomicExpr;
8888
class BlockExpr;
8989
class BuiltinTemplateDecl;
9090
class CharUnits;
91-
class ConceptDecl;
9291
class CXXABI;
9392
class CXXConstructorDecl;
9493
class CXXMethodDecl;
@@ -212,7 +211,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
212211
mutable llvm::FoldingSet<ObjCObjectPointerType> ObjCObjectPointerTypes;
213212
mutable llvm::FoldingSet<DependentUnaryTransformType>
214213
DependentUnaryTransformTypes;
215-
mutable llvm::ContextualFoldingSet<AutoType, ASTContext&> AutoTypes;
214+
mutable llvm::FoldingSet<AutoType> AutoTypes;
216215
mutable llvm::FoldingSet<DeducedTemplateSpecializationType>
217216
DeducedTemplateSpecializationTypes;
218217
mutable llvm::FoldingSet<AtomicType> AtomicTypes;
@@ -1543,9 +1542,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
15431542

15441543
/// C++11 deduced auto type.
15451544
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword,
1546-
bool IsDependent, bool IsPack = false,
1547-
ConceptDecl *TypeConstraintConcept = nullptr,
1548-
ArrayRef<TemplateArgument> TypeConstraintArgs ={}) const;
1545+
bool IsDependent, bool IsPack = false) const;
15491546

15501547
/// C++11 deduction pattern for 'auto' type.
15511548
QualType getAutoDeductType() const;

clang/include/clang/AST/ASTNodeTraverser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,8 @@ class ASTNodeTraverser
548548
}
549549

550550
void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D) {
551-
if (const auto *E = D->getPlaceholderTypeConstraint())
552-
Visit(E);
551+
if (const auto *TC = D->getPlaceholderTypeConstraint())
552+
Visit(TC->getImmediatelyDeclaredConstraint());
553553
if (D->hasDefaultArgument())
554554
Visit(D->getDefaultArgument(), SourceRange(),
555555
D->getDefaultArgStorage().getInheritedFrom(),

clang/include/clang/AST/DeclTemplate.h

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,17 +1102,6 @@ class FunctionTemplateDecl : public RedeclarableTemplateDecl {
11021102
/// template.
11031103
ArrayRef<TemplateArgument> getInjectedTemplateArgs();
11041104

1105-
/// Return whether this function template is an abbreviated function template,
1106-
/// e.g. `void foo(auto x)` or `template<typename T> void foo(auto x)`
1107-
bool isAbbreviated() const {
1108-
// Since the invented template parameters generated from 'auto' parameters
1109-
// are either appended to the end of the explicit template parameter list or
1110-
// form a new template paramter list, we can simply observe the last
1111-
// parameter to determine if such a thing happened.
1112-
const TemplateParameterList *TPL = getTemplateParameters();
1113-
return TPL->getParam(TPL->size() - 1)->isImplicit();
1114-
}
1115-
11161105
/// Merge \p Prev with our RedeclarableTemplateDecl::Common.
11171106
void mergePrevDecl(FunctionTemplateDecl *Prev);
11181107

@@ -1226,6 +1215,7 @@ class TemplateTypeParmDecl final : public TypeDecl,
12261215
bool ParameterPack,
12271216
bool HasTypeConstraint = false,
12281217
Optional<unsigned> NumExpanded = None);
1218+
12291219
static TemplateTypeParmDecl *CreateDeserialized(const ASTContext &C,
12301220
unsigned ID);
12311221
static TemplateTypeParmDecl *CreateDeserialized(const ASTContext &C,
@@ -1384,8 +1374,7 @@ class NonTypeTemplateParmDecl final
13841374
: public DeclaratorDecl,
13851375
protected TemplateParmPosition,
13861376
private llvm::TrailingObjects<NonTypeTemplateParmDecl,
1387-
std::pair<QualType, TypeSourceInfo *>,
1388-
Expr *> {
1377+
std::pair<QualType, TypeSourceInfo *>> {
13891378
friend class ASTDeclReader;
13901379
friend TrailingObjects;
13911380

@@ -1440,12 +1429,10 @@ class NonTypeTemplateParmDecl final
14401429
ArrayRef<TypeSourceInfo *> ExpandedTInfos);
14411430

14421431
static NonTypeTemplateParmDecl *CreateDeserialized(ASTContext &C,
1443-
unsigned ID,
1444-
bool HasTypeConstraint);
1432+
unsigned ID);
14451433
static NonTypeTemplateParmDecl *CreateDeserialized(ASTContext &C,
14461434
unsigned ID,
1447-
unsigned NumExpandedTypes,
1448-
bool HasTypeConstraint);
1435+
unsigned NumExpandedTypes);
14491436

14501437
using TemplateParmPosition::getDepth;
14511438
using TemplateParmPosition::setDepth;
@@ -1556,22 +1543,20 @@ class NonTypeTemplateParmDecl final
15561543
return TypesAndInfos[I].second;
15571544
}
15581545

1559-
/// Return the constraint introduced by the placeholder type of this non-type
1546+
/// Return the type-constraint in the placeholder type of this non-type
15601547
/// template parameter (if any).
1561-
Expr *getPlaceholderTypeConstraint() const {
1562-
return hasPlaceholderTypeConstraint() ? *getTrailingObjects<Expr *>() :
1563-
nullptr;
1564-
}
1565-
1566-
void setPlaceholderTypeConstraint(Expr *E) {
1567-
*getTrailingObjects<Expr *>() = E;
1548+
TypeConstraint *getPlaceholderTypeConstraint() const {
1549+
// TODO: Concepts: Implement once we have actual placeholders with type
1550+
// constraints.
1551+
return nullptr;
15681552
}
15691553

15701554
/// Determine whether this non-type template parameter's type has a
15711555
/// placeholder with a type-constraint.
15721556
bool hasPlaceholderTypeConstraint() const {
1573-
auto *AT = getType()->getContainedAutoType();
1574-
return AT && AT->isConstrained();
1557+
// TODO: Concepts: Implement once we have actual placeholders with type
1558+
// constraints.
1559+
return false;
15751560
}
15761561

15771562
/// \brief Get the associated-constraints of this template parameter.
@@ -1581,8 +1566,8 @@ class NonTypeTemplateParmDecl final
15811566
/// Use this instead of getPlaceholderImmediatelyDeclaredConstraint for
15821567
/// concepts APIs that accept an ArrayRef of constraint expressions.
15831568
void getAssociatedConstraints(llvm::SmallVectorImpl<const Expr *> &AC) const {
1584-
if (Expr *E = getPlaceholderTypeConstraint())
1585-
AC.push_back(E);
1569+
if (TypeConstraint *TC = getPlaceholderTypeConstraint())
1570+
AC.push_back(TC->getImmediatelyDeclaredConstraint());
15861571
}
15871572

15881573
// Implement isa/cast/dyncast/etc.

clang/include/clang/AST/PropertiesBase.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ def DeclRef : RefPropertyType<"Decl"> { let ConstWhenWriting = 1; }
9999
SubclassPropertyType<"TagDecl", DeclRef>;
100100
def TemplateDeclRef :
101101
SubclassPropertyType<"TemplateDecl", DeclRef>;
102-
def ConceptDeclRef :
103-
SubclassPropertyType<"ConceptDecl", DeclRef>;
104102
def TemplateTypeParmDeclRef :
105103
SubclassPropertyType<"TemplateTypeParmDecl", DeclRef>;
106104
def TemplateTemplateParmDeclRef :

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,13 +1040,7 @@ DEF_TRAVERSE_TYPE(UnaryTransformType, {
10401040
TRY_TO(TraverseType(T->getUnderlyingType()));
10411041
})
10421042

1043-
DEF_TRAVERSE_TYPE(AutoType, {
1044-
TRY_TO(TraverseType(T->getDeducedType()));
1045-
if (T->isConstrained()) {
1046-
TRY_TO(TraverseDecl(T->getTypeConstraintConcept()));
1047-
TRY_TO(TraverseTemplateArguments(T->getArgs(), T->getNumArgs()));
1048-
}
1049-
})
1043+
DEF_TRAVERSE_TYPE(AutoType, { TRY_TO(TraverseType(T->getDeducedType())); })
10501044
DEF_TRAVERSE_TYPE(DeducedTemplateSpecializationType, {
10511045
TRY_TO(TraverseTemplateName(T->getTemplateName()));
10521046
TRY_TO(TraverseType(T->getDeducedType()));
@@ -1293,12 +1287,6 @@ DEF_TRAVERSE_TYPELOC(UnaryTransformType, {
12931287

12941288
DEF_TRAVERSE_TYPELOC(AutoType, {
12951289
TRY_TO(TraverseType(TL.getTypePtr()->getDeducedType()));
1296-
if (TL.isConstrained()) {
1297-
TRY_TO(TraverseNestedNameSpecifierLoc(TL.getNestedNameSpecifierLoc()));
1298-
TRY_TO(TraverseDeclarationNameInfo(TL.getConceptNameInfo()));
1299-
for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I)
1300-
TRY_TO(TraverseTemplateArgumentLoc(TL.getArgLoc(I)));
1301-
}
13021290
})
13031291

13041292
DEF_TRAVERSE_TYPELOC(DeducedTemplateSpecializationType, {

clang/include/clang/AST/TemplateBase.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ struct ASTTemplateArgumentListInfo final
637637
}
638638

639639
static const ASTTemplateArgumentListInfo *
640-
Create(const ASTContext &C, const TemplateArgumentListInfo &List);
640+
Create(ASTContext &C, const TemplateArgumentListInfo &List);
641641
};
642642

643643
/// Represents an explicit template argument list in C++, e.g.,
@@ -702,11 +702,6 @@ inline const TemplateArgument &
702702
return getArgs()[Idx];
703703
}
704704

705-
inline const TemplateArgument &AutoType::getArg(unsigned Idx) const {
706-
assert(Idx < getNumArgs() && "Template argument out of range");
707-
return getArgs()[Idx];
708-
}
709-
710705
} // namespace clang
711706

712707
#endif // LLVM_CLANG_AST_TEMPLATEBASE_H

clang/include/clang/AST/Type.h

Lines changed: 18 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ namespace clang {
5858

5959
class ExtQuals;
6060
class QualType;
61-
class ConceptDecl;
6261
class TagDecl;
6362
class Type;
6463

@@ -1684,15 +1683,6 @@ class alignas(8) Type : public ExtQualsTypeCommonBase {
16841683
/// Was this placeholder type spelled as 'auto', 'decltype(auto)',
16851684
/// or '__auto_type'? AutoTypeKeyword value.
16861685
unsigned Keyword : 2;
1687-
1688-
/// The number of template arguments in the type-constraints, which is
1689-
/// expected to be able to hold at least 1024 according to [implimits].
1690-
/// However as this limit is somewhat easy to hit with template
1691-
/// metaprogramming we'd prefer to keep it as large as possible.
1692-
/// At the moment it has been left as a non-bitfield since this type
1693-
/// safely fits in 64 bits as an unsigned, so there is no reason to
1694-
/// introduce the performance impact of a bitfield.
1695-
unsigned NumArgs;
16961686
};
16971687

16981688
class SubstTemplateTypeParmPackTypeBitfields {
@@ -4824,7 +4814,8 @@ class SubstTemplateTypeParmPackType : public Type, public llvm::FoldingSetNode {
48244814

48254815
/// Common base class for placeholders for types that get replaced by
48264816
/// placeholder type deduction: C++11 auto, C++14 decltype(auto), C++17 deduced
4827-
/// class template types, and constrained type names.
4817+
/// class template types, and (eventually) constrained type names from the C++
4818+
/// Concepts TS.
48284819
///
48294820
/// These types are usually a placeholder for a deduced type. However, before
48304821
/// the initializer is attached, or (usually) if the initializer is
@@ -4869,50 +4860,18 @@ class DeducedType : public Type {
48694860
}
48704861
};
48714862

4872-
/// Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained
4873-
/// by a type-constraint.
4874-
class alignas(8) AutoType : public DeducedType, public llvm::FoldingSetNode {
4863+
/// Represents a C++11 auto or C++14 decltype(auto) type.
4864+
class AutoType : public DeducedType, public llvm::FoldingSetNode {
48754865
friend class ASTContext; // ASTContext creates these
48764866

4877-
ConceptDecl *TypeConstraintConcept;
4878-
48794867
AutoType(QualType DeducedAsType, AutoTypeKeyword Keyword,
4880-
bool IsDeducedAsDependent, bool IsDeducedAsPack, ConceptDecl *CD,
4881-
ArrayRef<TemplateArgument> TypeConstraintArgs);
4882-
4883-
const TemplateArgument *getArgBuffer() const {
4884-
return reinterpret_cast<const TemplateArgument*>(this+1);
4885-
}
4886-
4887-
TemplateArgument *getArgBuffer() {
4888-
return reinterpret_cast<TemplateArgument*>(this+1);
4868+
bool IsDeducedAsDependent, bool IsDeducedAsPack)
4869+
: DeducedType(Auto, DeducedAsType, IsDeducedAsDependent,
4870+
IsDeducedAsDependent, IsDeducedAsPack) {
4871+
AutoTypeBits.Keyword = (unsigned)Keyword;
48894872
}
48904873

48914874
public:
4892-
/// Retrieve the template arguments.
4893-
const TemplateArgument *getArgs() const {
4894-
return getArgBuffer();
4895-
}
4896-
4897-
/// Retrieve the number of template arguments.
4898-
unsigned getNumArgs() const {
4899-
return AutoTypeBits.NumArgs;
4900-
}
4901-
4902-
const TemplateArgument &getArg(unsigned Idx) const; // in TemplateBase.h
4903-
4904-
ArrayRef<TemplateArgument> getTypeConstraintArguments() const {
4905-
return {getArgs(), getNumArgs()};
4906-
}
4907-
4908-
ConceptDecl *getTypeConstraintConcept() const {
4909-
return TypeConstraintConcept;
4910-
}
4911-
4912-
bool isConstrained() const {
4913-
return TypeConstraintConcept != nullptr;
4914-
}
4915-
49164875
bool isDecltypeAuto() const {
49174876
return getKeyword() == AutoTypeKeyword::DecltypeAuto;
49184877
}
@@ -4921,15 +4880,18 @@ class alignas(8) AutoType : public DeducedType, public llvm::FoldingSetNode {
49214880
return (AutoTypeKeyword)AutoTypeBits.Keyword;
49224881
}
49234882

4924-
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) {
4925-
Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(),
4926-
getTypeConstraintConcept(), getTypeConstraintArguments());
4883+
void Profile(llvm::FoldingSetNodeID &ID) {
4884+
Profile(ID, getDeducedType(), getKeyword(), isDependentType(),
4885+
containsUnexpandedParameterPack());
49274886
}
49284887

4929-
static void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
4930-
QualType Deduced, AutoTypeKeyword Keyword,
4931-
bool IsDependent, ConceptDecl *CD,
4932-
ArrayRef<TemplateArgument> Arguments);
4888+
static void Profile(llvm::FoldingSetNodeID &ID, QualType Deduced,
4889+
AutoTypeKeyword Keyword, bool IsDependent, bool IsPack) {
4890+
ID.AddPointer(Deduced.getAsOpaquePtr());
4891+
ID.AddInteger((unsigned)Keyword);
4892+
ID.AddBoolean(IsDependent);
4893+
ID.AddBoolean(IsPack);
4894+
}
49334895

49344896
static bool classof(const Type *T) {
49354897
return T->getTypeClass() == Auto;

0 commit comments

Comments
 (0)