Author: Erich Keane Date: 2022-02-28T12:14:14-08:00 New Revision: 96dea2015554d1bf1e095ea82bc57d9229bd5fd5
URL: https://github.com/llvm/llvm-project/commit/96dea2015554d1bf1e095ea82bc57d9229bd5fd5 DIFF: https://github.com/llvm/llvm-project/commit/96dea2015554d1bf1e095ea82bc57d9229bd5fd5.diff LOG: [NFC] Make 1st param to getTemplateInstantiationArgs const correct The function doesn't modify anything, and took minimal effort to get const-correct, AND is necessary for a patch I've been working on for concepts. Added: Modified: clang/include/clang/AST/ASTLambda.h clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaTemplateInstantiate.cpp Removed: ################################################################################ diff --git a/clang/include/clang/AST/ASTLambda.h b/clang/include/clang/AST/ASTLambda.h index 6fd82d6af4908..230e0c848610f 100644 --- a/clang/include/clang/AST/ASTLambda.h +++ b/clang/include/clang/AST/ASTLambda.h @@ -65,8 +65,8 @@ inline bool isGenericLambdaCallOperatorSpecialization(DeclContext *DC) { } inline bool isGenericLambdaCallOperatorOrStaticInvokerSpecialization( - DeclContext *DC) { - CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC); + const DeclContext *DC) { + const auto *MD = dyn_cast<CXXMethodDecl>(DC); if (!MD) return false; const CXXRecordDecl *LambdaClass = MD->getParent(); if (LambdaClass && LambdaClass->isGenericLambda()) @@ -75,7 +75,6 @@ inline bool isGenericLambdaCallOperatorOrStaticInvokerSpecialization( return false; } - // This returns the parent DeclContext ensuring that the correct // parent DeclContext is returned for Lambdas inline DeclContext *getLambdaAwareParentOfDeclContext(DeclContext *DC) { diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 9937846e05658..0840f3a6cdb71 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -8747,11 +8747,9 @@ class Sema final { // C++ Template Instantiation // - MultiLevelTemplateArgumentList - getTemplateInstantiationArgs(NamedDecl *D, - const TemplateArgumentList *Innermost = nullptr, - bool RelativeToPrimary = false, - const FunctionDecl *Pattern = nullptr); + MultiLevelTemplateArgumentList getTemplateInstantiationArgs( + const NamedDecl *D, const TemplateArgumentList *Innermost = nullptr, + bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr); /// A context in which code is being synthesized (where a source location /// alone is not sufficient to identify the context). This covers template diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 6de486be8f167..2675665202971 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -55,26 +55,23 @@ using namespace sema; /// instantiating the definition of the given declaration, \p D. This is /// used to determine the proper set of template instantiation arguments for /// friend function template specializations. -MultiLevelTemplateArgumentList -Sema::getTemplateInstantiationArgs(NamedDecl *D, - const TemplateArgumentList *Innermost, - bool RelativeToPrimary, - const FunctionDecl *Pattern) { +MultiLevelTemplateArgumentList Sema::getTemplateInstantiationArgs( + const NamedDecl *D, const TemplateArgumentList *Innermost, + bool RelativeToPrimary, const FunctionDecl *Pattern) { // Accumulate the set of template argument lists in this structure. MultiLevelTemplateArgumentList Result; if (Innermost) Result.addOuterTemplateArguments(Innermost); - DeclContext *Ctx = dyn_cast<DeclContext>(D); + const auto *Ctx = dyn_cast<DeclContext>(D); if (!Ctx) { Ctx = D->getDeclContext(); // Add template arguments from a variable template instantiation. For a // class-scope explicit specialization, there are no template arguments // at this level, but there may be enclosing template arguments. - VarTemplateSpecializationDecl *Spec = - dyn_cast<VarTemplateSpecializationDecl>(D); + const auto *Spec = dyn_cast<VarTemplateSpecializationDecl>(D); if (Spec && !Spec->isClassScopeExplicitSpecialization()) { // We're done when we hit an explicit specialization. if (Spec->getSpecializationKind() == TSK_ExplicitSpecialization && @@ -107,8 +104,7 @@ Sema::getTemplateInstantiationArgs(NamedDecl *D, // use empty template parameter lists for all of the outer templates // to avoid performing any substitutions. if (Ctx->isTranslationUnit()) { - if (TemplateTemplateParmDecl *TTP - = dyn_cast<TemplateTemplateParmDecl>(D)) { + if (const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(D)) { for (unsigned I = 0, N = TTP->getDepth() + 1; I != N; ++I) Result.addOuterTemplateArguments(None); return Result; @@ -118,8 +114,7 @@ Sema::getTemplateInstantiationArgs(NamedDecl *D, while (!Ctx->isFileContext()) { // Add template arguments from a class template instantiation. - ClassTemplateSpecializationDecl *Spec - = dyn_cast<ClassTemplateSpecializationDecl>(Ctx); + const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(Ctx); if (Spec && !Spec->isClassScopeExplicitSpecialization()) { // We're done when we hit an explicit specialization. if (Spec->getSpecializationKind() == TSK_ExplicitSpecialization && @@ -135,7 +130,7 @@ Sema::getTemplateInstantiationArgs(NamedDecl *D, break; } // Add template arguments from a function template specialization. - else if (FunctionDecl *Function = dyn_cast<FunctionDecl>(Ctx)) { + else if (const auto *Function = dyn_cast<FunctionDecl>(Ctx)) { if (!RelativeToPrimary && Function->getTemplateSpecializationKindForInstantiation() == TSK_ExplicitSpecialization) @@ -177,7 +172,7 @@ Sema::getTemplateInstantiationArgs(NamedDecl *D, RelativeToPrimary = false; continue; } - } else if (CXXRecordDecl *Rec = dyn_cast<CXXRecordDecl>(Ctx)) { + } else if (const auto *Rec = dyn_cast<CXXRecordDecl>(Ctx)) { if (ClassTemplateDecl *ClassTemplate = Rec->getDescribedClassTemplate()) { assert(Result.getNumSubstitutedLevels() == 0 && "Outer template not instantiated?"); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits