From db9b9b7ecfc18201ba7078fe05b0800875261a5f Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Wed, 23 Apr 2014 05:16:48 +0000 Subject: [PATCH] AST: Cleanup/simplify some LV calculation code No functional change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206943 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/Decl.cpp | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 15410f0e9b..dd7b0c8194 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -227,23 +227,21 @@ getLVForType(const Type &T, LVComputationKind computation) { /// template parameter list. For visibility purposes, template /// parameters are part of the signature of a template. static LinkageInfo -getLVForTemplateParameterList(const TemplateParameterList *params, +getLVForTemplateParameterList(const TemplateParameterList *Params, LVComputationKind computation) { LinkageInfo LV; - for (TemplateParameterList::const_iterator P = params->begin(), - PEnd = params->end(); - P != PEnd; ++P) { - + for (const NamedDecl *P : *Params) { // Template type parameters are the most common and never // contribute to visibility, pack or not. - if (isa(*P)) + if (isa(P)) continue; // Non-type template parameters can be restricted by the value type, e.g. // template class A { ... }; // We have to be careful here, though, because we can be dealing with // dependent types. - if (NonTypeTemplateParmDecl *NTTP = dyn_cast(*P)) { + if (const NonTypeTemplateParmDecl *NTTP = + dyn_cast(P)) { // Handle the non-pack case first. if (!NTTP->isExpandedParameterPack()) { if (!NTTP->getType()->isDependentType()) { @@ -263,7 +261,7 @@ getLVForTemplateParameterList(const TemplateParameterList *params, // Template template parameters can be restricted by their // template parameters, recursively. - TemplateTemplateParmDecl *TTP = cast(*P); + const TemplateTemplateParmDecl *TTP = cast(P); // Handle the non-pack case first. if (!TTP->isExpandedParameterPack()) { @@ -303,43 +301,41 @@ static const Decl *getOutermostFuncOrBlockContext(const Decl *D) { /// /// Note that we don't take an LVComputationKind because we always /// want to honor the visibility of template arguments in the same way. -static LinkageInfo -getLVForTemplateArgumentList(ArrayRef args, - LVComputationKind computation) { +static LinkageInfo getLVForTemplateArgumentList(ArrayRef Args, + LVComputationKind computation) { LinkageInfo LV; - for (unsigned i = 0, e = args.size(); i != e; ++i) { - const TemplateArgument &arg = args[i]; - switch (arg.getKind()) { + for (const TemplateArgument &Arg : Args) { + switch (Arg.getKind()) { case TemplateArgument::Null: case TemplateArgument::Integral: case TemplateArgument::Expression: continue; case TemplateArgument::Type: - LV.merge(getLVForType(*arg.getAsType(), computation)); + LV.merge(getLVForType(*Arg.getAsType(), computation)); continue; case TemplateArgument::Declaration: - if (NamedDecl *ND = dyn_cast(arg.getAsDecl())) { + if (NamedDecl *ND = dyn_cast(Arg.getAsDecl())) { assert(!usesTypeVisibility(ND)); LV.merge(getLVForDecl(ND, computation)); } continue; case TemplateArgument::NullPtr: - LV.merge(arg.getNullPtrType()->getLinkageAndVisibility()); + LV.merge(Arg.getNullPtrType()->getLinkageAndVisibility()); continue; case TemplateArgument::Template: case TemplateArgument::TemplateExpansion: - if (TemplateDecl *Template - = arg.getAsTemplateOrTemplatePattern().getAsTemplateDecl()) + if (TemplateDecl *Template = + Arg.getAsTemplateOrTemplatePattern().getAsTemplateDecl()) LV.merge(getLVForDecl(Template, computation)); continue; case TemplateArgument::Pack: - LV.merge(getLVForTemplateArgumentList(arg.getPackAsArray(), computation)); + LV.merge(getLVForTemplateArgumentList(Arg.getPackAsArray(), computation)); continue; } llvm_unreachable("bad template argument kind"); -- 2.40.0