diff options
Diffstat (limited to 'clang/include')
25 files changed, 269 insertions, 78 deletions
diff --git a/clang/include/clang/AST/ASTConcept.h b/clang/include/clang/AST/ASTConcept.h index c8f6330..7ccac44 100644 --- a/clang/include/clang/AST/ASTConcept.h +++ b/clang/include/clang/AST/ASTConcept.h @@ -27,6 +27,7 @@ namespace clang { class ConceptDecl; +class TemplateDecl; class Expr; class NamedDecl; struct PrintingPolicy; @@ -123,6 +124,7 @@ struct ASTConstraintSatisfaction final : /// template <std::derives_from<Expr> T> void dump(); /// ~~~~~~~~~~~~~~~~~~~~~~~ (in TemplateTypeParmDecl) class ConceptReference { +protected: // \brief The optional nested name specifier used when naming the concept. NestedNameSpecifierLoc NestedNameSpec; @@ -140,7 +142,7 @@ class ConceptReference { NamedDecl *FoundDecl; /// \brief The concept named. - ConceptDecl *NamedConcept; + TemplateDecl *NamedConcept; /// \brief The template argument list source info used to specialize the /// concept. @@ -148,7 +150,7 @@ class ConceptReference { ConceptReference(NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, - ConceptDecl *NamedConcept, + TemplateDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten) : NestedNameSpec(NNS), TemplateKWLoc(TemplateKWLoc), ConceptName(ConceptNameInfo), FoundDecl(FoundDecl), @@ -158,7 +160,7 @@ public: static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, - NamedDecl *FoundDecl, ConceptDecl *NamedConcept, + NamedDecl *FoundDecl, TemplateDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten); const NestedNameSpecifierLoc &getNestedNameSpecifierLoc() const { @@ -197,9 +199,7 @@ public: return FoundDecl; } - ConceptDecl *getNamedConcept() const { - return NamedConcept; - } + TemplateDecl *getNamedConcept() const { return NamedConcept; } const ASTTemplateArgumentListInfo *getTemplateArgsAsWritten() const { return ArgsAsWritten; @@ -252,7 +252,9 @@ public: // FIXME: Instead of using these concept related functions the callers should // directly work with the corresponding ConceptReference. - ConceptDecl *getNamedConcept() const { return ConceptRef->getNamedConcept(); } + TemplateDecl *getNamedConcept() const { + return ConceptRef->getNamedConcept(); + } SourceLocation getConceptNameLoc() const { return ConceptRef->getConceptNameLoc(); diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index db86963..2b7ba41 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1290,6 +1290,9 @@ public: // Implicitly-declared type 'struct _GUID'. mutable TagDecl *MSGuidTagDecl = nullptr; + // Implicitly-declared type 'struct type_info'. + mutable TagDecl *MSTypeInfoTagDecl = nullptr; + /// Keep track of CUDA/HIP device-side variables ODR-used by host code. /// This does not include extern shared variables used by device host /// functions as addresses of shared variables are per warp, therefore @@ -1759,7 +1762,7 @@ private: QualType getAutoTypeInternal(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent, bool IsPack = false, - ConceptDecl *TypeConstraintConcept = nullptr, + TemplateDecl *TypeConstraintConcept = nullptr, ArrayRef<TemplateArgument> TypeConstraintArgs = {}, bool IsCanon = false) const; @@ -1979,10 +1982,11 @@ public: UnaryTransformType::UTTKind UKind) const; /// C++11 deduced auto type. - QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, - bool IsDependent, bool IsPack = false, - ConceptDecl *TypeConstraintConcept = nullptr, - ArrayRef<TemplateArgument> TypeConstraintArgs ={}) const; + QualType + getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent, + bool IsPack = false, + TemplateDecl *TypeConstraintConcept = nullptr, + ArrayRef<TemplateArgument> TypeConstraintArgs = {}) const; /// C++11 deduction pattern for 'auto' type. QualType getAutoDeductType() const; @@ -2387,6 +2391,14 @@ public: return getTagDeclType(MSGuidTagDecl); } + /// Retrieve the implicitly-predeclared 'struct type_info' declaration. + TagDecl *getMSTypeInfoTagDecl() const { + // Lazily create this type on demand - it's only needed for MS builds. + if (!MSTypeInfoTagDecl) + MSTypeInfoTagDecl = buildImplicitRecord("type_info", TagTypeKind::Class); + return MSTypeInfoTagDecl; + } + /// Return whether a declaration to a builtin is allowed to be /// overloaded/redeclared. bool canBuiltinBeRedeclared(const FunctionDecl *) const; diff --git a/clang/include/clang/AST/DeclID.h b/clang/include/clang/AST/DeclID.h index 384f7b0..47ae05b 100644 --- a/clang/include/clang/AST/DeclID.h +++ b/clang/include/clang/AST/DeclID.h @@ -77,6 +77,9 @@ enum PredefinedDeclIDs { /// The internal '__NSConstantString' tag type. PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID, + /// The predeclared 'type_info' struct. + PREDEF_DECL_BUILTIN_MS_TYPE_INFO_TAG_ID, + #define BuiltinTemplate(BTName) PREDEF_DECL##BTName##_ID, #include "clang/Basic/BuiltinTemplates.inc" diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index 1ff6cc6..32de203 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -26,6 +26,7 @@ #include "clang/Basic/LLVM.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/Specifiers.h" +#include "clang/Basic/TemplateKinds.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/PointerIntPair.h" @@ -1585,6 +1586,9 @@ class TemplateTemplateParmDecl final DefaultArgStorage<TemplateTemplateParmDecl, TemplateArgumentLoc *>; DefArgStorage DefaultArgument; + LLVM_PREFERRED_TYPE(TemplateNameKind) + unsigned ParameterKind : 3; + /// Whether this template template parameter was declaration with /// the 'typename' keyword. /// @@ -1607,13 +1611,16 @@ class TemplateTemplateParmDecl final TemplateTemplateParmDecl(DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, - bool Typename, TemplateParameterList *Params) + TemplateNameKind ParameterKind, bool Typename, + TemplateParameterList *Params) : TemplateDecl(TemplateTemplateParm, DC, L, Id, Params), - TemplateParmPosition(D, P), Typename(Typename), - ParameterPack(ParameterPack), ExpandedParameterPack(false) {} + TemplateParmPosition(D, P), ParameterKind(ParameterKind), + Typename(Typename), ParameterPack(ParameterPack), + ExpandedParameterPack(false) {} TemplateTemplateParmDecl(DeclContext *DC, SourceLocation L, unsigned D, - unsigned P, IdentifierInfo *Id, bool Typename, + unsigned P, IdentifierInfo *Id, + TemplateNameKind ParameterKind, bool Typename, TemplateParameterList *Params, ArrayRef<TemplateParameterList *> Expansions); @@ -1624,15 +1631,16 @@ public: friend class ASTDeclWriter; friend TrailingObjects; - static TemplateTemplateParmDecl *Create(const ASTContext &C, DeclContext *DC, - SourceLocation L, unsigned D, - unsigned P, bool ParameterPack, - IdentifierInfo *Id, bool Typename, - TemplateParameterList *Params); static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, - unsigned P, IdentifierInfo *Id, bool Typename, - TemplateParameterList *Params, + unsigned P, bool ParameterPack, IdentifierInfo *Id, + TemplateNameKind ParameterKind, bool Typename, + TemplateParameterList *Params); + + static TemplateTemplateParmDecl * + Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, + unsigned P, IdentifierInfo *Id, TemplateNameKind ParameterKind, + bool Typename, TemplateParameterList *Params, ArrayRef<TemplateParameterList *> Expansions); static TemplateTemplateParmDecl *CreateDeserialized(ASTContext &C, @@ -1746,6 +1754,16 @@ public: return SourceRange(getTemplateParameters()->getTemplateLoc(), End); } + TemplateNameKind templateParameterKind() const { + return static_cast<TemplateNameKind>(ParameterKind); + } + + bool isTypeConceptTemplateParam() const { + return templateParameterKind() == TemplateNameKind::TNK_Concept_template && + getTemplateParameters()->size() > 0 && + isa<TemplateTypeParmDecl>(getTemplateParameters()->getParam(0)); + } + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == TemplateTemplateParm; } @@ -3341,7 +3359,11 @@ inline TemplateDecl *getAsTypeTemplateDecl(Decl *D) { return TD && (isa<ClassTemplateDecl>(TD) || isa<ClassTemplatePartialSpecializationDecl>(TD) || isa<TypeAliasTemplateDecl>(TD) || - isa<TemplateTemplateParmDecl>(TD)) + [&]() { + if (const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(TD)) + return TTP->templateParameterKind() == TNK_Type_template; + return false; + }()) ? TD : nullptr; } diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index a22c322..7a26934 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -38,6 +38,7 @@ #include "clang/Basic/OperatorKinds.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/Specifiers.h" +#include "clang/Basic/TemplateKinds.h" #include "clang/Basic/TypeTraits.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/PointerUnion.h" @@ -3257,7 +3258,49 @@ public: bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); } /// Determines whether this expression had explicit template arguments. - bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); } + bool hasExplicitTemplateArgs() const { + if (!hasTemplateKWAndArgsInfo()) + return false; + // FIXME: deduced function types can have "hidden" args and no < + // investigate that further, but ultimately maybe we want to model concepts + // reference with another kind of expression. + return (isConceptReference() || isVarDeclReference()) + ? getTrailingASTTemplateKWAndArgsInfo()->NumTemplateArgs + : getLAngleLoc().isValid(); + } + + bool isConceptReference() const { + return getNumDecls() == 1 && [&]() { + if (auto *TTP = dyn_cast_or_null<TemplateTemplateParmDecl>( + getTrailingResults()->getDecl())) + return TTP->templateParameterKind() == TNK_Concept_template; + if (isa<ConceptDecl>(getTrailingResults()->getDecl())) + return true; + return false; + }(); + } + + bool isVarDeclReference() const { + return getNumDecls() == 1 && [&]() { + if (auto *TTP = dyn_cast_or_null<TemplateTemplateParmDecl>( + getTrailingResults()->getDecl())) + return TTP->templateParameterKind() == TNK_Var_template; + if (isa<VarTemplateDecl>(getTrailingResults()->getDecl())) + return true; + return false; + }(); + } + + TemplateDecl *getTemplateDecl() const { + assert(getNumDecls() == 1); + return dyn_cast_or_null<TemplateDecl>(getTrailingResults()->getDecl()); + } + + TemplateTemplateParmDecl *getTemplateTemplateDecl() const { + assert(getNumDecls() == 1); + return dyn_cast_or_null<TemplateTemplateParmDecl>( + getTrailingResults()->getDecl()); + } TemplateArgumentLoc const *getTemplateArgs() const { if (!hasExplicitTemplateArgs()) @@ -4658,7 +4701,7 @@ public: // sugared: it doesn't need to be resugared later. bool getFinal() const { return Final; } - NonTypeTemplateParmDecl *getParameter() const; + NamedDecl *getParameter() const; bool isReferenceParameter() const { return AssociatedDeclAndRef.getInt(); } diff --git a/clang/include/clang/AST/ExprConcepts.h b/clang/include/clang/AST/ExprConcepts.h index 7ab0c3e..4f162b6 100644 --- a/clang/include/clang/AST/ExprConcepts.h +++ b/clang/include/clang/AST/ExprConcepts.h @@ -84,7 +84,9 @@ public: ConceptReference *getConceptReference() const { return ConceptRef; } - ConceptDecl *getNamedConcept() const { return ConceptRef->getNamedConcept(); } + ConceptDecl *getNamedConcept() const { + return cast<ConceptDecl>(ConceptRef->getNamedConcept()); + } // FIXME: Several of the following functions can be removed. Instead the // caller can directly work with the ConceptReference. diff --git a/clang/include/clang/AST/OpenACCClause.h b/clang/include/clang/AST/OpenACCClause.h index 71ad24a..8c848a1 100644 --- a/clang/include/clang/AST/OpenACCClause.h +++ b/clang/include/clang/AST/OpenACCClause.h @@ -837,44 +837,87 @@ public: class OpenACCPrivateClause final : public OpenACCClauseWithVarList, - private llvm::TrailingObjects<OpenACCPrivateClause, Expr *> { + private llvm::TrailingObjects<OpenACCPrivateClause, Expr *, VarDecl *> { friend TrailingObjects; OpenACCPrivateClause(SourceLocation BeginLoc, SourceLocation LParenLoc, - ArrayRef<Expr *> VarList, SourceLocation EndLoc) + ArrayRef<Expr *> VarList, + ArrayRef<VarDecl *> InitRecipes, SourceLocation EndLoc) : OpenACCClauseWithVarList(OpenACCClauseKind::Private, BeginLoc, LParenLoc, EndLoc) { - setExprs(getTrailingObjects(VarList.size()), VarList); + assert(VarList.size() == InitRecipes.size()); + setExprs(getTrailingObjects<Expr *>(VarList.size()), VarList); + llvm::uninitialized_copy(InitRecipes, getTrailingObjects<VarDecl *>()); } public: static bool classof(const OpenACCClause *C) { return C->getClauseKind() == OpenACCClauseKind::Private; } + // Gets a list of 'made up' `VarDecl` objects that can be used by codegen to + // ensure that we properly initialize each of these variables. + ArrayRef<VarDecl *> getInitRecipes() { + return ArrayRef<VarDecl *>{getTrailingObjects<VarDecl *>(), + getExprs().size()}; + } + + ArrayRef<VarDecl *> getInitRecipes() const { + return ArrayRef<VarDecl *>{getTrailingObjects<VarDecl *>(), + getExprs().size()}; + } + static OpenACCPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, - ArrayRef<Expr *> VarList, SourceLocation EndLoc); + ArrayRef<Expr *> VarList, ArrayRef<VarDecl *> InitRecipes, + SourceLocation EndLoc); + + size_t numTrailingObjects(OverloadToken<Expr *>) const { + return getExprs().size(); + } }; class OpenACCFirstPrivateClause final : public OpenACCClauseWithVarList, - private llvm::TrailingObjects<OpenACCFirstPrivateClause, Expr *> { + private llvm::TrailingObjects<OpenACCFirstPrivateClause, Expr *, + VarDecl *> { friend TrailingObjects; OpenACCFirstPrivateClause(SourceLocation BeginLoc, SourceLocation LParenLoc, - ArrayRef<Expr *> VarList, SourceLocation EndLoc) + ArrayRef<Expr *> VarList, + ArrayRef<VarDecl *> InitRecipes, + SourceLocation EndLoc) : OpenACCClauseWithVarList(OpenACCClauseKind::FirstPrivate, BeginLoc, LParenLoc, EndLoc) { - setExprs(getTrailingObjects(VarList.size()), VarList); + assert(VarList.size() == InitRecipes.size()); + setExprs(getTrailingObjects<Expr *>(VarList.size()), VarList); + llvm::uninitialized_copy(InitRecipes, getTrailingObjects<VarDecl *>()); } public: static bool classof(const OpenACCClause *C) { return C->getClauseKind() == OpenACCClauseKind::FirstPrivate; } + + // Gets a list of 'made up' `VarDecl` objects that can be used by codegen to + // ensure that we properly initialize each of these variables. + ArrayRef<VarDecl *> getInitRecipes() { + return ArrayRef<VarDecl *>{getTrailingObjects<VarDecl *>(), + getExprs().size()}; + } + + ArrayRef<VarDecl *> getInitRecipes() const { + return ArrayRef<VarDecl *>{getTrailingObjects<VarDecl *>(), + getExprs().size()}; + } + static OpenACCFirstPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, - ArrayRef<Expr *> VarList, SourceLocation EndLoc); + ArrayRef<Expr *> VarList, ArrayRef<VarDecl *> InitRecipes, + SourceLocation EndLoc); + + size_t numTrailingObjects(OverloadToken<Expr *>) const { + return getExprs().size(); + } }; class OpenACCDevicePtrClause final diff --git a/clang/include/clang/AST/TemplateBase.h b/clang/include/clang/AST/TemplateBase.h index b67036c..eb384ea 100644 --- a/clang/include/clang/AST/TemplateBase.h +++ b/clang/include/clang/AST/TemplateBase.h @@ -316,6 +316,8 @@ public: /// Determine whether this template argument is a pack expansion. bool isPackExpansion() const; + bool isConceptOrConceptTemplateParameter() const; + /// Retrieve the type for a type template argument. QualType getAsType() const { assert(getKind() == Type && "Unexpected kind"); diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 98810fb..12dce30 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -6762,10 +6762,10 @@ public: class AutoType : public DeducedType { friend class ASTContext; // ASTContext creates these - ConceptDecl *TypeConstraintConcept; + TemplateDecl *TypeConstraintConcept; AutoType(QualType DeducedAsType, AutoTypeKeyword Keyword, - TypeDependence ExtraDependence, QualType Canon, ConceptDecl *CD, + TypeDependence ExtraDependence, QualType Canon, TemplateDecl *CD, ArrayRef<TemplateArgument> TypeConstraintArgs); public: @@ -6774,7 +6774,7 @@ public: AutoTypeBits.NumArgs}; } - ConceptDecl *getTypeConstraintConcept() const { + TemplateDecl *getTypeConstraintConcept() const { return TypeConstraintConcept; } @@ -6797,7 +6797,7 @@ public: void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context); static void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, QualType Deduced, AutoTypeKeyword Keyword, - bool IsDependent, ConceptDecl *CD, + bool IsDependent, TemplateDecl *CD, ArrayRef<TemplateArgument> Arguments); static bool classof(const Type *T) { diff --git a/clang/include/clang/AST/TypeLoc.h b/clang/include/clang/AST/TypeLoc.h index be0bc89..52ef7ac 100644 --- a/clang/include/clang/AST/TypeLoc.h +++ b/clang/include/clang/AST/TypeLoc.h @@ -2284,7 +2284,7 @@ public: return nullptr; } - ConceptDecl *getNamedConcept() const { + TemplateDecl *getNamedConcept() const { if (const auto *CR = getConceptReference()) return CR->getNamedConcept(); return nullptr; diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 3114d11..3373e96 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -495,9 +495,9 @@ let Class = AutoType in { def : Property<"keyword", AutoTypeKeyword> { let Read = [{ node->getKeyword() }]; } - def : Property<"typeConstraintConcept", Optional<ConceptDeclRef>> { + def : Property<"typeConstraintConcept", Optional<TemplateDeclRef>> { let Read = [{ makeOptionalFromPointer( - const_cast<const ConceptDecl*>(node->getTypeConstraintConcept())) }]; + node->getTypeConstraintConcept()) }]; } def : Property<"typeConstraintArguments", Array<TemplateArgument>> { let Read = [{ node->getTypeConstraintArguments() }]; diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index b3ff45b..63fa6aa 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -1059,22 +1059,13 @@ def AVRSignal : InheritableAttr, TargetSpecificAttr<TargetAVR> { def AsmLabel : InheritableAttr { let Spellings = [CustomKeyword<"asm">, CustomKeyword<"__asm__">]; let Args = [ - // Label specifies the mangled name for the decl. - StringArgument<"Label">, - - // IsLiteralLabel specifies whether the label is literal (i.e. suppresses - // the global C symbol prefix) or not. If not, the mangle-suppression prefix - // ('\01') is omitted from the decl name at the LLVM IR level. - // - // Non-literal labels are used by some external AST sources like LLDB. - BoolArgument<"IsLiteralLabel", /*optional=*/0, /*fake=*/1> - ]; + // Label specifies the mangled name for the decl. + StringArgument<"Label">, ]; let SemaHandler = 0; let Documentation = [AsmLabelDocs]; - let AdditionalMembers = -[{ + let AdditionalMembers = [{ bool isEquivalent(AsmLabelAttr *Other) const { - return getLabel() == Other->getLabel() && getIsLiteralLabel() == Other->getIsLiteralLabel(); + return getLabel() == Other->getLabel(); } }]; } @@ -2361,6 +2352,7 @@ def RISCVInterrupt : InheritableAttr, TargetSpecificAttr<TargetRISCV> { [ "supervisor", "machine", + "rnmi", "qci-nest", "qci-nonest", "SiFive-CLIC-preemptible", @@ -2369,6 +2361,7 @@ def RISCVInterrupt : InheritableAttr, TargetSpecificAttr<TargetRISCV> { [ "supervisor", "machine", + "rnmi", "qcinest", "qcinonest", "SiFiveCLICPreemptible", diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 76747d2..326cf0b 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -2905,10 +2905,13 @@ the backend to generate appropriate function entry/exit code so that it can be used directly as an interrupt service routine. Permissible values for this parameter are ``machine``, ``supervisor``, -``qci-nest``, ``qci-nonest``, ``SiFive-CLIC-preemptible``, and +``rnmi``, ``qci-nest``, ``qci-nonest``, ``SiFive-CLIC-preemptible``, and ``SiFive-CLIC-stack-swap``. If there is no parameter, then it defaults to ``machine``. +The ``rnmi`` value is used for resumable non-maskable interrupts. It requires the +standard Smrnmi extension. + The ``qci-nest`` and ``qci-nonest`` values require Qualcomm's Xqciint extension and are used for Machine-mode Interrupts and Machine-mode Non-maskable interrupts. These use the following instructions from Xqciint to save and diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def b/clang/include/clang/Basic/BuiltinsAMDGPU.def index ced758c..b16d4a2 100644 --- a/clang/include/clang/Basic/BuiltinsAMDGPU.def +++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def @@ -163,6 +163,16 @@ BUILTIN(__builtin_amdgcn_raw_buffer_load_b64, "V2UiQbiiIi", "n") BUILTIN(__builtin_amdgcn_raw_buffer_load_b96, "V3UiQbiiIi", "n") BUILTIN(__builtin_amdgcn_raw_buffer_load_b128, "V4UiQbiiIi", "n") +BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_add_i32, "iiQbiiIi", "t") + +TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fadd_f32, "ffQbiiIi", "t", "atomic-fadd-rtn-insts") +TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fadd_v2f16, "V2hV2hQbiiIi", "t", "atomic-buffer-global-pk-add-f16-insts") + +TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fmin_f32, "ffQbiiIi", "t", "atomic-fmin-fmax-global-f32") +TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fmax_f32, "ffQbiiIi", "t", "atomic-fmin-fmax-global-f32") +TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fmin_f64, "ddQbiiIi", "t", "atomic-fmin-fmax-global-f64") +TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fmax_f64, "ddQbiiIi", "t", "atomic-fmin-fmax-global-f64") + TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_load_lds, "vQbv*3IUiiiIiIi", "t", "vmem-to-lds-load-insts") TARGET_BUILTIN(__builtin_amdgcn_struct_ptr_buffer_load_lds, "vQbv*3IUiiiiIiIi", "t", "vmem-to-lds-load-insts") @@ -790,9 +800,13 @@ TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x128_fp8_fp8, "V8fV16iV16iIsV8fIbI TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x128_fp8_bf8, "V8fV16iV16iIsV8fIbIb", "nc", "gfx1250-insts,wavefrontsize32") TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x128_bf8_fp8, "V8fV16iV16iIsV8fIbIb", "nc", "gfx1250-insts,wavefrontsize32") TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x128_bf8_bf8, "V8fV16iV16iIsV8fIbIb", "nc", "gfx1250-insts,wavefrontsize32") +TARGET_BUILTIN(__builtin_amdgcn_wmma_scale_f32_16x16x128_f8f6f4, "V8fIiV16iIiV16iIsV8fIiIiiIiIiiIbIb", "nc", "gfx1250-insts,wavefrontsize32") +TARGET_BUILTIN(__builtin_amdgcn_wmma_scale16_f32_16x16x128_f8f6f4, "V8fIiV16iIiV16iIsV8fIiIiLiIiIiLiIbIb", "nc", "gfx1250-insts,wavefrontsize32") TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x32_f16, "V8fIbV16hIbV16hIsV8fIbIb", "nc", "gfx1250-insts,wavefrontsize32") TARGET_BUILTIN(__builtin_amdgcn_wmma_f16_16x16x32_f16, "V8hIbV16hIbV16hIsV8hIbIb", "nc", "gfx1250-insts,wavefrontsize32") TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_32x16x128_f4, "V16fV16iV8iIsV16f", "nc", "gfx1250-insts,wavefrontsize32") +TARGET_BUILTIN(__builtin_amdgcn_wmma_scale_f32_32x16x128_f4, "V16fV16iV8iIsV16fIiIiiIiIiiIbIb", "nc", "gfx1250-insts,wavefrontsize32") +TARGET_BUILTIN(__builtin_amdgcn_wmma_scale16_f32_32x16x128_f4, "V16fV16iV8iIsV16fIiIiLiIiIiLiIbIb", "nc", "gfx1250-insts,wavefrontsize32") TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x64_bf16, "V8fIbV16yIbV32yV8fiIbIb", "nc", "gfx1250-insts,wavefrontsize32") TARGET_BUILTIN(__builtin_amdgcn_swmmac_bf16_16x16x64_bf16, "V8yIbV16yIbV32yV8yiIbIb", "nc", "gfx1250-insts,wavefrontsize32") TARGET_BUILTIN(__builtin_amdgcn_swmmac_bf16f32_16x16x64_bf16, "V8fIbV16yIbV32yV8fiIbIb", "nc", "gfx1250-insts,wavefrontsize32") diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index 759ba04..0f17f4a 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -394,6 +394,8 @@ def warn_drv_fraw_string_literals_in_cxx11 : Warning< "ignoring '-f%select{no-|}0raw-string-literals', which is only valid for C and C++ standards before C++11">, InGroup<UnusedCommandLineArgument>; +def err_drv_libclc_not_found : Error<"no libclc library '%0' found in the clang resource directory">; + def err_drv_invalid_malign_branch_EQ : Error< "invalid argument '%0' to -malign-branch=; each element must be one of: %1">; diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index 165f015..0042afc 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -931,6 +931,10 @@ def err_missing_dependent_template_keyword : Error< def warn_missing_dependent_template_keyword : ExtWarn< "use 'template' keyword to treat '%0' as a dependent template name">; +def err_cxx26_template_template_params + : Error<"%select{variable template|concept}0 template parameter is a C++2c " + "extension">; + def ext_extern_template : Extension< "extern templates are a C++11 extension">, InGroup<CXX11>; def warn_cxx98_compat_extern_template : Warning< diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 94b174c..f903b7f 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -1812,7 +1812,10 @@ def note_unsatisfied_trait_reason "%DeletedAssign{has a deleted %select{copy|move}1 " "assignment operator}|" "%UnionWithUserDeclaredSMF{is a union with a user-declared " - "%sub{select_special_member_kind}1}" + "%sub{select_special_member_kind}1}|" + "%FunctionType{is a function type}|" + "%CVVoidType{is a cv void type}|" + "%IncompleteArrayType{is an incomplete array type}" "}0">; def warn_consteval_if_always_true : Warning< @@ -5438,8 +5441,10 @@ def err_template_arg_must_be_expr : Error< "template argument for non-type template parameter must be an expression">; def err_template_arg_nontype_ambig : Error< "template argument for non-type template parameter is treated as function type %0">; -def err_template_arg_must_be_template : Error< - "template argument for template template parameter must be a class template%select{| or type alias template}0">; +def err_template_arg_must_be_template + : Error<"template argument for template template parameter must be a " + "%select{class template%select{| or type alias template}1|variable " + "template|concept}0">; def ext_template_arg_local_type : ExtWarn< "template argument uses local type %0">, InGroup<LocalTypeTemplateArgs>; def ext_template_arg_unnamed_type : ExtWarn< @@ -5454,11 +5459,14 @@ def note_template_unnamed_type_here : Note< "unnamed type used in template argument was declared here">; def err_template_arg_overload_type : Error< "template argument is the type of an unresolved overloaded function">; -def err_template_arg_not_valid_template : Error< - "template argument does not refer to a class or alias template, or template " - "template parameter">; -def note_template_arg_refers_here_func : Note< - "template argument refers to function template %0, here">; +def err_template_arg_not_valid_template + : Error<"template argument does not refer to a %select{class or alias " + "template|variable template|concept}0, or template " + "template parameter">; + +def note_template_arg_refers_to_template_here + : Note<"template argument refers to a %select{function template|class " + "template|variable template|concept}0 %1, here">; def err_template_arg_template_params_mismatch : Error< "template template argument has different template parameters than its " "corresponding template template parameter">; @@ -13526,7 +13534,8 @@ def err_acc_device_type_multiple_archs def warn_acc_var_referenced_lacks_op : Warning<"variable of type %0 referenced in OpenACC '%1' clause does not " "have a %enum_select<AccVarReferencedReason>{%DefCtor{default " - "constructor}|%Dtor{destructor}}2; reference has no effect">, + "constructor}|%CopyCtor{copy constructor}|%Dtor{destructor}}2; " + "reference has no effect">, InGroup<DiagGroup<"openacc-var-lacks-operation">>, DefaultError; diff --git a/clang/include/clang/Driver/CommonArgs.h b/clang/include/clang/Driver/CommonArgs.h index 49c7149..9802962d 100644 --- a/clang/include/clang/Driver/CommonArgs.h +++ b/clang/include/clang/Driver/CommonArgs.h @@ -215,6 +215,9 @@ void addOpenMPDeviceRTL(const Driver &D, const llvm::opt::ArgList &DriverArgs, StringRef BitcodeSuffix, const llvm::Triple &Triple, const ToolChain &HostTC); +void addOpenCLBuiltinsLib(const Driver &D, const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args); + void addOutlineAtomicsArgs(const Driver &D, const ToolChain &TC, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 3c04aeb..6aab43c 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1422,6 +1422,21 @@ def fno_hip_emit_relocatable : Flag<["-"], "fno-hip-emit-relocatable">, HelpText<"Do not override toolchain to compile HIP source to relocatable">; } +// Clang specific/exclusive options for OpenACC. +def openacc_macro_override + : Separate<["-"], "fexperimental-openacc-macro-override">, + Visibility<[ClangOption, CC1Option]>, + Group<f_Group>, + HelpText<"Overrides the _OPENACC macro value for experimental testing " + "during OpenACC support development">; +def openacc_macro_override_EQ + : Joined<["-"], "fexperimental-openacc-macro-override=">, + Alias<openacc_macro_override>; + +// End Clang specific/exclusive options for OpenACC. + +def libclc_lib_EQ : Joined<["--"], "libclc-lib=">, Group<opencl_Group>, + HelpText<"Namespec of libclc OpenCL bitcode library to link">; def libomptarget_amdgpu_bc_path_EQ : Joined<["--"], "libomptarget-amdgpu-bc-path=">, Group<i_Group>, HelpText<"Path to libomptarget-amdgcn bitcode library">; def libomptarget_amdgcn_bc_path_EQ : Joined<["--"], "libomptarget-amdgcn-bc-path=">, Group<i_Group>, diff --git a/clang/include/clang/Sema/Initialization.h b/clang/include/clang/Sema/Initialization.h index a1c156e..d7675ea 100644 --- a/clang/include/clang/Sema/Initialization.h +++ b/clang/include/clang/Sema/Initialization.h @@ -159,8 +159,9 @@ private: }; struct VD { - /// The VarDecl, FieldDecl, or BindingDecl being initialized. - ValueDecl *VariableOrMember; + /// The VarDecl, FieldDecl, TemplateParmDecl, or BindingDecl being + /// initialized. + NamedDecl *VariableOrMember; /// When Kind == EK_Member, whether this is an implicit member /// initialization in a copy or move constructor. These can perform array @@ -291,8 +292,8 @@ public: } /// Create the initialization entity for a template parameter. - static InitializedEntity - InitializeTemplateParameter(QualType T, NonTypeTemplateParmDecl *Param) { + static InitializedEntity InitializeTemplateParameter(QualType T, + NamedDecl *Param) { InitializedEntity Entity; Entity.Kind = EK_TemplateParameter; Entity.Type = T; diff --git a/clang/include/clang/Sema/Ownership.h b/clang/include/clang/Sema/Ownership.h index 0752f5d..b152083 100644 --- a/clang/include/clang/Sema/Ownership.h +++ b/clang/include/clang/Sema/Ownership.h @@ -13,6 +13,7 @@ #ifndef LLVM_CLANG_SEMA_OWNERSHIP_H #define LLVM_CLANG_SEMA_OWNERSHIP_H +#include "clang/AST/DeclTemplate.h" #include "clang/AST/Expr.h" #include "clang/Basic/LLVM.h" #include "llvm/ADT/ArrayRef.h" diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 0b2c027..5211373 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -11458,7 +11458,7 @@ public: /// of arguments for the named concept). bool AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, - ConceptDecl *NamedConcept, NamedDecl *FoundDecl, + TemplateDecl *NamedConcept, NamedDecl *FoundDecl, const TemplateArgumentListInfo *TemplateArgs, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc); @@ -11491,8 +11491,9 @@ public: /// parameter (e.g. T in template <template \<typename> class T> class array) /// has been parsed. S is the current scope. NamedDecl *ActOnTemplateTemplateParameter( - Scope *S, SourceLocation TmpLoc, TemplateParameterList *Params, - bool Typename, SourceLocation EllipsisLoc, IdentifierInfo *ParamName, + Scope *S, SourceLocation TmpLoc, TemplateNameKind Kind, + bool TypenameKeyword, TemplateParameterList *Params, + SourceLocation EllipsisLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg); @@ -11660,6 +11661,11 @@ public: SourceLocation TemplateLoc, const TemplateArgumentListInfo *TemplateArgs); + ExprResult CheckVarOrConceptTemplateTemplateId( + const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, + TemplateTemplateParmDecl *Template, SourceLocation TemplateLoc, + const TemplateArgumentListInfo *TemplateArgs); + ExprResult CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &ConceptNameInfo, @@ -11996,7 +12002,7 @@ public: /// If an error occurred, it returns ExprError(); otherwise, it /// returns the converted template argument. \p ParamType is the /// type of the non-type template parameter after it has been instantiated. - ExprResult CheckTemplateArgument(NonTypeTemplateParmDecl *Param, + ExprResult CheckTemplateArgument(NamedDecl *Param, QualType InstantiatedParamType, Expr *Arg, TemplateArgument &SugaredConverted, TemplateArgument &CanonicalConverted, @@ -12014,6 +12020,10 @@ public: bool PartialOrdering, bool *StrictPackMatch); + bool CheckDeclCompatibleWithTemplateTemplate(TemplateDecl *Template, + TemplateTemplateParmDecl *Param, + const TemplateArgumentLoc &Arg); + void NoteTemplateLocation(const NamedDecl &Decl, std::optional<SourceRange> ParamRange = {}); void NoteTemplateParameterLocation(const NamedDecl &Decl); @@ -12290,7 +12300,7 @@ public: void CheckConceptRedefinition(ConceptDecl *NewDecl, LookupResult &Previous, bool &AddToScope); - bool CheckConceptUseInDefinition(ConceptDecl *Concept, SourceLocation Loc); + bool CheckConceptUseInDefinition(NamedDecl *Concept, SourceLocation Loc); TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, const CXXScopeSpec &SS, diff --git a/clang/include/clang/Sema/SemaInternal.h b/clang/include/clang/Sema/SemaInternal.h index 4d0da11..42c9469 100644 --- a/clang/include/clang/Sema/SemaInternal.h +++ b/clang/include/clang/Sema/SemaInternal.h @@ -15,6 +15,7 @@ #define LLVM_CLANG_SEMA_SEMAINTERNAL_H #include "clang/AST/ASTContext.h" +#include "clang/AST/DeclTemplate.h" #include "clang/Sema/Lookup.h" #include "clang/Sema/Sema.h" #include "clang/Sema/SemaDiagnostic.h" diff --git a/clang/include/clang/Sema/SemaOpenACC.h b/clang/include/clang/Sema/SemaOpenACC.h index b7e7f5d..964749c 100644 --- a/clang/include/clang/Sema/SemaOpenACC.h +++ b/clang/include/clang/Sema/SemaOpenACC.h @@ -176,10 +176,6 @@ private: void checkFor(); - // void checkRangeFor(); ?? ERICH - // const ValueDecl *checkInit(); - // void checkCond(const ValueDecl *Init); - // void checkInc(const ValueDecl *Init); public: // Checking for non-instantiation version of a Range-for. ForStmtBeginChecker(SemaOpenACC &SemaRef, SourceLocation ForLoc, @@ -241,6 +237,11 @@ public: SourceLocation ClauseLoc, ArrayRef<const OpenACCClause *> Clauses); + // Creates a VarDecl with a proper default init for the purposes of a + // `private`/'firstprivate'/'reduction' clause, so it can be used to generate + // a recipe later. + VarDecl *CreateInitRecipe(OpenACCClauseKind CK, const Expr *VarExpr); + public: ComputeConstructInfo &getActiveComputeConstructInfo() { return ActiveComputeConstructInfo; diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td index 36196cd..73f702d 100644 --- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td +++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td @@ -297,6 +297,11 @@ def StackAddrAsyncEscapeChecker "Check that addresses to stack memory do not escape the function">, Documentation<HasDocumentation>; +def StoreToImmutableChecker : Checker<"StoreToImmutable">, + HelpText<"Check for writes to immutable memory regions. " + "This implements part of SEI CERT Rule ENV30-C.">, + Documentation<HasDocumentation>; + def PthreadLockBase : Checker<"PthreadLockBase">, HelpText<"Helper registering multiple checks.">, Documentation<NotDocumented>, |