Skip to content

Commit 8536c2e

Browse files
authored
[clang][NFC] Move concepts::createSubstDiagAt from AST to Sema (#113294)
This fixes layering violation introduced in 2fd01d7. The declaration is moved to `SemaTemplateInstantiate` section of `Sema.h`, after the file where it's implemented.
1 parent 9edb4f7 commit 8536c2e

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

clang/include/clang/AST/ExprConcepts.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -489,14 +489,6 @@ class NestedRequirement : public Requirement {
489489
return R->getKind() == RK_Nested;
490490
}
491491
};
492-
493-
using EntityPrinter = llvm::function_ref<void(llvm::raw_ostream &)>;
494-
495-
/// \brief create a Requirement::SubstitutionDiagnostic with only a
496-
/// SubstitutedEntity and DiagLoc using Sema's allocator.
497-
Requirement::SubstitutionDiagnostic *
498-
createSubstDiagAt(Sema &S, SourceLocation Location, EntityPrinter Printer);
499-
500492
} // namespace concepts
501493

502494
/// C++2a [expr.prim.req]:

clang/include/clang/Sema/Sema.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13435,6 +13435,13 @@ class Sema final : public SemaBase {
1343513435
return CodeSynthesisContexts.size() > NonInstantiationEntries;
1343613436
}
1343713437

13438+
using EntityPrinter = llvm::function_ref<void(llvm::raw_ostream &)>;
13439+
13440+
/// \brief create a Requirement::SubstitutionDiagnostic with only a
13441+
/// SubstitutedEntity and DiagLoc using ASTContext's allocator.
13442+
concepts::Requirement::SubstitutionDiagnostic *
13443+
createSubstDiagAt(SourceLocation Location, EntityPrinter Printer);
13444+
1343813445
///@}
1343913446

1344013447
//

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9444,11 +9444,11 @@ Sema::BuildExprRequirement(
94449444
ExprResult Constraint = SubstExpr(IDC, MLTAL);
94459445
if (Constraint.isInvalid()) {
94469446
return new (Context) concepts::ExprRequirement(
9447-
concepts::createSubstDiagAt(*this, IDC->getExprLoc(),
9448-
[&](llvm::raw_ostream &OS) {
9449-
IDC->printPretty(OS, /*Helper=*/nullptr,
9450-
getPrintingPolicy());
9451-
}),
9447+
createSubstDiagAt(IDC->getExprLoc(),
9448+
[&](llvm::raw_ostream &OS) {
9449+
IDC->printPretty(OS, /*Helper=*/nullptr,
9450+
getPrintingPolicy());
9451+
}),
94529452
IsSimple, NoexceptLoc, ReturnTypeRequirement);
94539453
}
94549454
SubstitutedConstraintExpr =

clang/lib/Sema/SemaTemplateInstantiate.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2654,7 +2654,7 @@ QualType TemplateInstantiator::TransformSubstTemplateTypeParmPackType(
26542654

26552655
static concepts::Requirement::SubstitutionDiagnostic *
26562656
createSubstDiag(Sema &S, TemplateDeductionInfo &Info,
2657-
concepts::EntityPrinter Printer) {
2657+
Sema::EntityPrinter Printer) {
26582658
SmallString<128> Message;
26592659
SourceLocation ErrorLoc;
26602660
if (Info.hasSFINAEDiagnostic()) {
@@ -2675,12 +2675,11 @@ createSubstDiag(Sema &S, TemplateDeductionInfo &Info,
26752675
}
26762676

26772677
concepts::Requirement::SubstitutionDiagnostic *
2678-
concepts::createSubstDiagAt(Sema &S, SourceLocation Location,
2679-
EntityPrinter Printer) {
2678+
Sema::createSubstDiagAt(SourceLocation Location, EntityPrinter Printer) {
26802679
SmallString<128> Entity;
26812680
llvm::raw_svector_ostream OS(Entity);
26822681
Printer(OS);
2683-
const ASTContext &C = S.Context;
2682+
const ASTContext &C = Context;
26842683
return new (C) concepts::Requirement::SubstitutionDiagnostic{
26852684
/*SubstitutedEntity=*/C.backupStr(Entity),
26862685
/*DiagLoc=*/Location, /*DiagMessage=*/StringRef()};

0 commit comments

Comments
 (0)