diff options
author | Adrian Prantl <aprantl@apple.com> | 2024-05-07 13:02:17 -0700 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2024-05-07 13:03:14 -0700 |
commit | c6855ab24e63feb432aac4f86eb70ac16d76c921 (patch) | |
tree | d9c3f525aac1bb609dffce6f664b3a56ae9822fa /clang/tools | |
parent | 2e4abfae57f81e2bb23fc654d6edbaeae51ae10a (diff) | |
download | llvm-c6855ab24e63feb432aac4f86eb70ac16d76c921.zip llvm-c6855ab24e63feb432aac4f86eb70ac16d76c921.tar.gz llvm-c6855ab24e63feb432aac4f86eb70ac16d76c921.tar.bz2 |
Revert "[Clang] Unify interface for accessing template arguments as written for class/variable template specializations (#81642)"
This reverts commit 7115ed0fff027b65fa76fdfae215ed1382ed1473.
This commit broke several LLDB tests.
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/3480/
Diffstat (limited to 'clang/tools')
-rw-r--r-- | clang/tools/libclang/CIndex.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index 60241af..b845a38 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -743,10 +743,14 @@ bool CursorVisitor::VisitClassTemplateSpecializationDecl( } // Visit the template arguments used in the specialization. - if (const auto *ArgsWritten = D->getTemplateArgsAsWritten()) { - for (const TemplateArgumentLoc &Arg : ArgsWritten->arguments()) - if (VisitTemplateArgumentLoc(Arg)) - return true; + if (TypeSourceInfo *SpecType = D->getTypeAsWritten()) { + TypeLoc TL = SpecType->getTypeLoc(); + if (TemplateSpecializationTypeLoc TSTLoc = + TL.getAs<TemplateSpecializationTypeLoc>()) { + for (unsigned I = 0, N = TSTLoc.getNumArgs(); I != N; ++I) + if (VisitTemplateArgumentLoc(TSTLoc.getArgLoc(I))) + return true; + } } return ShouldVisitBody && VisitCXXRecordDecl(D); @@ -5655,19 +5659,16 @@ CXString clang_getCursorDisplayName(CXCursor C) { if (const ClassTemplateSpecializationDecl *ClassSpec = dyn_cast<ClassTemplateSpecializationDecl>(D)) { + // If the type was explicitly written, use that. + if (TypeSourceInfo *TSInfo = ClassSpec->getTypeAsWritten()) + return cxstring::createDup(TSInfo->getType().getAsString(Policy)); + SmallString<128> Str; llvm::raw_svector_ostream OS(Str); OS << *ClassSpec; - // If the template arguments were written explicitly, use them.. - if (const auto *ArgsWritten = ClassSpec->getTemplateArgsAsWritten()) { - printTemplateArgumentList( - OS, ArgsWritten->arguments(), Policy, - ClassSpec->getSpecializedTemplate()->getTemplateParameters()); - } else { - printTemplateArgumentList( - OS, ClassSpec->getTemplateArgs().asArray(), Policy, - ClassSpec->getSpecializedTemplate()->getTemplateParameters()); - } + printTemplateArgumentList( + OS, ClassSpec->getTemplateArgs().asArray(), Policy, + ClassSpec->getSpecializedTemplate()->getTemplateParameters()); return cxstring::createDup(OS.str()); } |