Skip to content

Commit 7bc252a

Browse files
committed
Decouple from the new version of getTemplateInstantiationArgs()
1 parent 7e7ed8e commit 7bc252a

File tree

3 files changed

+40
-9
lines changed

3 files changed

+40
-9
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13033,6 +13033,7 @@ class Sema final : public SemaBase {
1303313033
///
1303413034
/// \param SkipForSpecialization when specified, any template specializations
1303513035
/// in a traversal would be ignored.
13036+
///
1303613037
/// \param ForDefaultArgumentSubstitution indicates we should continue looking
1303713038
/// when encountering a specialized member function template, rather than
1303813039
/// returning immediately.
@@ -13044,6 +13045,17 @@ class Sema final : public SemaBase {
1304413045
bool SkipForSpecialization = false,
1304513046
bool ForDefaultArgumentSubstitution = false);
1304613047

13048+
/// Apart from storing the result to \p Result, this behaves the same as
13049+
/// another overload.
13050+
void getTemplateInstantiationArgs(
13051+
MultiLevelTemplateArgumentList &Result, const NamedDecl *D,
13052+
const DeclContext *DC = nullptr, bool Final = false,
13053+
std::optional<ArrayRef<TemplateArgument>> Innermost = std::nullopt,
13054+
bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr,
13055+
bool ForConstraintInstantiation = false,
13056+
bool SkipForSpecialization = false,
13057+
bool ForDefaultArgumentSubstitution = false);
13058+
1304713059
/// RAII object to handle the state changes required to synthesize
1304813060
/// a function body.
1304913061
class SynthesizedFunctionScope {

clang/lib/Sema/SemaConcept.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,12 +1128,18 @@ static bool CheckFunctionConstraintsWithoutInstantiation(
11281128
// Collect the list of template arguments relative to the 'primary'
11291129
// template. We need the entire list, since the constraint is completely
11301130
// uninstantiated at this point.
1131-
MultiLevelTemplateArgumentList MLTAL =
1132-
SemaRef.getTemplateInstantiationArgs(FD, /*DC=*/nullptr,
1133-
/*Final=*/false,
1134-
/*Innermost=*/TemplateArgs,
1135-
/*RelativeToPrimary=*/true,
1136-
/*ForConstraintInstantiation=*/true);
1131+
1132+
// FIXME: Add TemplateArgs through the 'Innermost' parameter once
1133+
// the refactoring of getTemplateInstantiationArgs() relands.
1134+
MultiLevelTemplateArgumentList MLTAL;
1135+
MLTAL.addOuterTemplateArguments(Template, /*Args=*/TemplateArgs,
1136+
/*Final=*/false);
1137+
SemaRef.getTemplateInstantiationArgs(
1138+
MLTAL, /*D=*/nullptr,
1139+
FD->getFriendObjectKind() ? FD->getLexicalDeclContext()
1140+
: FD->getDeclContext(),
1141+
/*Final=*/false, /*Innermost=*/std::nullopt, /*RelativeToPrimary=*/true,
1142+
/*Pattern=*/nullptr, /*ForConstraintInstantiation=*/true);
11371143

11381144
Sema::ContextRAII SavedContext(SemaRef, FD);
11391145
std::optional<Sema::CXXThisScopeRAII> ThisScope;

clang/lib/Sema/SemaTemplateInstantiate.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,21 @@ MultiLevelTemplateArgumentList Sema::getTemplateInstantiationArgs(
475475
assert((ND || DC) && "Can't find arguments for a decl if one isn't provided");
476476
// Accumulate the set of template argument lists in this structure.
477477
MultiLevelTemplateArgumentList Result;
478+
getTemplateInstantiationArgs(
479+
Result, ND, DC, Final, Innermost, RelativeToPrimary, Pattern,
480+
ForConstraintInstantiation, SkipForSpecialization,
481+
ForDefaultArgumentSubstitution);
482+
return Result;
483+
}
484+
485+
void Sema::getTemplateInstantiationArgs(
486+
MultiLevelTemplateArgumentList &Result, const NamedDecl *ND,
487+
const DeclContext *DC, bool Final,
488+
std::optional<ArrayRef<TemplateArgument>> Innermost, bool RelativeToPrimary,
489+
const FunctionDecl *Pattern, bool ForConstraintInstantiation,
490+
bool SkipForSpecialization, bool ForDefaultArgumentSubstitution) {
491+
assert((ND || DC) && "Can't find arguments for a decl if one isn't provided");
492+
// Accumulate the set of template argument lists in this structure.
478493

479494
using namespace TemplateInstArgsHelpers;
480495
const Decl *CurDecl = ND;
@@ -535,14 +550,12 @@ MultiLevelTemplateArgumentList Sema::getTemplateInstantiationArgs(
535550
}
536551

537552
if (R.IsDone)
538-
return Result;
553+
return;
539554
if (R.ClearRelativeToPrimary)
540555
RelativeToPrimary = false;
541556
assert(R.NextDecl);
542557
CurDecl = R.NextDecl;
543558
}
544-
545-
return Result;
546559
}
547560

548561
bool Sema::CodeSynthesisContext::isInstantiationRecord() const {

0 commit comments

Comments
 (0)