From: David Blaikie Date: Fri, 17 Oct 2014 18:00:12 +0000 (+0000) Subject: Rename TemplateArgument::getTypeForDecl to getParamTypeForDecl for clarity X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=34364392336ffeb4e76e5583bce9537aec4aaa75;p=clang Rename TemplateArgument::getTypeForDecl to getParamTypeForDecl for clarity Code review feedback from Richard Smith on r219900. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220060 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/TemplateBase.h b/include/clang/AST/TemplateBase.h index b50525c8ae..f3c6440f40 100644 --- a/include/clang/AST/TemplateBase.h +++ b/include/clang/AST/TemplateBase.h @@ -249,7 +249,7 @@ public: return DeclArg.D; } - QualType getTypeForDecl() const { + QualType getParamTypeForDecl() const { assert(getKind() == Declaration && "Unexpected kind"); return QualType::getFromOpaquePtr(DeclArg.QT); } diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 8f8ae8da0d..ba581396d9 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -4099,7 +4099,7 @@ ASTContext::getCanonicalTemplateArgument(const TemplateArgument &Arg) const { case TemplateArgument::Declaration: { ValueDecl *D = cast(Arg.getAsDecl()->getCanonicalDecl()); - return TemplateArgument(D, Arg.getTypeForDecl()); + return TemplateArgument(D, Arg.getParamTypeForDecl()); } case TemplateArgument::NullPtr: diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index 6b16cacbc9..02864a5d4d 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -2094,7 +2094,7 @@ ASTNodeImporter::ImportTemplateArgument(const TemplateArgument &From) { case TemplateArgument::Declaration: { ValueDecl *FromD = From.getAsDecl(); if (ValueDecl *To = cast_or_null(Importer.Import(FromD))) - return TemplateArgument(To, From.getTypeForDecl()); + return TemplateArgument(To, From.getParamTypeForDecl()); return TemplateArgument(); } diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp index fe5a50271d..5965ef0515 100644 --- a/lib/AST/ItaniumMangle.cpp +++ b/lib/AST/ItaniumMangle.cpp @@ -3403,7 +3403,7 @@ void CXXNameMangler::mangleTemplateArg(TemplateArgument A) { // and pointer-to-function expressions are represented as a declaration not // an expression. We compensate for it here to produce the correct mangling. ValueDecl *D = A.getAsDecl(); - bool compensateMangling = !A.getTypeForDecl()->isReferenceType(); + bool compensateMangling = !A.getParamTypeForDecl()->isReferenceType(); if (compensateMangling) { Out << 'X'; mangleOperatorName(OO_Amp, 1); diff --git a/lib/AST/MicrosoftMangle.cpp b/lib/AST/MicrosoftMangle.cpp index 54ac2b6352..59cf4d091b 100644 --- a/lib/AST/MicrosoftMangle.cpp +++ b/lib/AST/MicrosoftMangle.cpp @@ -1139,7 +1139,7 @@ void MicrosoftCXXNameMangler::mangleTemplateArg(const TemplateDecl *TD, else mangle(FD, "$1?"); } else { - mangle(ND, TA.getTypeForDecl()->isReferenceType() ? "$E?" : "$1?"); + mangle(ND, TA.getParamTypeForDecl()->isReferenceType() ? "$E?" : "$1?"); } break; } diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 0a5c40ed1a..ac51a55d15 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -1255,32 +1255,29 @@ CollectTemplateParams(const TemplateParameterList *TPList, } break; case TemplateArgument::Declaration: { const ValueDecl *D = TA.getAsDecl(); - bool InstanceMember = D->isCXXInstanceMember(); - QualType T = TA.getTypeForDecl(); + QualType T = TA.getParamTypeForDecl(); llvm::DIType TTy = getOrCreateType(T, Unit); llvm::Value *V = nullptr; // Variable pointer template parameters have a value that is the address // of the variable. - if (const VarDecl *VD = dyn_cast(D)) + if (const auto *VD = dyn_cast(D)) V = CGM.GetAddrOfGlobalVar(VD); // Member function pointers have special support for building them, though // this is currently unsupported in LLVM CodeGen. - if (InstanceMember) { - if (const CXXMethodDecl *method = dyn_cast(D)) + else if (const auto *method = dyn_cast(D)) V = CGM.getCXXABI().EmitMemberPointer(method); - } else if (const FunctionDecl *FD = dyn_cast(D)) + else if (const auto *FD = dyn_cast(D)) V = CGM.GetAddrOfFunction(FD); // Member data pointers have special handling too to compute the fixed // offset within the object. - if (isa(D) || isa(D)) { + else if (const auto *MPT = dyn_cast(T.getTypePtr())) { // These five lines (& possibly the above member function pointer // handling) might be able to be refactored to use similar code in // CodeGenModule::getMemberPointerConstant uint64_t fieldOffset = CGM.getContext().getFieldOffset(D); CharUnits chars = CGM.getContext().toCharUnitsFromBits((int64_t) fieldOffset); - V = CGM.getCXXABI().EmitMemberDataPointer( - cast(T.getTypePtr()), chars); + V = CGM.getCXXABI().EmitMemberDataPointer(MPT, chars); } llvm::DITemplateValueParameter TVP = DBuilder.createTemplateValueParameter(TheCU, Name, TTy, diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index c1df964460..5f8f5961be 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -5372,7 +5372,7 @@ void ASTWriter::AddTemplateArgument(const TemplateArgument &Arg, break; case TemplateArgument::Declaration: AddDeclRef(Arg.getAsDecl(), Record); - AddTypeRef(Arg.getTypeForDecl(), Record); + AddTypeRef(Arg.getParamTypeForDecl(), Record); break; case TemplateArgument::NullPtr: AddTypeRef(Arg.getNullPtrType(), Record);