Skip to content

Commit 18c70b0

Browse files
authored
[clang] Refactor: Move CTAD code from SemaTemplate.cpp to a dedicated file, NFC (#98524)
Split out the deduction guide related code from SemaTemplate.cpp to a dedicated file. These code has grown significantly, and moving it to a separate file will improve code organization.
1 parent a5a29a2 commit 18c70b0

File tree

4 files changed

+1472
-1395
lines changed

4 files changed

+1472
-1395
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -560,13 +560,14 @@ class Sema final : public SemaBase {
560560
// 23. Statement Attribute Handling (SemaStmtAttr.cpp)
561561
// 24. C++ Templates (SemaTemplate.cpp)
562562
// 25. C++ Template Argument Deduction (SemaTemplateDeduction.cpp)
563-
// 26. C++ Template Instantiation (SemaTemplateInstantiate.cpp)
564-
// 27. C++ Template Declaration Instantiation
563+
// 26. C++ Template Deduction Guide (SemaTemplateDeductionGuide.cpp)
564+
// 27. C++ Template Instantiation (SemaTemplateInstantiate.cpp)
565+
// 28. C++ Template Declaration Instantiation
565566
// (SemaTemplateInstantiateDecl.cpp)
566-
// 28. C++ Variadic Templates (SemaTemplateVariadic.cpp)
567-
// 29. Constraints and Concepts (SemaConcept.cpp)
568-
// 30. Types (SemaType.cpp)
569-
// 31. FixIt Helpers (SemaFixItUtils.cpp)
567+
// 29. C++ Variadic Templates (SemaTemplateVariadic.cpp)
568+
// 30. Constraints and Concepts (SemaConcept.cpp)
569+
// 31. Types (SemaType.cpp)
570+
// 32. FixIt Helpers (SemaFixItUtils.cpp)
570571

571572
/// \name Semantic Analysis
572573
/// Implementations are in Sema.cpp
@@ -11347,6 +11348,10 @@ class Sema final : public SemaBase {
1134711348
bool &IsMemberSpecialization, bool &Invalid,
1134811349
bool SuppressDiagnostic = false);
1134911350

11351+
/// Returns the template parameter list with all default template argument
11352+
/// information.
11353+
TemplateParameterList *GetTemplateParameterList(TemplateDecl *TD);
11354+
1135011355
DeclResult CheckClassTemplate(
1135111356
Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
1135211357
CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc,
@@ -12009,15 +12014,6 @@ class Sema final : public SemaBase {
1200912014
unsigned TemplateDepth,
1201012015
const Expr *Constraint);
1201112016

12012-
/// Declare implicit deduction guides for a class template if we've
12013-
/// not already done so.
12014-
void DeclareImplicitDeductionGuides(TemplateDecl *Template,
12015-
SourceLocation Loc);
12016-
12017-
FunctionTemplateDecl *DeclareAggregateDeductionGuideFromInitList(
12018-
TemplateDecl *Template, MutableArrayRef<QualType> ParamTypes,
12019-
SourceLocation Loc);
12020-
1202112017
/// Find the failed Boolean condition within a given Boolean
1202212018
/// constant expression, and describe it with a string.
1202312019
std::pair<Expr *, std::string> findFailedBooleanCondition(Expr *Cond);
@@ -12570,6 +12566,27 @@ class Sema final : public SemaBase {
1257012566
//
1257112567
//
1257212568

12569+
/// \name C++ Template Deduction Guide
12570+
/// Implementations are in SemaTemplateDeductionGuide.cpp
12571+
///@{
12572+
12573+
/// Declare implicit deduction guides for a class template if we've
12574+
/// not already done so.
12575+
void DeclareImplicitDeductionGuides(TemplateDecl *Template,
12576+
SourceLocation Loc);
12577+
12578+
FunctionTemplateDecl *DeclareAggregateDeductionGuideFromInitList(
12579+
TemplateDecl *Template, MutableArrayRef<QualType> ParamTypes,
12580+
SourceLocation Loc);
12581+
12582+
///@}
12583+
12584+
//
12585+
//
12586+
// -------------------------------------------------------------------------
12587+
//
12588+
//
12589+
1257312590
/// \name C++ Template Instantiation
1257412591
/// Implementations are in SemaTemplateInstantiate.cpp
1257512592
///@{

clang/lib/Sema/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ add_clang_library(clangSema
8282
SemaSystemZ.cpp
8383
SemaTemplate.cpp
8484
SemaTemplateDeduction.cpp
85+
SemaTemplateDeductionGuide.cpp
8586
SemaTemplateInstantiate.cpp
8687
SemaTemplateInstantiateDecl.cpp
8788
SemaTemplateVariadic.cpp

0 commit comments

Comments
 (0)