-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang][NFC] Move concepts::createSubstDiagAt
from AST to Sema
#113294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This fixes layering violation introduced in 2fd01d7. The declaration is moved to `SemaTemplateInstantiate` section of `Sema.h`, after the file where it's implemented.
@llvm/pr-subscribers-clang Author: Vlad Serebrennikov (Endilll) ChangesThis fixes layering violation introduced in 2fd01d7. The declaration is moved to Full diff: https://github.com/llvm/llvm-project/pull/113294.diff 4 Files Affected:
diff --git a/clang/include/clang/AST/ExprConcepts.h b/clang/include/clang/AST/ExprConcepts.h
index 29913fd84c58b4..f3e32ce3961981 100644
--- a/clang/include/clang/AST/ExprConcepts.h
+++ b/clang/include/clang/AST/ExprConcepts.h
@@ -489,14 +489,6 @@ class NestedRequirement : public Requirement {
return R->getKind() == RK_Nested;
}
};
-
-using EntityPrinter = llvm::function_ref<void(llvm::raw_ostream &)>;
-
-/// \brief create a Requirement::SubstitutionDiagnostic with only a
-/// SubstitutedEntity and DiagLoc using Sema's allocator.
-Requirement::SubstitutionDiagnostic *
-createSubstDiagAt(Sema &S, SourceLocation Location, EntityPrinter Printer);
-
} // namespace concepts
/// C++2a [expr.prim.req]:
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index bc9c422ed4c477..18ba63ab5a7867 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -13435,6 +13435,13 @@ class Sema final : public SemaBase {
return CodeSynthesisContexts.size() > NonInstantiationEntries;
}
+ using EntityPrinter = llvm::function_ref<void(llvm::raw_ostream &)>;
+
+ /// \brief create a Requirement::SubstitutionDiagnostic with only a
+ /// SubstitutedEntity and DiagLoc using Sema's allocator.
+ concepts::Requirement::SubstitutionDiagnostic *
+ createSubstDiagAt(SourceLocation Location, EntityPrinter Printer);
+
///@}
//
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 40f24ea0ab2eaa..e19016ab23abe7 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -9444,11 +9444,11 @@ Sema::BuildExprRequirement(
ExprResult Constraint = SubstExpr(IDC, MLTAL);
if (Constraint.isInvalid()) {
return new (Context) concepts::ExprRequirement(
- concepts::createSubstDiagAt(*this, IDC->getExprLoc(),
- [&](llvm::raw_ostream &OS) {
- IDC->printPretty(OS, /*Helper=*/nullptr,
- getPrintingPolicy());
- }),
+ createSubstDiagAt(IDC->getExprLoc(),
+ [&](llvm::raw_ostream &OS) {
+ IDC->printPretty(OS, /*Helper=*/nullptr,
+ getPrintingPolicy());
+ }),
IsSimple, NoexceptLoc, ReturnTypeRequirement);
}
SubstitutedConstraintExpr =
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 457a9968c32a4a..198442dd9821ec 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2654,7 +2654,7 @@ QualType TemplateInstantiator::TransformSubstTemplateTypeParmPackType(
static concepts::Requirement::SubstitutionDiagnostic *
createSubstDiag(Sema &S, TemplateDeductionInfo &Info,
- concepts::EntityPrinter Printer) {
+ Sema::EntityPrinter Printer) {
SmallString<128> Message;
SourceLocation ErrorLoc;
if (Info.hasSFINAEDiagnostic()) {
@@ -2675,12 +2675,11 @@ createSubstDiag(Sema &S, TemplateDeductionInfo &Info,
}
concepts::Requirement::SubstitutionDiagnostic *
-concepts::createSubstDiagAt(Sema &S, SourceLocation Location,
- EntityPrinter Printer) {
+Sema::createSubstDiagAt(SourceLocation Location, EntityPrinter Printer) {
SmallString<128> Entity;
llvm::raw_svector_ostream OS(Entity);
Printer(OS);
- const ASTContext &C = S.Context;
+ const ASTContext &C = Context;
return new (C) concepts::Requirement::SubstitutionDiagnostic{
/*SubstitutedEntity=*/C.backupStr(Entity),
/*DiagLoc=*/Location, /*DiagMessage=*/StringRef()};
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This fixes layering violation introduced in 2fd01d7. The declaration is moved to
SemaTemplateInstantiate
section ofSema.h
, after the file where it's implemented.