Skip to content

Commit

Permalink
Unify access to template_arguments
Browse files Browse the repository at this point in the history
The other methods, such as directly calling begin() and end() as well
as getNumArgs() and getArgs() will go away in LLVM 16, see commit
llvm/llvm-project@1acffe81ee.
  • Loading branch information
hahnjo authored and jenkins committed Jul 11, 2023
1 parent dbb34a4 commit 8a633e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/Interpreter/ForwardDeclPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ namespace cling {
{
const TemplateSpecializationType* TST
= static_cast<const TemplateSpecializationType*>(typ);
for (const TemplateArgument& TA: *TST) {
for (const TemplateArgument& TA : TST->template_arguments()) {
VisitTemplateArgument(TA);
if (m_SkipFlag) {
skipDecl(nullptr, "template argument failed");
Expand Down
19 changes: 9 additions & 10 deletions lib/Utils/AST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,12 @@ namespace utils {

bool mightHaveChanged = false;
llvm::SmallVector<TemplateArgument, 4> desArgs;
for (TemplateSpecializationType::iterator
I = TST->begin(), E = TST->end();
I != E; ++I) {

for (const TemplateArgument& Arg : TST->template_arguments()) {
// cheap to copy and potentially modified by
// GetFullyQualifedTemplateArgument
TemplateArgument arg(*I);
mightHaveChanged |= GetFullyQualifiedTemplateArgument(Ctx,arg);
desArgs.push_back(arg);
TemplateArgument CopiedArg = Arg;
mightHaveChanged |= GetFullyQualifiedTemplateArgument(Ctx, CopiedArg);
desArgs.push_back(CopiedArg);
}

// If desugaring happened allocate new type in the AST.
Expand Down Expand Up @@ -1232,10 +1229,12 @@ namespace utils {

bool mightHaveChanged = false;
llvm::SmallVector<TemplateArgument, 4> desArgs;
llvm::ArrayRef<clang::TemplateArgument> template_arguments =
TST->template_arguments();
unsigned int argi = 0;
for(TemplateSpecializationType::iterator I = TST->begin(), E = TST->end();
I != E; ++I, ++argi) {

for (const clang::TemplateArgument *I = template_arguments.begin(),
*E = template_arguments.end();
I != E; ++I, ++argi) {
if (I->getKind() == TemplateArgument::Expression) {
// If we have an expression, we need to replace it / desugar it
// as it could contain unqualifed (or partially qualified or
Expand Down

0 comments on commit 8a633e6

Please sign in to comment.