Skip to content

Commit a08930e

Browse files
committed
fix rebase
1 parent 71f557e commit a08930e

File tree

9 files changed

+51
-41
lines changed

9 files changed

+51
-41
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11673,7 +11673,7 @@ class Sema final : public SemaBase {
1167311673
ExprResult
1167411674
CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
1167511675
const DeclarationNameInfo &ConceptNameInfo,
11676-
NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
11676+
NamedDecl *FoundDecl, TemplateDecl *NamedConcept,
1167711677
const TemplateArgumentListInfo *TemplateArgs,
1167811678
bool DoCheckConstraintSatisfaction = true);
1167911679

clang/lib/AST/ASTImporter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ Error ASTNodeImporter::ImportConstraintSatisfaction(
10691069
ToSat.ContainsErrors = FromSat.ContainsErrors;
10701070
if (!ToSat.IsSatisfied) {
10711071
for (auto Record = FromSat.begin(); Record != FromSat.end(); ++Record) {
1072-
if (Expr *E = Record->dyn_cast<Expr *>()) {
1072+
if (const Expr *E = Record->dyn_cast<const Expr *>()) {
10731073
ExpectedExpr ToSecondExpr = import(E);
10741074
if (!ToSecondExpr)
10751075
return ToSecondExpr.takeError();

clang/lib/Sema/SemaConcept.cpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,16 @@ class AdjustConstraintDepth : public TreeTransform<AdjustConstraintDepth> {
245245
NewTL.setNameLoc(TL.getNameLoc());
246246
return Result;
247247
}
248+
249+
bool AlreadyTransformed(QualType T) {
250+
if (T.isNull())
251+
return true;
252+
253+
if (T->isInstantiationDependentType() || T->isVariablyModifiedType() ||
254+
T->containsUnexpandedParameterPack())
255+
return false;
256+
return true;
257+
}
248258
};
249259
} // namespace
250260

@@ -576,8 +586,8 @@ static ExprResult calculateConstraintSatisfaction(
576586
Satisfaction.IsSatisfied = false;
577587
Satisfaction.ContainsErrors = false;
578588
ExprResult Expr = calculateConstraintSatisfaction(
579-
S, FE.getNormalizedPattern(), Template, TemplateNameLoc,
580-
MLTAL, Satisfaction, UnsignedOrNone(I));
589+
S, FE.getNormalizedPattern(), Template, TemplateNameLoc, MLTAL,
590+
Satisfaction, UnsignedOrNone(I));
581591
if (Expr.isUsable()) {
582592
if (Out.isUnset())
583593
Out = Expr;
@@ -697,17 +707,17 @@ static ExprResult calculateConstraintSatisfaction(
697707
if (Satisfaction.IsSatisfied)
698708
return E;
699709

700-
CXXScopeSpec SS;
701-
SS.Adopt(Constraint.getConceptId()->getNestedNameSpecifierLoc());
710+
CXXScopeSpec SS;
711+
SS.Adopt(Constraint.getConceptId()->getNestedNameSpecifierLoc());
702712

703-
ExprResult SubstitutedConceptId = S.CheckConceptTemplateId(
704-
SS, Constraint.getConceptId()->getTemplateKWLoc(),
705-
Constraint.getConceptId()->getConceptNameInfo(),
706-
Constraint.getConceptId()->getFoundDecl(),
707-
Constraint.getConceptId()->getNamedConcept(), &OutArgs,
713+
ExprResult SubstitutedConceptId = S.CheckConceptTemplateId(
714+
SS, Constraint.getConceptId()->getTemplateKWLoc(),
715+
Constraint.getConceptId()->getConceptNameInfo(),
716+
Constraint.getConceptId()->getFoundDecl(),
717+
Constraint.getConceptId()->getNamedConcept(), &OutArgs,
708718
/*DoCheckConstraintSatisfaction=*/false);
709719

710-
if (SubstitutedConceptId.isInvalid() || Trap.hasErrorOccurred())
720+
if (SubstitutedConceptId.isInvalid() || Trap.hasErrorOccurred())
711721
return E;
712722

713723
if (Size != Satisfaction.Details.size()) {

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
//===----------------------------------------------------------------------===//
1010

1111
#include "TreeTransform.h"
12+
#include "clang/AST/ASTConcept.h"
1213
#include "clang/AST/ASTConsumer.h"
1314
#include "clang/AST/ASTContext.h"
1415
#include "clang/AST/Decl.h"
@@ -1181,10 +1182,9 @@ static ExprResult formImmediatelyDeclaredConstraint(
11811182
if (auto *CD = dyn_cast<ConceptDecl>(NamedConcept)) {
11821183
ImmediatelyDeclaredConstraint = S.CheckConceptTemplateId(
11831184
SS, /*TemplateKWLoc=*/SourceLocation(), NameInfo,
1184-
/*FoundDecl=*/FoundDecl ? FoundDecl : NamedConcept, NamedConcept,
1185-
&ConstraintArgs,
1186-
/*DoCheckConstraintSatisfaction=*/
1187-
!S.inParameterMappingSubstitution());
1185+
/*FoundDecl=*/FoundDecl ? FoundDecl : CD, CD, &ConstraintArgs,
1186+
/*DoCheckConstraintSatisfaction=*/
1187+
!S.inParameterMappingSubstitution());
11881188
}
11891189
// We have a template template parameter
11901190
else {
@@ -4802,7 +4802,7 @@ void Sema::diagnoseMissingTemplateArguments(const CXXScopeSpec &SS,
48024802
ExprResult Sema::CheckConceptTemplateId(
48034803
const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
48044804
const DeclarationNameInfo &ConceptNameInfo, NamedDecl *FoundDecl,
4805-
ConceptDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs,
4805+
TemplateDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs,
48064806
bool DoCheckConstraintSatisfaction) {
48074807
assert(NamedConcept && "A concept template id without a template?");
48084808

@@ -4842,18 +4842,19 @@ ExprResult Sema::CheckConceptTemplateId(
48424842
ASTTemplateArgumentListInfo::Create(Context, *TemplateArgs));
48434843

48444844
bool Error = false;
4845-
if (!AreArgsDependent && DoCheckConstraintSatisfaction) {
4845+
if (const auto *Concept = dyn_cast<ConceptDecl>(NamedConcept);
4846+
Concept && Concept->getConstraintExpr() && !AreArgsDependent &&
4847+
DoCheckConstraintSatisfaction) {
48464848

4847-
LocalInstantiationScope Scope(*this);
4849+
LocalInstantiationScope Scope(*this);
48484850

4849-
EnterExpressionEvaluationContext EECtx{
4850-
*this, ExpressionEvaluationContext::Unevaluated, CSD};
4851+
EnterExpressionEvaluationContext EECtx{
4852+
*this, ExpressionEvaluationContext::Unevaluated, CSD};
48514853

48524854
Error = CheckConstraintSatisfaction(
4853-
NamedConcept, AssociatedConstraint(NamedConcept->getConstraintExpr()),
4854-
MLTAL,
4855-
SourceRange(SS.isSet() ? SS.getBeginLoc() : ConceptNameInfo.getLoc(),
4856-
TemplateArgs->getRAngleLoc()),
4855+
NamedConcept, AssociatedConstraint(Concept->getConstraintExpr()), MLTAL,
4856+
SourceRange(SS.isSet() ? SS.getBeginLoc() : ConceptNameInfo.getLoc(),
4857+
TemplateArgs->getRAngleLoc()),
48574858
Satisfaction, CL);
48584859
Satisfaction.ContainsErrors = Error;
48594860
}

clang/test/AST/ast-dump-ctad-alias.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,13 @@ void foo() {
190190
// CHECK-NEXT: | | | | | `-TemplateTypeParm {{.*}} 'U'
191191
// CHECK-NEXT: | | | | `-TemplateArgument pack '<Packs<Ts...>>'
192192
// CHECK-NEXT: | | | | `-TemplateArgument type 'Packs<Ts...>'
193-
// CHECK-NEXT: | | | | `-ElaboratedType {{.*}} 'Packs<Ts...>' sugar dependent
194-
// CHECK-NEXT: | | | | `-TemplateSpecializationType {{.*}} 'Packs<Ts...>' dependent
195-
// CHECK-NEXT: | | | | |-name: 'Packs':'GH124715::Packs' qualified
193+
// CHECK-NEXT: | | | | `-TemplateSpecializationType {{.*}} 'Packs<Ts...>' dependent
194+
// CHECK-NEXT: | | | | |-name: 'Packs':'GH124715::Packs' qualified
196195
// CHECK-NEXT: | | | | | `-ClassTemplateDecl {{.*}} Packs
197-
// CHECK-NEXT: | | | | `-TemplateArgument type 'Ts...'
198-
// CHECK-NEXT: | | | | `-PackExpansionType {{.*}} 'Ts...' dependent
199-
// CHECK-NEXT: | | | | `-TemplateTypeParmType {{.*}} 'Ts' dependent contains_unexpanded_pack depth 0 index 1 pack
200-
// CHECK-NEXT: | | | | `-TemplateTypeParm {{.*}} 'Ts'
196+
// CHECK-NEXT: | | | | `-TemplateArgument type 'Ts...'
197+
// CHECK-NEXT: | | | | `-PackExpansionType {{.*}} 'Ts...' dependent
198+
// CHECK-NEXT: | | | | `-TemplateTypeParmType {{.*}} 'Ts' dependent contains_unexpanded_pack depth 0 index 1 pack
199+
// CHECK-NEXT: | | | | `-TemplateTypeParm {{.*}} 'Ts'
201200
// CHECK-NEXT: | | | |-TemplateArgument {{.*}} type 'U':'type-parameter-0-2'
202201
// CHECK-NEXT: | | | | `-TemplateTypeParmType {{.*}} 'U' dependent depth 0 index 2
203202
// CHECK-NEXT: | | | | `-TemplateTypeParm {{.*}} 'U'

clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ namespace std_example {
149149
template<typename T> constexpr bool is_same_v<T, T> = true;
150150

151151
template<typename T, typename U> concept same_as = is_same_v<T, U>;
152-
// expected-note@-1 {{because 'is_same_v<int, typename T2::inner>' evaluated to false}}
152+
// expected-note@-1 {{because 'is_same_v<int, typename std_example::T2::inner>' evaluated to false}}
153153

154154
static_assert(C1<int>);
155155
static_assert(C1<int*>);
@@ -160,7 +160,7 @@ namespace std_example {
160160
template<typename T> concept C2 =
161161
requires(T x) {
162162
{*x} -> same_as<typename T::inner>;
163-
// expected-note@-1{{because 'same_as<int, typename T2::inner>' evaluated to false}}
163+
// expected-note@-1{{because 'same_as<int, typename std_example::T2::inner>' evaluated to false}}
164164
// expected-note@-2{{because '*x' would be invalid: indirection requires pointer operand ('int' invalid)}}
165165
};
166166

clang/test/SemaCXX/cxx2b-deducing-this.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,13 +1257,13 @@ void f() {
12571257
(&A::e)(a, a);
12581258
// expected-error@-1 {{no matching function for call to 'e'}} \
12591259
// expected-note@#tpl-address-e{{candidate template ignored: constraints not satisfied [with T = A, U = A]}} \
1260-
// expected-note@#tpl-address-e{{because '__is_same(tpl_address::A, int)' evaluated to false}}
1260+
// expected-note@#tpl-address-e{{because '__is_same(A, int)' evaluated to false}}
12611261

12621262
(&A::e<A>)(a, 0);
12631263
(&A::e<A>)(a, a);
12641264
// expected-error@-1 {{no matching function for call to 'e'}} \
12651265
// expected-note@#tpl-address-e{{candidate template ignored: constraints not satisfied [with T = A, U = A]}} \
1266-
// expected-note@#tpl-address-e{{because '__is_same(tpl_address::A, int)' evaluated to false}}
1266+
// expected-note@#tpl-address-e{{because '__is_same(A, int)' evaluated to false}}
12671267

12681268
(&A::e<A, int>)(a, 0);
12691269

@@ -1273,12 +1273,12 @@ void f() {
12731273
(&A::f<A>)(a);
12741274
// expected-error@-1 {{no matching function for call to 'f'}} \
12751275
// expected-note@#tpl-address-f{{candidate template ignored: constraints not satisfied [with T = A]}} \
1276-
// expected-note@#tpl-address-f{{because '__is_same(tpl_address::A, int)' evaluated to false}}
1276+
// expected-note@#tpl-address-f{{because '__is_same(A, int)' evaluated to false}}
12771277

12781278
(&A::f)(a);
12791279
// expected-error@-1 {{no matching function for call to 'f'}} \
12801280
// expected-note@#tpl-address-f{{candidate template ignored: constraints not satisfied [with T = A]}} \
1281-
// expected-note@#tpl-address-f{{because '__is_same(tpl_address::A, int)' evaluated to false}}
1281+
// expected-note@#tpl-address-f{{because '__is_same(A, int)' evaluated to false}}
12821282

12831283
(&A::g)(a);
12841284
(&A::g)(a, 0);

clang/test/SemaCXX/cxx2c-template-template-param.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ concept BinaryDefaultedFalse = false;
106106

107107
template <template <typename...> concept C, typename T>
108108
struct S {
109-
template <C TT> // expected-note {{because 'int' does not satisfy 'UnaryFalse'}}
109+
template <C TT> // expected-note 2{{because 'int' does not satisfy 'UnaryFalse'}}
110110
void f(TT); // expected-note {{ignored}}
111111
void g(C auto); // expected-note {{ignored}} \
112112
// expected-note {{because 'int' does not satisfy 'UnaryFalse'}}
@@ -171,7 +171,7 @@ concept BinaryDefaultedFalse = false;
171171

172172
template <template <typename...> concept C, typename T>
173173
struct S {
174-
template <C TT> // expected-note {{because 'int' does not satisfy 'UnaryFalse'}}
174+
template <C TT> // expected-note 2{{because 'int' does not satisfy 'UnaryFalse'}}
175175
void f(TT); // expected-note {{ignored}}
176176
void g(C auto); // expected-note {{ignored}} \
177177
// expected-note {{because 'int' does not satisfy 'UnaryFalse'}}

clang/test/SemaCXX/overload-resolution-deferred-templates.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static_assert(__is_constructible(Movable, int));
102102
// expected-error@-1 {{no matching constructor for initialization of 'Movable'}} \
103103
// expected-note@-1 2{{}}
104104
// expected-error@#err-self-constraint-1{{satisfaction of constraint '__is_constructible(Movable, T)' depends on itself}}
105-
// expected-note@#err-self-constraint-1 4{{}}
105+
// expected-note@#err-self-constraint-1 3{{}}
106106
// expected-note@#Movable {{'Movable' defined here}}
107107

108108
template <typename T>

0 commit comments

Comments
 (0)