Skip to content

Commit 4ca083d

Browse files
committed
cleanups
1 parent 1fdb0e0 commit 4ca083d

File tree

7 files changed

+19
-62
lines changed

7 files changed

+19
-62
lines changed

clang/include/clang/Sema/SemaConcept.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,23 @@ struct NormalizedConstraint {
6363
using ExprOrConcept =
6464
llvm::PointerUnion<const Expr *, const ConceptReference *>;
6565

66-
struct AtomicBits {
66+
struct AtomicConstraintBits {
6767
LLVM_PREFERRED_TYPE(ConstraintKind)
68+
// Kind is the first member of all union members,
69+
// as we rely on their initial common sequence.
6870
unsigned Kind : 5;
6971
unsigned Placeholder : 1;
7072
unsigned PackSubstitutionIndex : 26;
73+
// Indexes and Args are part of the common initial sequences
74+
// of constraints that do have a mapping.
7175
OccurenceList Indexes;
7276
TemplateArgumentLoc *Args;
7377
TemplateParameterList *ParamList;
7478
ExprOrConcept ConstraintExpr;
7579
const NamedDecl *ConstraintDecl;
7680
};
7781

78-
struct FoldExpandedBits {
82+
struct FoldExpandedConstraintBits {
7983
LLVM_PREFERRED_TYPE(ConstraintKind)
8084
unsigned Kind : 5;
8185
LLVM_PREFERRED_TYPE(FoldOperatorKind)
@@ -89,14 +93,14 @@ struct NormalizedConstraint {
8993
NormalizedConstraint *Constraint;
9094
};
9195

92-
struct ConceptIdBits : AtomicBits {
96+
struct ConceptIdBits : AtomicConstraintBits {
9397
NormalizedConstraint *Sub;
9498

9599
// Only used for parameter mapping.
96100
const ConceptSpecializationExpr *CSE;
97101
};
98102

99-
struct CompoundBits {
103+
struct CompoundConstraintBits {
100104
LLVM_PREFERRED_TYPE(ConstraintKind)
101105
unsigned Kind : 5;
102106
LLVM_PREFERRED_TYPE(CompoundConstraintKind)
@@ -106,10 +110,10 @@ struct NormalizedConstraint {
106110
};
107111

108112
union {
109-
AtomicBits Atomic;
110-
FoldExpandedBits FoldExpanded;
113+
AtomicConstraintBits Atomic;
114+
FoldExpandedConstraintBits FoldExpanded;
111115
ConceptIdBits ConceptId;
112-
CompoundBits Compound;
116+
CompoundConstraintBits Compound;
113117
};
114118

115119
~NormalizedConstraint() {
@@ -161,6 +165,8 @@ struct NormalizedConstraint {
161165
llvm::to_underlying(CCK), LHS, RHS} {}
162166

163167
bool hasParameterMapping() const {
168+
// compound constraints do not have a mapping
169+
// and Args is not part of their common initial sequence.
164170
return getKind() != ConstraintKind::Compound && Atomic.Args != nullptr;
165171
}
166172

@@ -388,9 +394,6 @@ class ConceptIdConstraint : public NormalizedConstraintWithParamMapping {
388394
};
389395

390396
struct CachedConceptIdConstraint {
391-
#ifndef NDEBUG
392-
const Expr *E;
393-
#endif
394397
ExprResult SubstExpr;
395398
ConstraintSatisfaction Satisfaction;
396399
};

clang/include/clang/Sema/Template.h

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -240,28 +240,16 @@ enum class TemplateSubstitutionKind : char {
240240
"Replacing in an empty list?");
241241

242242
if (!TemplateArgumentLists.empty()) {
243-
// assert((!TemplateArgumentLists[0].AssociatedDeclAndFinal.getPointer()
244-
// ||
245-
// TemplateArgumentLists[0].AssociatedDeclAndFinal.getPointer()
246-
// ==
247-
// AssociatedDecl) &&
248-
// "Trying to change incorrect declaration?");
249243
TemplateArgumentLists[0].Args = Args;
250-
} else {
251-
--NumRetainedOuterLevels;
252-
TemplateArgumentLists.push_back(
253-
{{AssociatedDecl, /*Final=*/Final}, Args});
244+
return;
254245
}
246+
--NumRetainedOuterLevels;
247+
TemplateArgumentLists.push_back(
248+
{{AssociatedDecl, /*Final=*/Final}, Args});
255249
}
256250

257251
void replaceOutermostTemplateArguments(Decl *AssociatedDecl, ArgList Args) {
258252
assert((!TemplateArgumentLists.empty()) && "Replacing in an empty list?");
259-
// assert((!TemplateArgumentLists.back().AssociatedDeclAndFinal.getPointer()
260-
// ||
261-
// TemplateArgumentLists.back().AssociatedDeclAndFinal.getPointer()
262-
// ==
263-
// AssociatedDecl) &&
264-
// "Trying to change incorrect declaration?");
265253
TemplateArgumentLists.back().AssociatedDeclAndFinal.setPointer(
266254
AssociatedDecl);
267255
TemplateArgumentLists.back().Args = Args;

clang/lib/AST/ASTContext.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5793,7 +5793,6 @@ QualType ASTContext::getSubstTemplateTypeParmType(QualType Replacement,
57935793
llvm::FoldingSetNodeID ID;
57945794
SubstTemplateTypeParmType::Profile(ID, Replacement, AssociatedDecl, Index,
57955795
PackIndex, Final);
5796-
57975796
void *InsertPos = nullptr;
57985797
SubstTemplateTypeParmType *SubstParm =
57995798
SubstTemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);

clang/lib/Sema/SemaConcept.cpp

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "clang/AST/Decl.h"
1818
#include "clang/AST/DeclCXX.h"
1919
#include "clang/AST/DeclTemplate.h"
20-
#include "clang/AST/DependenceFlags.h"
2120
#include "clang/AST/Expr.h"
2221
#include "clang/AST/ExprConcepts.h"
2322
#include "clang/AST/RecursiveASTVisitor.h"
@@ -32,20 +31,10 @@
3231
#include "clang/Sema/SemaInternal.h"
3332
#include "clang/Sema/Template.h"
3433
#include "clang/Sema/TemplateDeduction.h"
35-
#include "llvm/ADT/ArrayRef.h"
3634
#include "llvm/ADT/DenseMap.h"
3735
#include "llvm/ADT/PointerUnion.h"
38-
#include "llvm/ADT/STLExtras.h"
39-
#include "llvm/ADT/ScopeExit.h"
40-
#include "llvm/ADT/SmallVector.h"
4136
#include "llvm/ADT/StringExtras.h"
42-
#include "llvm/Support/Casting.h"
4337
#include "llvm/Support/SaveAndRestore.h"
44-
#include "llvm/Support/raw_ostream.h"
45-
#include <chrono>
46-
#include <cstddef>
47-
#include <iterator>
48-
#include <optional>
4938

5039
using namespace clang;
5140
using namespace sema;
@@ -691,9 +680,7 @@ ExprResult CalculateConstraintSatisfaction::Calculate(
691680
Constraint.getPackSubstitutionIndex()
692681
? Constraint.getPackSubstitutionIndex()
693682
: PackSubstitutionIndex;
694-
// Constraint.getConstraintExpr()->Profile(ID, S.Context, /*Canonical=*/true,
695-
// /*ProfileLambdaExpr=*/true);
696-
auto *Previous = Constraint.getConstraintExpr();
683+
697684
ID.AddPointer(Constraint.getConstraintExpr());
698685
ID.AddInteger(OuterPackSubstIndex.toInternalRepresentation());
699686
ID.AddBoolean(Constraint.hasParameterMapping());
@@ -713,15 +700,12 @@ ExprResult CalculateConstraintSatisfaction::Calculate(
713700

714701
ExprResult E = CalculateSlow(Constraint, MLTAL);
715702

716-
assert(Constraint.getConstraintExpr() == Previous);
717-
718703
CachedConceptIdConstraint Cache;
719704
Cache.Satisfaction.ContainsErrors = Satisfaction.ContainsErrors;
720705
Cache.Satisfaction.IsSatisfied = Satisfaction.IsSatisfied;
721706
std::copy(Satisfaction.Details.begin() + Size, Satisfaction.Details.end(),
722707
std::back_inserter(Cache.Satisfaction.Details));
723708
Cache.SubstExpr = E;
724-
Cache.E = Constraint.getConstraintExpr();
725709
S.ConceptIdSatisfactionCache.insert({ID, std::move(Cache)});
726710

727711
return E;
@@ -2153,8 +2137,6 @@ NormalizedConstraint *NormalizedConstraint::fromConstraintExpr(
21532137
if (!SubNF)
21542138
return nullptr;
21552139
}
2156-
// if (substituteParameterMappings(S, *SubNF, CSE))
2157-
// return nullptr;
21582140

21592141
return ConceptIdConstraint::Create(S.getASTContext(),
21602142
CSE->getConceptReference(), SubNF, D,

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6069,19 +6069,6 @@ bool Sema::CheckTemplateArgumentList(
60696069
return true;
60706070
}
60716071

6072-
// For constraint parameter mapping, we have already built a pack in
6073-
// TransformTemplateArguments
6074-
// if (inParameterMappingSubstitution()) {
6075-
// llvm::copy(SugaredArgumentPack,
6076-
// std::back_inserter(CTAI.SugaredConverted));
6077-
// SugaredArgumentPack.clear();
6078-
// llvm::copy(CanonicalArgumentPack,
6079-
// std::back_inserter(CTAI.CanonicalConverted));
6080-
// CanonicalArgumentPack.clear();
6081-
// ++Param;
6082-
// continue;
6083-
// }
6084-
60856072
CTAI.SugaredConverted.push_back(
60866073
TemplateArgument::CreatePackCopy(Context, SugaredArgumentPack));
60876074
SugaredArgumentPack.clear();

clang/lib/Sema/TreeTransform.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,6 @@ class TreeTransform {
356356
/// being expanded.
357357
void ExpandingFunctionParameterPack(ParmVarDecl *Pack) { }
358358

359-
bool ShouldPreserveTemplateArgumentsPacks() const { return false; }
360-
361359
/// Transforms the given type into another type.
362360
///
363361
/// By default, this routine transforms a type by creating a

clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %clang_cc1 -std=c++2a -x c++ -verify %s
2-
// FIXME: RUN: %clang_cc1 -std=c++2c -x c++ -verify %s
2+
// RUN: %clang_cc1 -std=c++2c -x c++ -verify %s
33

44
template<typename T> concept True = true;
55
template<typename T> concept Foo = True<T*>; // #Foo

0 commit comments

Comments
 (0)