clang 17.0.0git
|
#include "TreeTransform.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTMutationListener.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/DeclVisitor.h"
#include "clang/AST/DependentDiagnostic.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/PrettyDeclStackTrace.h"
#include "clang/AST/TypeLoc.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Sema/Initialization.h"
#include "clang/Sema/Lookup.h"
#include "clang/Sema/ScopeInfo.h"
#include "clang/Sema/SemaInternal.h"
#include "clang/Sema/Template.h"
#include "clang/Sema/TemplateInstCallback.h"
#include "llvm/Support/TimeProfiler.h"
#include <optional>
#include "clang/Sema/AttrTemplateInstantiate.inc"
Go to the source code of this file.
Functions | |
static bool | isDeclWithinFunction (const Decl *D) |
template<typename DeclT > | |
static bool | SubstQualifier (Sema &SemaRef, const DeclT *OldDecl, DeclT *NewDecl, const MultiLevelTemplateArgumentList &TemplateArgs) |
static void | instantiateDependentAlignedAttr (Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AlignedAttr *Aligned, Decl *New, bool IsPackExpansion) |
static void | instantiateDependentAlignedAttr (Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AlignedAttr *Aligned, Decl *New) |
static void | instantiateDependentAssumeAlignedAttr (Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AssumeAlignedAttr *Aligned, Decl *New) |
static void | instantiateDependentAlignValueAttr (Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AlignValueAttr *Aligned, Decl *New) |
static void | instantiateDependentAllocAlignAttr (Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AllocAlignAttr *Align, Decl *New) |
static void | instantiateDependentAnnotationAttr (Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AnnotateAttr *Attr, Decl *New) |
static Expr * | instantiateDependentFunctionAttrCondition (Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const Attr *A, Expr *OldCond, const Decl *Tmpl, FunctionDecl *New) |
static void | instantiateDependentEnableIfAttr (Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const EnableIfAttr *EIA, const Decl *Tmpl, FunctionDecl *New) |
static void | instantiateDependentDiagnoseIfAttr (Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const DiagnoseIfAttr *DIA, const Decl *Tmpl, FunctionDecl *New) |
static void | instantiateDependentCUDALaunchBoundsAttr (Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const CUDALaunchBoundsAttr &Attr, Decl *New) |
static void | instantiateDependentModeAttr (Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const ModeAttr &Attr, Decl *New) |
static void | instantiateOMPDeclareSimdDeclAttr (Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const OMPDeclareSimdDeclAttr &Attr, Decl *New) |
Instantiation of 'declare simd' attribute and its arguments. | |
static void | instantiateOMPDeclareVariantAttr (Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const OMPDeclareVariantAttr &Attr, Decl *New) |
Instantiation of 'declare variant' attribute and its arguments. | |
static void | instantiateDependentAMDGPUFlatWorkGroupSizeAttr (Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AMDGPUFlatWorkGroupSizeAttr &Attr, Decl *New) |
static ExplicitSpecifier | instantiateExplicitSpecifier (Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES, FunctionDecl *New) |
static void | instantiateDependentAMDGPUWavesPerEUAttr (Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AMDGPUWavesPerEUAttr &Attr, Decl *New) |
static void | instantiateDependentSYCLKernelAttr (Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const SYCLKernelAttr &Attr, Decl *New) |
static bool | isRelevantAttr (Sema &S, const Decl *D, const Attr *A) |
Determine whether the attribute A might be relevant to the declaration D. | |
static Sema::RetainOwnershipKind | attrToRetainOwnershipKind (const Attr *A) |
template<typename DeclT > | |
static DeclT * | getPreviousDeclForInstantiation (DeclT *D) |
Get the previous declaration of a declaration for the purposes of template instantiation. | |
static QualType | adjustFunctionTypeForInstantiation (ASTContext &Context, FunctionDecl *D, TypeSourceInfo *TInfo) |
Adjust the given function type for an instantiation of the given declaration, to cope with modifications to the function's type that aren't reflected in the type-source information. | |
static void | collectUnexpandedParameterPacks (Sema &S, TemplateParameterList *Params, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded) |
static bool | isInstantiationOf (ClassTemplateDecl *Pattern, ClassTemplateDecl *Instance) |
static bool | isInstantiationOf (FunctionTemplateDecl *Pattern, FunctionTemplateDecl *Instance) |
static bool | isInstantiationOf (ClassTemplatePartialSpecializationDecl *Pattern, ClassTemplatePartialSpecializationDecl *Instance) |
static bool | isInstantiationOf (CXXRecordDecl *Pattern, CXXRecordDecl *Instance) |
static bool | isInstantiationOf (FunctionDecl *Pattern, FunctionDecl *Instance) |
static bool | isInstantiationOf (EnumDecl *Pattern, EnumDecl *Instance) |
static bool | isInstantiationOf (UsingShadowDecl *Pattern, UsingShadowDecl *Instance, ASTContext &C) |
static bool | isInstantiationOf (UsingDecl *Pattern, UsingDecl *Instance, ASTContext &C) |
template<typename T > | |
static bool | isInstantiationOfUnresolvedUsingDecl (T *Pattern, Decl *Other, ASTContext &Ctx) |
static bool | isInstantiationOfStaticDataMember (VarDecl *Pattern, VarDecl *Instance) |
static bool | isInstantiationOf (ASTContext &Ctx, NamedDecl *D, Decl *Other) |
template<typename ForwardIterator > | |
static NamedDecl * | findInstantiationOf (ASTContext &Ctx, NamedDecl *D, ForwardIterator first, ForwardIterator last) |
static bool | isDependentContextAtLevel (DeclContext *DC, unsigned Level) |
Determine whether the given context is dependent on template parameters at level Level or below. | |
|
static |
Adjust the given function type for an instantiation of the given declaration, to cope with modifications to the function's type that aren't reflected in the type-source information.
D | The declaration we're instantiating. |
TInfo | The already-instantiated type. |
Definition at line 2007 of file SemaTemplateInstantiateDecl.cpp.
References clang::Type::castAs(), clang::FunctionProtoType::ExtProtoInfo::ExtInfo, clang::FunctionType::getExtInfo(), clang::ASTContext::getFunctionType(), clang::ValueDecl::getType(), and clang::TypeSourceInfo::getType().
Referenced by clang::TemplateDeclInstantiator::VisitCXXMethodDecl(), and clang::TemplateDeclInstantiator::VisitFunctionDecl().
|
static |
Definition at line 683 of file SemaTemplateInstantiateDecl.cpp.
References clang::Sema::CF, clang::Attr::getKind(), clang::Sema::NS, and clang::Sema::OS.
Referenced by clang::Sema::InstantiateAttrs().
|
static |
Definition at line 3040 of file SemaTemplateInstantiateDecl.cpp.
References collectUnexpandedParameterPacks(), clang::Sema::collectUnexpandedParameterPacks(), and P.
Referenced by collectUnexpandedParameterPacks().
|
static |
Definition at line 5980 of file SemaTemplateInstantiateDecl.cpp.
References isInstantiationOf().
Referenced by clang::Sema::FindInstantiatedDecl().
|
static |
Get the previous declaration of a declaration for the purposes of template instantiation.
If this finds a previous declaration, then the previous declaration of the instantiation of D should be an instantiation of the result of this function.
Definition at line 878 of file SemaTemplateInstantiateDecl.cpp.
References clang::Result.
Referenced by clang::TemplateDeclInstantiator::InstantiateTypedefNameDecl(), and clang::TemplateDeclInstantiator::VisitBaseUsingDecls().
|
static |
Definition at line 105 of file SemaTemplateInstantiateDecl.cpp.
References clang::Sema::CheckParameterPacksForExpansion(), clang::Sema::collectUnexpandedParameterPacks(), and instantiateDependentAlignedAttr().
|
static |
Definition at line 86 of file SemaTemplateInstantiateDecl.cpp.
References clang::Sema::AddAlignedAttr(), clang::Sema::ConstantEvaluated, clang::Result, clang::Sema::SubstExpr(), and clang::Sema::SubstType().
Referenced by clang::Sema::InstantiateAttrs(), and instantiateDependentAlignedAttr().
|
static |
Definition at line 166 of file SemaTemplateInstantiateDecl.cpp.
References clang::Sema::AddAlignValueAttr(), clang::Sema::ConstantEvaluated, clang::Result, and clang::Sema::SubstExpr().
Referenced by clang::Sema::InstantiateAttrs().
|
static |
Definition at line 177 of file SemaTemplateInstantiateDecl.cpp.
References clang::Sema::AddAllocAlignAttr(), clang::IntegerLiteral::Create(), clang::Sema::getASTContext(), and clang::ASTContext::UnsignedLongLongTy.
Referenced by clang::Sema::InstantiateAttrs().
|
static |
Definition at line 534 of file SemaTemplateInstantiateDecl.cpp.
References clang::Sema::addAMDGPUFlatWorkGroupSizeAttr(), clang::Sema::ConstantEvaluated, clang::Result, and clang::Sema::SubstExpr().
Referenced by clang::Sema::InstantiateAttrs().
|
static |
Definition at line 577 of file SemaTemplateInstantiateDecl.cpp.
References clang::Sema::addAMDGPUWavesPerEUAttr(), clang::Sema::ConstantEvaluated, clang::Result, and clang::Sema::SubstExpr().
Referenced by clang::Sema::InstantiateAttrs().
|
static |
Definition at line 187 of file SemaTemplateInstantiateDecl.cpp.
References clang::Sema::AddAnnotationAttr(), clang::Sema::checkStringLiteralArgumentAttr(), clang::Sema::ConstantEvaluated, clang::Sema::Diag(), clang::AttributeCommonInfo::getLoc(), and clang::Sema::SubstExprs().
Referenced by clang::Sema::InstantiateAttrs().
|
static |
Definition at line 143 of file SemaTemplateInstantiateDecl.cpp.
References clang::Sema::AddAssumeAlignedAttr(), clang::Sema::ConstantEvaluated, clang::Result, and clang::Sema::SubstExpr().
Referenced by clang::Sema::InstantiateAttrs().
|
static |
Definition at line 281 of file SemaTemplateInstantiateDecl.cpp.
References clang::Sema::AddLaunchBoundsAttr(), clang::Sema::ConstantEvaluated, clang::Result, and clang::Sema::SubstExpr().
Referenced by clang::Sema::InstantiateAttrs().
|
static |
Definition at line 267 of file SemaTemplateInstantiateDecl.cpp.
References clang::Decl::addAttr(), clang::Sema::getASTContext(), and instantiateDependentFunctionAttrCondition().
Referenced by clang::Sema::InstantiateAttrs().
|
static |
Definition at line 256 of file SemaTemplateInstantiateDecl.cpp.
References clang::Decl::addAttr(), clang::Sema::getASTContext(), and instantiateDependentFunctionAttrCondition().
Referenced by clang::Sema::InstantiateAttrs().
|
static |
Definition at line 225 of file SemaTemplateInstantiateDecl.cpp.
References clang::Sema::ConstantEvaluated, clang::Sema::Diag(), clang::ActionResult< PtrTy, CompressInvalid >::get(), clang::Attr::getLocation(), clang::ActionResult< PtrTy, CompressInvalid >::isInvalid(), clang::Expr::isPotentialConstantExprUnevaluated(), clang::Expr::isTypeDependent(), clang::Expr::isValueDependent(), P, clang::Sema::PerformContextuallyConvertToBool(), clang::Result, and clang::Sema::SubstExpr().
Referenced by instantiateDependentDiagnoseIfAttr(), and instantiateDependentEnableIfAttr().
|
static |
Definition at line 305 of file SemaTemplateInstantiateDecl.cpp.
References clang::Sema::AddModeAttr().
Referenced by clang::Sema::InstantiateAttrs().
|
static |
Definition at line 603 of file SemaTemplateInstantiateDecl.cpp.
References clang::Decl::addAttr(), clang::Attr::clone(), and clang::Sema::getASTContext().
Referenced by clang::Sema::InstantiateAttrs().
|
static |
Definition at line 555 of file SemaTemplateInstantiateDecl.cpp.
References clang::Sema::ConstantEvaluated, clang::ActionResult< PtrTy, CompressInvalid >::get(), clang::ExplicitSpecifier::getExpr(), clang::ExplicitSpecifier::getKind(), clang::ExplicitSpecifier::Invalid(), clang::ActionResult< PtrTy, CompressInvalid >::isInvalid(), clang::Expr::isTypeDependent(), clang::Result, clang::Sema::SubstExpr(), and clang::Sema::tryResolveExplicitSpecifier().
Referenced by clang::TemplateDeclInstantiator::VisitCXXMethodDecl(), and clang::TemplateDeclInstantiator::VisitFunctionDecl().
|
static |
Instantiation of 'declare simd' attribute and its arguments.
Definition at line 313 of file SemaTemplateInstantiateDecl.cpp.
References clang::Sema::ActOnFinishFullExpr(), clang::Sema::ActOnOpenMPDeclareSimdDirective(), clang::Sema::ConvertDeclToDeclGroup(), clang::ExprEmpty(), clang::ActionResult< PtrTy, CompressInvalid >::get(), clang::AttributeCommonInfo::getRange(), clang::ActionResult< PtrTy, CompressInvalid >::isInvalid(), clang::Sema::PotentiallyEvaluated, and clang::Sema::SubstExpr().
Referenced by clang::Sema::InstantiateAttrs().
|
static |
Instantiation of 'declare variant' attribute and its arguments.
Definition at line 396 of file SemaTemplateInstantiateDecl.cpp.
References clang::Sema::ActOnFinishFullExpr(), clang::Sema::ActOnOpenMPDeclareVariantDirective(), clang::OMPTraitInfo::anyScoreOrCondition(), bool, clang::Sema::checkOpenMPDeclareVariantFunction(), clang::Sema::ConstantEvaluated, clang::Sema::Context, clang::Sema::ConvertDeclToDeclGroup(), clang::DeclRefExpr::Create(), clang::TemplateArgumentList::CreateCopy(), clang::ActionResult< PtrTy, CompressInvalid >::get(), clang::Sema::getASTContext(), clang::MultiLevelTemplateArgumentList::getInnermost(), clang::Decl::getLocation(), clang::ASTContext::getNewOMPTraitInfo(), clang::AttributeCommonInfo::getRange(), clang::Sema::InstantiateFunctionDeclaration(), clang::Sema::InstantiateFunctionDefinition(), clang::ActionResult< PtrTy, CompressInvalid >::isInvalid(), clang::QualType::isNull(), clang::ActionResult< PtrTy, CompressInvalid >::isUsable(), clang::ASTContext::mergeFunctionTypes(), clang::Sema::PotentiallyEvaluated, clang::Sema::SubstExpr(), and clang::VK_PRValue.
Referenced by clang::Sema::InstantiateAttrs().
Definition at line 36 of file SemaTemplateInstantiateDecl.cpp.
References clang::Decl::getDeclContext(), clang::DeclContext::isFunctionOrMethod(), and clang::DeclContext::isRecord().
|
static |
Determine whether the given context is dependent on template parameters at level Level
or below.
Sometimes we only substitute an inner set of template arguments and leave the outer templates alone. In such cases, contexts dependent only on the outer levels are not effectively dependent.
Definition at line 6009 of file SemaTemplateInstantiateDecl.cpp.
References clang::DeclContext::isDependentContext().
Referenced by clang::Sema::FindInstantiatedDecl().
|
static |
Definition at line 5927 of file SemaTemplateInstantiateDecl.cpp.
References clang::declaresSameEntity(), Enum, clang::NamedDecl::getDeclName(), clang::ASTContext::getInstantiatedFromUnnamedFieldDecl(), clang::Decl::getKind(), isInstantiationOf(), isInstantiationOfStaticDataMember(), isInstantiationOfUnresolvedUsingDecl(), and clang::VarDecl::isStaticDataMember().
|
static |
Definition at line 5790 of file SemaTemplateInstantiateDecl.cpp.
References clang::ClassTemplateDecl::getCanonicalDecl().
Referenced by clang::Sema::FindInstantiatedDecl(), findInstantiationOf(), and isInstantiationOf().
|
static |
Definition at line 5817 of file SemaTemplateInstantiateDecl.cpp.
References clang::CXXRecordDecl::getCanonicalDecl().
|
static |
Definition at line 5832 of file SemaTemplateInstantiateDecl.cpp.
References clang::CXXRecordDecl::getCanonicalDecl().
Definition at line 5858 of file SemaTemplateInstantiateDecl.cpp.
References clang::EnumDecl::getCanonicalDecl().
|
static |
Definition at line 5845 of file SemaTemplateInstantiateDecl.cpp.
References clang::FunctionDecl::getCanonicalDecl().
|
static |
Definition at line 5803 of file SemaTemplateInstantiateDecl.cpp.
References clang::FunctionTemplateDecl::getCanonicalDecl().
|
static |
Definition at line 5878 of file SemaTemplateInstantiateDecl.cpp.
References clang::C, and clang::declaresSameEntity().
|
static |
Definition at line 5871 of file SemaTemplateInstantiateDecl.cpp.
References clang::C, and clang::declaresSameEntity().
Definition at line 5910 of file SemaTemplateInstantiateDecl.cpp.
References clang::VarDecl::getCanonicalDecl().
Referenced by isInstantiationOf().
|
static |
Definition at line 5884 of file SemaTemplateInstantiateDecl.cpp.
References clang::declaresSameEntity(), and clang::ASTContext::getInstantiatedFromUsingDecl().
Referenced by isInstantiationOf().
Determine whether the attribute A might be relevant to the declaration D.
If not, we can skip instantiating it. The attribute may or may not have been instantiated yet.
Definition at line 612 of file SemaTemplateInstantiateDecl.cpp.
References clang::Sema::Context, clang::declaresSameEntity(), clang::Type::getAsCXXRecordDecl(), clang::FunctionDecl::getNumParams(), clang::FunctionDecl::getParamDecl(), clang::FunctionDecl::getReturnType(), clang::ValueDecl::getType(), clang::ASTContext::hasSameType(), clang::Type::isDependentType(), clang::Type::isLValueReferenceType(), clang::Type::isReferenceType(), clang::Type::isRValueReferenceType(), and clang::Decl::specific_attrs().
Referenced by clang::Sema::InstantiateAttrs(), and clang::Sema::InstantiateAttrsForDecl().
|
static |
Definition at line 48 of file SemaTemplateInstantiateDecl.cpp.
References clang::Sema::SubstNestedNameSpecifierLoc().
Referenced by clang::Sema::InstantiateFunctionDefinition().