[clang] [Clang] Unify interface for accessing template arguments as written for class/variable template specializations (PR #81642)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 1 08:03:32 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff f914e8e77c4703814e2f2dcef1d4569b17837c92 01858345a1146f761dec8e5d0a5a36dc0507ec48 -- clang/include/clang/AST/DeclTemplate.h clang/include/clang/AST/RecursiveASTVisitor.h clang/include/clang/ASTMatchers/ASTMatchers.h clang/include/clang/ASTMatchers/ASTMatchersInternal.h clang/lib/AST/ASTImporter.cpp clang/lib/AST/DeclPrinter.cpp clang/lib/AST/DeclTemplate.cpp clang/lib/AST/TypePrinter.cpp clang/lib/Index/IndexDecl.cpp clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaTemplate.cpp clang/lib/Sema/SemaTemplateInstantiateDecl.cpp clang/lib/Serialization/ASTReaderDecl.cpp clang/lib/Serialization/ASTWriterDecl.cpp clang/test/AST/ast-dump-template-decls.cpp clang/test/Index/Core/index-source.cpp clang/test/Index/index-refs.cpp clang/tools/libclang/CIndex.cpp clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 7bfd54c333..3844cafb5c 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -445,8 +445,7 @@ namespace clang {
FunctionDecl *FromFD);
template <typename DeclTy>
- Error ImportTemplateParameterLists(const DeclTy *FromD,
- DeclTy *ToD);
+ Error ImportTemplateParameterLists(const DeclTy *FromD, DeclTy *ToD);
Error ImportTemplateInformation(FunctionDecl *FromFD, FunctionDecl *ToFD);
diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index f1fb5ba378..adcf9188a9 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -987,23 +987,26 @@ ClassTemplateSpecializationDecl::getSpecializedTemplate() const {
SourceRange
ClassTemplateSpecializationDecl::getSourceRange() const {
if (getSpecializationKind() == TSK_ExplicitInstantiationDeclaration) {
- return SourceRange(getExternLoc(), getTemplateArgsAsWritten()->getRAngleLoc());
+ return SourceRange(getExternLoc(),
+ getTemplateArgsAsWritten()->getRAngleLoc());
} else if (getSpecializationKind() == TSK_ExplicitInstantiationDefinition) {
- return SourceRange(getTemplateKeywordLoc(), getTemplateArgsAsWritten()->getRAngleLoc());
+ return SourceRange(getTemplateKeywordLoc(),
+ getTemplateArgsAsWritten()->getRAngleLoc());
} else if (!isExplicitSpecialization()) {
// No explicit info available.
llvm::PointerUnion<ClassTemplateDecl *,
ClassTemplatePartialSpecializationDecl *>
- InstFrom = getInstantiatedFrom();
+ InstFrom = getInstantiatedFrom();
if (InstFrom.isNull())
return getSpecializedTemplate()->getSourceRange();
if (const auto *CTD = InstFrom.dyn_cast<ClassTemplateDecl *>())
return CTD->getSourceRange();
return InstFrom.get<ClassTemplatePartialSpecializationDecl *>()
- ->getSourceRange();
+ ->getSourceRange();
}
SourceLocation Begin = TagDecl::getOuterLocStart();
- if (const auto *CTPSD = dyn_cast<ClassTemplatePartialSpecializationDecl>(this)) {
+ if (const auto *CTPSD =
+ dyn_cast<ClassTemplatePartialSpecializationDecl>(this)) {
if (const auto *InstFrom = CTPSD->getInstantiatedFromMember())
return InstFrom->getSourceRange();
else if (!getNumTemplateParameterLists())
@@ -1381,10 +1384,12 @@ SourceRange VarTemplateSpecializationDecl::getSourceRange() const {
if (isExplicitSpecialization() && !hasInit()) {
if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsAsWritten())
return SourceRange(getOuterLocStart(), Info->getRAngleLoc());
- } else if (getTemplateSpecializationKind() == TSK_ExplicitInstantiationDeclaration ) {
+ } else if (getTemplateSpecializationKind() ==
+ TSK_ExplicitInstantiationDeclaration) {
if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsAsWritten())
return SourceRange(getExternLoc(), Info->getRAngleLoc());
- } else if (getTemplateSpecializationKind() == TSK_ExplicitInstantiationDefinition) {
+ } else if (getTemplateSpecializationKind() ==
+ TSK_ExplicitInstantiationDefinition) {
if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsAsWritten())
return SourceRange(getTemplateKeywordLoc(), Info->getRAngleLoc());
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/81642
More information about the cfe-commits
mailing list