diff options
Diffstat (limited to 'clang/include')
62 files changed, 930 insertions, 423 deletions
diff --git a/clang/include/clang/APINotes/Types.h b/clang/include/clang/APINotes/Types.h index d9bf2f07291f..0d97e9ad8623 100644 --- a/clang/include/clang/APINotes/Types.h +++ b/clang/include/clang/APINotes/Types.h @@ -240,7 +240,7 @@ public: } void setSwiftImportAsNonGeneric(llvm::Optional<bool> Value) { SwiftImportAsNonGenericSpecified = Value.hasValue(); - SwiftImportAsNonGeneric = Value.hasValue() ? *Value : false; + SwiftImportAsNonGeneric = Value.getValueOr(false); } llvm::Optional<bool> getSwiftObjCMembers() const { @@ -249,7 +249,7 @@ public: } void setSwiftObjCMembers(llvm::Optional<bool> Value) { SwiftObjCMembersSpecified = Value.hasValue(); - SwiftObjCMembers = Value.hasValue() ? *Value : false; + SwiftObjCMembers = Value.getValueOr(false); } /// Strip off any information within the class information structure that is @@ -368,7 +368,7 @@ public: } void setSwiftImportAsAccessors(llvm::Optional<bool> Value) { SwiftImportAsAccessorsSpecified = Value.hasValue(); - SwiftImportAsAccessors = Value.hasValue() ? *Value : false; + SwiftImportAsAccessors = Value.getValueOr(false); } friend bool operator==(const ObjCPropertyInfo &, const ObjCPropertyInfo &); @@ -433,7 +433,7 @@ public: } void setNoEscape(llvm::Optional<bool> Value) { NoEscapeSpecified = Value.hasValue(); - NoEscape = Value.hasValue() ? *Value : false; + NoEscape = Value.getValueOr(false); } llvm::Optional<RetainCountConventionKind> getRetainCountConvention() const { @@ -671,7 +671,7 @@ public: } void setFlagEnum(llvm::Optional<bool> Value) { HasFlagEnum = Value.hasValue(); - IsFlagEnum = Value.hasValue() ? *Value : false; + IsFlagEnum = Value.getValueOr(false); } TagInfo &operator|=(const TagInfo &RHS) { diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index d336342e4cda..63f2c948c79b 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -248,6 +248,7 @@ class ASTContext : public RefCountedBase<ASTContext> { mutable llvm::ContextualFoldingSet<TemplateSpecializationType, ASTContext&> TemplateSpecializationTypes; mutable llvm::FoldingSet<ParenType> ParenTypes; + mutable llvm::FoldingSet<UsingType> UsingTypes; mutable llvm::FoldingSet<ElaboratedType> ElaboratedTypes; mutable llvm::FoldingSet<DependentNameType> DependentNameTypes; mutable llvm::ContextualFoldingSet<DependentTemplateSpecializationType, @@ -264,8 +265,8 @@ class ASTContext : public RefCountedBase<ASTContext> { mutable llvm::FoldingSet<AtomicType> AtomicTypes; llvm::FoldingSet<AttributedType> AttributedTypes; mutable llvm::FoldingSet<PipeType> PipeTypes; - mutable llvm::FoldingSet<ExtIntType> ExtIntTypes; - mutable llvm::FoldingSet<DependentExtIntType> DependentExtIntTypes; + mutable llvm::FoldingSet<BitIntType> BitIntTypes; + mutable llvm::FoldingSet<DependentBitIntType> DependentBitIntTypes; mutable llvm::FoldingSet<QualifiedTemplateName> QualifiedTemplateNames; mutable llvm::FoldingSet<DependentTemplateName> DependentTemplateNames; @@ -1350,13 +1351,13 @@ public: /// Return a write_only pipe type for the specified type. QualType getWritePipeType(QualType T) const; - /// Return an extended integer type with the specified signedness and bit + /// Return a bit-precise integer type with the specified signedness and bit /// count. - QualType getExtIntType(bool Unsigned, unsigned NumBits) const; + QualType getBitIntType(bool Unsigned, unsigned NumBits) const; - /// Return a dependent extended integer type with the specified signedness and - /// bit count. - QualType getDependentExtIntType(bool Unsigned, Expr *BitsExpr) const; + /// Return a dependent bit-precise integer type with the specified signedness + /// and bit count. + QualType getDependentBitIntType(bool Unsigned, Expr *BitsExpr) const; /// Gets the struct used to keep track of the extended descriptor for /// pointer to blocks. @@ -1555,6 +1556,9 @@ public: return getTypeDeclTypeSlow(Decl); } + QualType getUsingType(const UsingShadowDecl *Found, + QualType Underlying) const; + /// Return the unique reference to the type for the specified /// typedef-name decl. QualType getTypedefType(const TypedefNameDecl *Decl, @@ -1564,6 +1568,9 @@ public: QualType getEnumType(const EnumDecl *Decl) const; + QualType + getUnresolvedUsingType(const UnresolvedUsingTypenameDecl *Decl) const; + QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const; QualType getAttributedType(attr::Kind attrKind, diff --git a/clang/include/clang/AST/ASTDiagnostic.h b/clang/include/clang/AST/ASTDiagnostic.h index d6549e12d92a..4cd909751725 100644 --- a/clang/include/clang/AST/ASTDiagnostic.h +++ b/clang/include/clang/AST/ASTDiagnostic.h @@ -9,6 +9,7 @@ #ifndef LLVM_CLANG_AST_ASTDIAGNOSTIC_H #define LLVM_CLANG_AST_ASTDIAGNOSTIC_H +#include "clang/AST/Type.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/DiagnosticAST.h" @@ -31,6 +32,11 @@ namespace clang { SmallVectorImpl<char> &Output, void *Cookie, ArrayRef<intptr_t> QualTypeVals); + + /// Returns a desugared version of the QualType, and marks ShouldAKA as true + /// whenever we remove significant sugar from the type. + QualType desugarForDiagnostic(ASTContext &Context, QualType QT, + bool &ShouldAKA); } // end namespace clang #endif diff --git a/clang/include/clang/AST/ASTImporterLookupTable.h b/clang/include/clang/AST/ASTImporterLookupTable.h index 47dca2033839..918c2b9e350c 100644 --- a/clang/include/clang/AST/ASTImporterLookupTable.h +++ b/clang/include/clang/AST/ASTImporterLookupTable.h @@ -75,6 +75,10 @@ public: // The function should be called when the old context is definitely different // from the new. void update(NamedDecl *ND, DeclContext *OldDC); + // Same as 'update' but allow if 'ND' is not in the table or the old context + // is the same as the new. + // FIXME: The old redeclaration context is not handled. + void updateForced(NamedDecl *ND, DeclContext *OldDC); using LookupResult = DeclList; LookupResult lookup(DeclContext *DC, DeclarationName Name) const; // Check if the `ND` is within the lookup table (with its current name) in diff --git a/clang/include/clang/AST/AbstractBasicReader.h b/clang/include/clang/AST/AbstractBasicReader.h index 5505d661b44e..442039044cfe 100644 --- a/clang/include/clang/AST/AbstractBasicReader.h +++ b/clang/include/clang/AST/AbstractBasicReader.h @@ -21,7 +21,7 @@ inline T makeNullableFromOptional(const Optional<T> &value) { template <class T> inline T *makePointerFromOptional(Optional<T *> value) { - return (value ? *value : nullptr); + return value.getValueOr(nullptr); } // PropertyReader is a class concept that requires the following method: diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index d33babef958e..f7a2e3146d06 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -1211,13 +1211,12 @@ class TemplateTypeParmDecl final : public TypeDecl, DefArgStorage DefaultArgument; TemplateTypeParmDecl(DeclContext *DC, SourceLocation KeyLoc, - SourceLocation IdLoc, IdentifierInfo *Id, - bool Typename, bool HasTypeConstraint, - Optional<unsigned> NumExpanded) + SourceLocation IdLoc, IdentifierInfo *Id, bool Typename, + bool HasTypeConstraint, Optional<unsigned> NumExpanded) : TypeDecl(TemplateTypeParm, DC, IdLoc, Id, KeyLoc), Typename(Typename), - HasTypeConstraint(HasTypeConstraint), TypeConstraintInitialized(false), - ExpandedParameterPack(NumExpanded), - NumExpanded(NumExpanded ? *NumExpanded : 0) {} + HasTypeConstraint(HasTypeConstraint), TypeConstraintInitialized(false), + ExpandedParameterPack(NumExpanded), + NumExpanded(NumExpanded.getValueOr(0)) {} public: static TemplateTypeParmDecl *Create(const ASTContext &C, DeclContext *DC, diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index 2c63406fba18..e2c36e12393f 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -572,6 +572,12 @@ public: bool isConstantInitializer(ASTContext &Ctx, bool ForRef, const Expr **Culprit = nullptr) const; + /// If this expression is an unambiguous reference to a single declaration, + /// in the style of __builtin_function_start, return that declaration. Note + /// that this may return a non-static member function or field in C++ if this + /// expression is a member pointer constant. + const ValueDecl *getAsBuiltinConstantDeclRef(const ASTContext &Context) const; + /// EvalStatus is a struct with detailed info about an evaluation in progress. struct EvalStatus { /// Whether the evaluated expression has side effects. diff --git a/clang/include/clang/AST/OpenMPClause.h b/clang/include/clang/AST/OpenMPClause.h index 565eb0c9cf99..3fd1b6d30080 100644 --- a/clang/include/clang/AST/OpenMPClause.h +++ b/clang/include/clang/AST/OpenMPClause.h @@ -2224,6 +2224,47 @@ public: } }; +/// This represents 'compare' clause in the '#pragma omp atomic' +/// directive. +/// +/// \code +/// #pragma omp atomic compare +/// \endcode +/// In this example directive '#pragma omp atomic' has 'compare' clause. +class OMPCompareClause final : public OMPClause { +public: + /// Build 'compare' clause. + /// + /// \param StartLoc Starting location of the clause. + /// \param EndLoc Ending location of the clause. + OMPCompareClause(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPClause(llvm::omp::OMPC_compare, StartLoc, EndLoc) {} + + /// Build an empty clause. + OMPCompareClause() + : OMPClause(llvm::omp::OMPC_compare, SourceLocation(), SourceLocation()) { + } + + child_range children() { + return child_range(child_iterator(), child_iterator()); + } + + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + + child_range used_children() { + return child_range(child_iterator(), child_iterator()); + } + const_child_range used_children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + + static bool classof(const OMPClause *T) { + return T->getClauseKind() == llvm::omp::OMPC_compare; + } +}; + /// This represents 'seq_cst' clause in the '#pragma omp atomic' /// directive. /// diff --git a/clang/include/clang/AST/PropertiesBase.td b/clang/include/clang/AST/PropertiesBase.td index a087cb406b29..9282b24eb68c 100644 --- a/clang/include/clang/AST/PropertiesBase.td +++ b/clang/include/clang/AST/PropertiesBase.td @@ -107,6 +107,8 @@ def DeclRef : RefPropertyType<"Decl"> { let ConstWhenWriting = 1; } SubclassPropertyType<"TemplateTypeParmDecl", DeclRef>; def TemplateTemplateParmDeclRef : SubclassPropertyType<"TemplateTemplateParmDecl", DeclRef>; + def UsingShadowDeclRef : + SubclassPropertyType<"UsingShadowDecl", DeclRef>; def ValueDeclRef : SubclassPropertyType<"ValueDecl", DeclRef>; def ElaboratedTypeKeyword : EnumPropertyType; diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h index 9797eac53dde..f62dc36de556 100644 --- a/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/clang/include/clang/AST/RecursiveASTVisitor.h @@ -981,6 +981,7 @@ DEF_TRAVERSE_TYPE(FunctionProtoType, { TRY_TO(TraverseStmt(NE)); }) +DEF_TRAVERSE_TYPE(UsingType, {}) DEF_TRAVERSE_TYPE(UnresolvedUsingType, {}) DEF_TRAVERSE_TYPE(TypedefType, {}) @@ -1072,8 +1073,8 @@ DEF_TRAVERSE_TYPE(AtomicType, { TRY_TO(TraverseType(T->getValueType())); }) DEF_TRAVERSE_TYPE(PipeType, { TRY_TO(TraverseType(T->getElementType())); }) -DEF_TRAVERSE_TYPE(ExtIntType, {}) -DEF_TRAVERSE_TYPE(DependentExtIntType, +DEF_TRAVERSE_TYPE(BitIntType, {}) +DEF_TRAVERSE_TYPE(DependentBitIntType, { TRY_TO(TraverseStmt(T->getNumBitsExpr())); }) #undef DEF_TRAVERSE_TYPE @@ -1252,6 +1253,7 @@ DEF_TRAVERSE_TYPELOC(FunctionProtoType, { TRY_TO(TraverseStmt(NE)); }) +DEF_TRAVERSE_TYPELOC(UsingType, {}) DEF_TRAVERSE_TYPELOC(UnresolvedUsingType, {}) DEF_TRAVERSE_TYPELOC(TypedefType, {}) @@ -1358,8 +1360,8 @@ DEF_TRAVERSE_TYPELOC(AtomicType, { TRY_TO(TraverseTypeLoc(TL.getValueLoc())); }) DEF_TRAVERSE_TYPELOC(PipeType, { TRY_TO(TraverseTypeLoc(TL.getValueLoc())); }) -DEF_TRAVERSE_TYPELOC(ExtIntType, {}) -DEF_TRAVERSE_TYPELOC(DependentExtIntType, { +DEF_TRAVERSE_TYPELOC(BitIntType, {}) +DEF_TRAVERSE_TYPELOC(DependentBitIntType, { TRY_TO(TraverseStmt(TL.getTypePtr()->getNumBitsExpr())); }) @@ -2095,7 +2097,13 @@ bool RecursiveASTVisitor<Derived>::TraverseFunctionHelper(FunctionDecl *D) { } if (VisitBody) { - TRY_TO(TraverseStmt(D->getBody())); // Function body. + TRY_TO(TraverseStmt(D->getBody())); + // Body may contain using declarations whose shadows are parented to the + // FunctionDecl itself. + for (auto *Child : D->decls()) { + if (isa<UsingShadowDecl>(Child)) + TRY_TO(TraverseDecl(Child)); + } } return true; } @@ -3227,6 +3235,11 @@ bool RecursiveASTVisitor<Derived>::VisitOMPCaptureClause(OMPCaptureClause *) { } template <typename Derived> +bool RecursiveASTVisitor<Derived>::VisitOMPCompareClause(OMPCompareClause *) { + return true; +} + +template <typename Derived> bool RecursiveASTVisitor<Derived>::VisitOMPSeqCstClause(OMPSeqCstClause *) { return true; } diff --git a/clang/include/clang/AST/TextNodeDumper.h b/clang/include/clang/AST/TextNodeDumper.h index 0eb0031de11f..41bbf2ec593a 100644 --- a/clang/include/clang/AST/TextNodeDumper.h +++ b/clang/include/clang/AST/TextNodeDumper.h @@ -311,6 +311,7 @@ public: void VisitFunctionType(const FunctionType *T); void VisitFunctionProtoType(const FunctionProtoType *T); void VisitUnresolvedUsingType(const UnresolvedUsingType *T); + void VisitUsingType(const UsingType *T); void VisitTypedefType(const TypedefType *T); void VisitUnaryTransformType(const UnaryTransformType *T); void VisitTagType(const TagType *T); diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 4c89c297bf34..a69c0ae67d0a 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -129,6 +129,7 @@ class TemplateArgumentLoc; class TemplateTypeParmDecl; class TypedefNameDecl; class UnresolvedUsingTypenameDecl; +class UsingShadowDecl; using CanQualType = CanQual<Type>; @@ -2128,7 +2129,7 @@ public: bool isOCLExtOpaqueType() const; // Any OpenCL extension type bool isPipeType() const; // OpenCL pipe type - bool isExtIntType() const; // Extended Int Type + bool isBitIntType() const; // Bit-precise integer type bool isOpenCLSpecificType() const; // Any OpenCL specific type /// Determines if this type, which must satisfy @@ -4368,6 +4369,27 @@ public: } }; +class UsingType : public Type, public llvm::FoldingSetNode { + UsingShadowDecl *Found; + friend class ASTContext; // ASTContext creates these. + + UsingType(const UsingShadowDecl *Found, QualType Underlying, QualType Canon); + +public: + UsingShadowDecl *getFoundDecl() const { return Found; } + QualType getUnderlyingType() const; + + bool isSugared() const { return true; } + QualType desugar() const { return getUnderlyingType(); } + + void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, Found); } + static void Profile(llvm::FoldingSetNodeID &ID, + const UsingShadowDecl *Found) { + ID.AddPointer(Found); + } + static bool classof(const Type *T) { return T->getTypeClass() == Using; } +}; + class TypedefType : public Type { TypedefNameDecl *Decl; @@ -6307,13 +6329,13 @@ public: }; /// A fixed int type of a specified bitwidth. -class ExtIntType final : public Type, public llvm::FoldingSetNode { +class BitIntType final : public Type, public llvm::FoldingSetNode { friend class ASTContext; unsigned IsUnsigned : 1; unsigned NumBits : 24; protected: - ExtIntType(bool isUnsigned, unsigned NumBits); + BitIntType(bool isUnsigned, unsigned NumBits); public: bool isUnsigned() const { return IsUnsigned; } @@ -6333,16 +6355,16 @@ public: ID.AddInteger(NumBits); } - static bool classof(const Type *T) { return T->getTypeClass() == ExtInt; } + static bool classof(const Type *T) { return T->getTypeClass() == BitInt; } }; -class DependentExtIntType final : public Type, public llvm::FoldingSetNode { +class DependentBitIntType final : public Type, public llvm::FoldingSetNode { friend class ASTContext; const ASTContext &Context; llvm::PointerIntPair<Expr*, 1, bool> ExprAndUnsigned; protected: - DependentExtIntType(const ASTContext &Context, bool IsUnsigned, + DependentBitIntType(const ASTContext &Context, bool IsUnsigned, Expr *NumBits); public: @@ -6360,7 +6382,7 @@ public: bool IsUnsigned, Expr *NumBitsExpr); static bool classof(const Type *T) { - return T->getTypeClass() == DependentExtInt; + return T->getTypeClass() == DependentBitInt; } }; @@ -6891,8 +6913,8 @@ inline bool Type::isPipeType() const { return isa<PipeType>(CanonicalType); } -inline bool Type::isExtIntType() const { - return isa<ExtIntType>(CanonicalType); +inline bool Type::isBitIntType() const { + return isa<BitIntType>(CanonicalType); } #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ @@ -6998,7 +7020,7 @@ inline bool Type::isIntegerType() const { return IsEnumDeclComplete(ET->getDecl()) && !IsEnumDeclScoped(ET->getDecl()); } - return isExtIntType(); + return isBitIntType(); } inline bool Type::isFixedPointType() const { @@ -7056,7 +7078,7 @@ inline bool Type::isScalarType() const { isa<MemberPointerType>(CanonicalType) || isa<ComplexType>(CanonicalType) || isa<ObjCObjectPointerType>(CanonicalType) || - isExtIntType(); + isBitIntType(); } inline bool Type::isIntegralOrEnumerationType() const { @@ -7069,7 +7091,7 @@ inline bool Type::isIntegralOrEnumerationType() const { if (const auto *ET = dyn_cast<EnumType>(CanonicalType)) return IsEnumDeclComplete(ET->getDecl()); - return isExtIntType(); + return isBitIntType(); } inline bool Type::isBooleanType() const { diff --git a/clang/include/clang/AST/TypeLoc.h b/clang/include/clang/AST/TypeLoc.h index bb668c1980fe..7a036836e8c4 100644 --- a/clang/include/clang/AST/TypeLoc.h +++ b/clang/include/clang/AST/TypeLoc.h @@ -665,6 +665,16 @@ public: } }; +/// Wrapper for source info for types used via transparent aliases. +class UsingTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, + UsingTypeLoc, UsingType> { +public: + QualType getUnderlyingType() const { + return getTypePtr()->getUnderlyingType(); + } + UsingShadowDecl *getFoundDecl() const { return getTypePtr()->getFoundDecl(); } +}; + /// Wrapper for source info for typedefs. class TypedefTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, TypedefTypeLoc, @@ -2561,12 +2571,12 @@ inline T TypeLoc::getAsAdjusted() const { } return Cur.getAs<T>(); } -class ExtIntTypeLoc final - : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, ExtIntTypeLoc, - ExtIntType> {}; -class DependentExtIntTypeLoc final - : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, DependentExtIntTypeLoc, - DependentExtIntType> {}; +class BitIntTypeLoc final + : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, BitIntTypeLoc, + BitIntType> {}; +class DependentBitIntTypeLoc final + : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, DependentBitIntTypeLoc, + DependentBitIntType> {}; } // namespace clang diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 438d5af5a2e2..8cbb67589b94 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -358,7 +358,20 @@ let Class = UnresolvedUsingType in { } def : Creator<[{ - return ctx.getTypeDeclType(cast<UnresolvedUsingTypenameDecl>(declaration)); + return ctx.getUnresolvedUsingType(cast<UnresolvedUsingTypenameDecl>(declaration)); + }]>; +} + +let Class = UsingType in { + def : Property<"foundDeclaration", UsingShadowDeclRef> { + let Read = [{ node->getFoundDecl() }]; + } + def : Property<"underlyingType", QualType> { + let Read = [{ node->getUnderlyingType() }]; + } + + def : Creator<[{ + return ctx.getUsingType(foundDeclaration, underlyingType); }]>; } @@ -882,7 +895,7 @@ let Class = PipeType in { }]>; } -let Class = ExtIntType in { +let Class = BitIntType in { def : Property<"isUnsigned", Bool> { let Read = [{ node->isUnsigned() }]; } @@ -891,11 +904,11 @@ let Class = ExtIntType in { } def : Creator<[{ - return ctx.getExtIntType(isUnsigned, numBits); + return ctx.getBitIntType(isUnsigned, numBits); }]>; } -let Class = DependentExtIntType in { +let Class = DependentBitIntType in { def : Property<"isUnsigned", Bool> { let Read = [{ node->isUnsigned() }]; } @@ -903,6 +916,6 @@ let Class = DependentExtIntType in { let Read = [{ node->getNumBitsExpr() }]; } def : Creator<[{ - return ctx.getDependentExtIntType(isUnsigned, numBitsExpr); + return ctx.getDependentBitIntType(isUnsigned, numBitsExpr); }]>; } diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h index 5221d05477d0..55cce324b436 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -4128,25 +4128,34 @@ AST_MATCHER_P(DeclRefExpr, to, internal::Matcher<Decl>, InnerMatcher.matches(*DeclNode, Finder, Builder)); } -/// Matches a \c DeclRefExpr that refers to a declaration through a -/// specific using shadow declaration. +/// Matches if a node refers to a declaration through a specific +/// using shadow declaration. /// -/// Given +/// Examples: /// \code -/// namespace a { void f() {} } +/// namespace a { int f(); } /// using a::f; -/// void g() { -/// f(); // Matches this .. -/// a::f(); // .. but not this. -/// } +/// int x = f(); /// \endcode /// declRefExpr(throughUsingDecl(anything())) -/// matches \c f() -AST_MATCHER_P(DeclRefExpr, throughUsingDecl, - internal::Matcher<UsingShadowDecl>, InnerMatcher) { +/// matches \c f +/// +/// \code +/// namespace a { class X{}; } +/// using a::X; +/// X x; +/// \code +/// typeLoc(loc(usingType(throughUsingDecl(anything())))) +/// matches \c X +/// +/// Usable as: Matcher<DeclRefExpr>, Matcher<UsingType> +AST_POLYMORPHIC_MATCHER_P(throughUsingDecl, + AST_POLYMORPHIC_SUPPORTED_TYPES(DeclRefExpr, + UsingType), + internal::Matcher<UsingShadowDecl>, Inner) { const NamedDecl *FoundDecl = Node.getFoundDecl(); if (const UsingShadowDecl *UsingDecl = dyn_cast<UsingShadowDecl>(FoundDecl)) - return InnerMatcher.matches(*UsingDecl, Finder, Builder); + return Inner.matches(*UsingDecl, Finder, Builder); return false; } @@ -4872,7 +4881,7 @@ AST_POLYMORPHIC_MATCHER_P2(forEachArgumentWithParamType, } } - int ParamIndex = 0; + unsigned ParamIndex = 0; bool Matched = false; unsigned NumArgs = Node.getNumArgs(); if (FProto && FProto->isVariadic()) @@ -4886,7 +4895,7 @@ AST_POLYMORPHIC_MATCHER_P2(forEachArgumentWithParamType, // This test is cheaper compared to the big matcher in the next if. // Therefore, please keep this order. - if (FProto) { + if (FProto && FProto->getNumParams() > ParamIndex) { QualType ParamType = FProto->getParamType(ParamIndex); if (ParamMatcher.matches(ParamType, Finder, &ParamMatches)) { Result.addMatch(ParamMatches); @@ -6843,7 +6852,7 @@ extern const AstTypeMatcher<DecltypeType> decltypeType; AST_TYPE_TRAVERSE_MATCHER(hasDeducedType, getDeducedType, AST_POLYMORPHIC_SUPPORTED_TYPES(AutoType)); -/// Matches \c DecltypeType nodes to find out the underlying type. +/// Matches \c DecltypeType or \c UsingType nodes to find the underlying type. /// /// Given /// \code @@ -6853,9 +6862,10 @@ AST_TYPE_TRAVERSE_MATCHER(hasDeducedType, getDeducedType, /// decltypeType(hasUnderlyingType(isInteger())) /// matches the type of "a" /// -/// Usable as: Matcher<DecltypeType> +/// Usable as: Matcher<DecltypeType>, Matcher<UsingType> AST_TYPE_TRAVERSE_MATCHER(hasUnderlyingType, getUnderlyingType, - AST_POLYMORPHIC_SUPPORTED_TYPES(DecltypeType)); + AST_POLYMORPHIC_SUPPORTED_TYPES(DecltypeType, + UsingType)); /// Matches \c FunctionType nodes. /// @@ -7183,6 +7193,18 @@ AST_MATCHER_P(ElaboratedType, namesType, internal::Matcher<QualType>, return InnerMatcher.matches(Node.getNamedType(), Finder, Builder); } +/// Matches types specified through a using declaration. +/// +/// Given +/// \code +/// namespace a { struct S {}; } +/// using a::S; +/// S s; +/// \endcode +/// +/// \c usingType() matches the type of the variable declaration of \c s. +extern const AstTypeMatcher<UsingType> usingType; + /// Matches types that represent the result of substituting a type for a /// template type parameter. /// diff --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h index a77611001fb1..ab7a445dbcd4 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h +++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h @@ -1090,6 +1090,12 @@ private: if (const auto *S = dyn_cast<ElaboratedType>(&Node)) { return matchesSpecialized(S->desugar(), Finder, Builder); } + // Similarly types found via using declarations. + // These are *usually* meaningless sugar, and this matches the historical + // behavior prior to the introduction of UsingType. + if (const auto *S = dyn_cast<UsingType>(&Node)) { + return matchesSpecialized(S->desugar(), Finder, Builder); + } return false; } diff --git a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h index 4a58fe870944..a0ae44131b45 100644 --- a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h +++ b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h @@ -155,7 +155,7 @@ public: return false; // Ignore anonymous functions. - if (!dyn_cast_or_null<NamedDecl>(AC.getDecl())) + if (!isa_and_nonnull<NamedDecl>(AC.getDecl())) return false; SortedGraph = AC.getAnalysis<PostOrderCFGView>(); diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h index 69a5c2e47b66..4a3c0239f8e1 100644 --- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h +++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h @@ -15,11 +15,20 @@ #ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_DATAFLOWENVIRONMENT_H #define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_DATAFLOWENVIRONMENT_H +#include "clang/Analysis/FlowSensitive/DataflowLattice.h" + namespace clang { namespace dataflow { /// Holds the state of the program (store and heap) at a given program point. -class Environment {}; +class Environment { +public: + bool operator==(const Environment &) const { return true; } + + LatticeJoinEffect join(const Environment &) { + return LatticeJoinEffect::Unchanged; + } +}; } // namespace dataflow } // namespace clang diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowWorklist.h b/clang/include/clang/Analysis/FlowSensitive/DataflowWorklist.h index 90095735ad3d..52d84eb13c56 100644 --- a/clang/include/clang/Analysis/FlowSensitive/DataflowWorklist.h +++ b/clang/include/clang/Analysis/FlowSensitive/DataflowWorklist.h @@ -61,11 +61,12 @@ struct ReversePostOrderCompare { /// the same block multiple times at once. struct ForwardDataflowWorklist : DataflowWorklistBase<ReversePostOrderCompare, 20> { + ForwardDataflowWorklist(const CFG &Cfg, PostOrderCFGView *POV) + : DataflowWorklistBase(Cfg, POV, + ReversePostOrderCompare{POV->getComparator()}) {} + ForwardDataflowWorklist(const CFG &Cfg, AnalysisDeclContext &Ctx) - : DataflowWorklistBase( - Cfg, Ctx.getAnalysis<PostOrderCFGView>(), - ReversePostOrderCompare{ - Ctx.getAnalysis<PostOrderCFGView>()->getComparator()}) {} + : ForwardDataflowWorklist(Cfg, Ctx.getAnalysis<PostOrderCFGView>()) {} void enqueueSuccessors(const CFGBlock *Block) { for (auto B : Block->succs()) diff --git a/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h b/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h index 9448b911f471..6193b9860d33 100644 --- a/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h +++ b/clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h @@ -76,6 +76,24 @@ struct TypeErasedDataflowAnalysisState { Environment Env; }; +/// Transfers the state of a basic block by evaluating each of its statements in +/// the context of `Analysis` and the states of its predecessors that are +/// available in `BlockStates`. `HandleTransferredStmt` (if provided) will be +/// applied to each statement in the block, after it is evaluated. +/// +/// Requirements: +/// +/// All predecessors of `Block` except those with loop back edges must have +/// already been transferred. States in `BlockStates` that are set to +/// `llvm::None` represent basic blocks that are not evaluated yet. +TypeErasedDataflowAnalysisState transferBlock( + std::vector<llvm::Optional<TypeErasedDataflowAnalysisState>> &BlockStates, + const CFGBlock &Block, const Environment &InitEnv, + TypeErasedDataflowAnalysis &Analysis, + std::function<void(const CFGStmt &, + const TypeErasedDataflowAnalysisState &)> + HandleTransferredStmt = nullptr); + /// Performs dataflow analysis and returns a mapping from basic block IDs to /// dataflow analysis states that model the respective basic blocks. Indices /// of the returned vector correspond to basic block IDs. diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index fab3f3edfb83..10c5c7f1b879 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -3865,6 +3865,14 @@ def ReleaseHandle : InheritableParamAttr { let Documentation = [ReleaseHandleDocs]; } +def DiagnoseAsBuiltin : InheritableAttr { + let Spellings = [Clang<"diagnose_as_builtin">]; + let Args = [DeclArgument<Function, "Function">, + VariadicUnsignedArgument<"ArgIndices">]; + let Subjects = SubjectList<[Function]>; + let Documentation = [DiagnoseAsBuiltinDocs]; +} + def Builtin : InheritableAttr { let Spellings = []; let Args = [UnsignedArgument<"ID">]; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 10cce4c2d689..8a7424a88c9f 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -187,6 +187,10 @@ primary use is for COFF object files which explicitly specify what interfaces are imported from external modules. See the dllimport_ documentation on MSDN for more information. +Note that a dllimport function may still be inlined, if its definition is +available and it doesn't reference any non-dllimport functions or global +variables. + .. _dllimport: https://msdn.microsoft.com/en-us/library/3y1sfaz2.aspx }]; } @@ -5980,6 +5984,50 @@ attribute requires a string literal argument to identify the handle being releas }]; } +def DiagnoseAsBuiltinDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +The ``diagnose_as_builtin` attribute indicates that Fortify diagnostics are to +be applied to the declared function as if it were the function specified by the +attribute. The builtin function whose diagnostics are to be mimicked should be +given. In addition, the order in which arguments should be applied must also +be given. + +For example, the attribute can be used as follows. + + .. code-block:: c + + __attribute__((diagnose_as_builtin(__builtin_memset, 3, 2, 1))) + void *mymemset(int n, int c, void *s) { + // ... + } + +This indicates that calls to ``mymemset`` should be diagnosed as if they were +calls to ``__builtin_memset``. The arguments ``3, 2, 1`` indicate by index the +order in which arguments of ``mymemset`` should be applied to +``__builtin_memset``. The third argument should be applied first, then the +second, and then the first. Thus (when Fortify warnings are enabled) the call +``mymemset(n, c, s)`` will diagnose overflows as if it were the call +``__builtin_memset(s, c, n)``. + +For variadic functions, the variadic arguments must come in the same order as +they would to the builtin function, after all normal arguments. For instance, +to diagnose a new function as if it were `sscanf`, we can use the attribute as +follows. + + .. code-block:: c + __attribute__((diagnose_as_builtin(sscanf, 1, 2))) + int mysscanf(const char *str, const char *format, ...) { + // ... + } + +Then the call `mysscanf("abc def", "%4s %4s", buf1, buf2)` will be diagnosed as +if it were the call `sscanf("abc def", "%4s %4s", buf1, buf2)`. + +This attribute cannot be applied to non-static member functions. +}]; +} + def ArmSveVectorBitsDocs : Documentation { let Category = DocCatType; let Content = [{ diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def index ad8b66aa490b..45d445163749 100644 --- a/clang/include/clang/Basic/Builtins.def +++ b/clang/include/clang/Basic/Builtins.def @@ -646,8 +646,10 @@ BUILTIN(__builtin_call_with_static_chain, "v.", "nt") BUILTIN(__builtin_elementwise_abs, "v.", "nct") BUILTIN(__builtin_elementwise_max, "v.", "nct") BUILTIN(__builtin_elementwise_min, "v.", "nct") +BUILTIN(__builtin_elementwise_ceil, "v.", "nct") BUILTIN(__builtin_reduce_max, "v.", "nct") BUILTIN(__builtin_reduce_min, "v.", "nct") +BUILTIN(__builtin_reduce_xor, "v.", "nct") BUILTIN(__builtin_matrix_transpose, "v.", "nFt") BUILTIN(__builtin_matrix_column_major_load, "v.", "nFt") @@ -1574,6 +1576,7 @@ BUILTIN(__builtin_smulll_overflow, "bSLLiCSLLiCSLLi*", "n") // Clang builtins (not available in GCC). BUILTIN(__builtin_addressof, "v*v&", "nct") +BUILTIN(__builtin_function_start, "v*v&", "nct") BUILTIN(__builtin_operator_new, "v*z", "tc") BUILTIN(__builtin_operator_delete, "vv*", "tn") BUILTIN(__builtin_char_memchr, "c*cC*iz", "n") @@ -1611,7 +1614,6 @@ LANGBUILTIN(__builtin_coro_alloc, "b", "n", COR_LANG) LANGBUILTIN(__builtin_coro_begin, "v*v*", "n", COR_LANG) LANGBUILTIN(__builtin_coro_end, "bv*Ib", "n", COR_LANG) LANGBUILTIN(__builtin_coro_suspend, "cIb", "n", COR_LANG) -LANGBUILTIN(__builtin_coro_param, "bv*v*", "n", COR_LANG) // OpenCL v2.0 s6.13.16, s9.17.3.5 - Pipe functions. // We need the generic prototype, since the packet type could be anything. diff --git a/clang/include/clang/Basic/BuiltinsAArch64NeonSVEBridge.def b/clang/include/clang/Basic/BuiltinsAArch64NeonSVEBridge.def new file mode 100644 index 000000000000..8e3229984d8b --- /dev/null +++ b/clang/include/clang/Basic/BuiltinsAArch64NeonSVEBridge.def @@ -0,0 +1,39 @@ +#ifdef GET_SVE_BUILTINS +BUILTIN(__builtin_sve_svget_neonq_s8, "V16Scq16Sc", "n") +BUILTIN(__builtin_sve_svget_neonq_s16, "V8sq8s", "n") +BUILTIN(__builtin_sve_svget_neonq_s32, "V4iq4i", "n") +BUILTIN(__builtin_sve_svget_neonq_s64, "V2Wiq2Wi", "n") +BUILTIN(__builtin_sve_svget_neonq_u8, "V16Ucq16Uc", "n") +BUILTIN(__builtin_sve_svget_neonq_u16, "V16Usq16Us", "n") +BUILTIN(__builtin_sve_svget_neonq_u32, "V4Uiq4Ui", "n") +BUILTIN(__builtin_sve_svget_neonq_u64, "V2UWiq2UWi", "n") +BUILTIN(__builtin_sve_svget_neonq_f16, "V8hq8h", "n") +BUILTIN(__builtin_sve_svget_neonq_f32, "V4fq4f", "n") +BUILTIN(__builtin_sve_svget_neonq_f64, "V2dq2d", "n") +BUILTIN(__builtin_sve_svget_neonq_bf16, "V8yq8y", "n") +BUILTIN(__builtin_sve_svset_neonq_s8, "q16Scq16ScV16Sc", "n") +BUILTIN(__builtin_sve_svset_neonq_s16, "q8sq8sV8s", "n") +BUILTIN(__builtin_sve_svset_neonq_s32, "q4iq4iV4i", "n") +BUILTIN(__builtin_sve_svset_neonq_s64, "q2Wiq2WiV2Wi", "n") +BUILTIN(__builtin_sve_svset_neonq_u8, "q16Ucq16UcV16Uc", "n") +BUILTIN(__builtin_sve_svset_neonq_u16, "q8Usq8UsV8s", "n") +BUILTIN(__builtin_sve_svset_neonq_u32, "q4Uiq4UiV4Ui", "n") +BUILTIN(__builtin_sve_svset_neonq_u64, "q2UWiq2UWiV2UWi", "n") +BUILTIN(__builtin_sve_svset_neonq_f16, "q8hq8hV8h", "n") +BUILTIN(__builtin_sve_svset_neonq_f32, "q4fq4fV4f", "n") +BUILTIN(__builtin_sve_svset_neonq_f64, "q2dq2dV2d", "n") +BUILTIN(__builtin_sve_svset_neonq_bf16, "q8yq8yV8y", "n") +BUILTIN(__builtin_sve_svdup_neonq_s8, "q16ScV16Sc", "n") +BUILTIN(__builtin_sve_svdup_neonq_s16, "q8sV8s", "n") +BUILTIN(__builtin_sve_svdup_neonq_s32, "q4iV4i", "n") +BUILTIN(__builtin_sve_svdup_neonq_s64, "q4iV4i", "n") +BUILTIN(__builtin_sve_svdup_neonq_u8, "q16UcV16Uc", "n") +BUILTIN(__builtin_sve_svdup_neonq_u16, "q8UsV8Us", "n") +BUILTIN(__builtin_sve_svdup_neonq_u32, "q4UiV4Ui", "n") +BUILTIN(__builtin_sve_svdup_neonq_u64, "q2UWiV2UWi", "n") +BUILTIN(__builtin_sve_svdup_neonq_f16, "q8hV8h", "n") +BUILTIN(__builtin_sve_svdup_neonq_f32, "q4fV4f", "n") +BUILTIN(__builtin_sve_svdup_neonq_f64, "q2dV2d", "n") +BUILTIN(__builtin_sve_svdup_neonq_bf16, "q8yV8y", "n") +#endif + diff --git a/clang/include/clang/Basic/BuiltinsAArch64NeonSVEBridge_cg.def b/clang/include/clang/Basic/BuiltinsAArch64NeonSVEBridge_cg.def new file mode 100644 index 000000000000..7717ba67b427 --- /dev/null +++ b/clang/include/clang/Basic/BuiltinsAArch64NeonSVEBridge_cg.def @@ -0,0 +1,39 @@ +#ifdef GET_SVE_LLVM_INTRINSIC_MAP +SVEMAP2(svget_neonq_s8, SVETypeFlags::EltTyInt8), +SVEMAP2(svget_neonq_s16, SVETypeFlags::EltTyInt16), +SVEMAP2(svget_neonq_s32, SVETypeFlags::EltTyInt32), +SVEMAP2(svget_neonq_s64, SVETypeFlags::EltTyInt64), +SVEMAP2(svget_neonq_u8, SVETypeFlags::EltTyInt8), +SVEMAP2(svget_neonq_u16, SVETypeFlags::EltTyInt16), +SVEMAP2(svget_neonq_u32, SVETypeFlags::EltTyInt32), +SVEMAP2(svget_neonq_u64, SVETypeFlags::EltTyInt64), +SVEMAP2(svget_neonq_f16, SVETypeFlags::EltTyFloat16), +SVEMAP2(svget_neonq_f32, SVETypeFlags::EltTyFloat32), +SVEMAP2(svget_neonq_f64, SVETypeFlags::EltTyFloat64), +SVEMAP2(svget_neonq_bf16, SVETypeFlags::EltTyBFloat16), +SVEMAP2(svset_neonq_s8, SVETypeFlags::EltTyInt8), +SVEMAP2(svset_neonq_s16, SVETypeFlags::EltTyInt16), +SVEMAP2(svset_neonq_s32, SVETypeFlags::EltTyInt32), +SVEMAP2(svset_neonq_s64, SVETypeFlags::EltTyInt64), +SVEMAP2(svset_neonq_u8, SVETypeFlags::EltTyInt8), +SVEMAP2(svset_neonq_u16, SVETypeFlags::EltTyInt16), +SVEMAP2(svset_neonq_u32, SVETypeFlags::EltTyInt32), +SVEMAP2(svset_neonq_u64, SVETypeFlags::EltTyInt64), +SVEMAP2(svset_neonq_f16, SVETypeFlags::EltTyFloat16), +SVEMAP2(svset_neonq_f32, SVETypeFlags::EltTyFloat32), +SVEMAP2(svset_neonq_f64, SVETypeFlags::EltTyFloat64), +SVEMAP2(svset_neonq_bf16, SVETypeFlags::EltTyBFloat16), +SVEMAP2(svdup_neonq_s8, SVETypeFlags::EltTyInt8), +SVEMAP2(svdup_neonq_s16, SVETypeFlags::EltTyInt16), +SVEMAP2(svdup_neonq_s32, SVETypeFlags::EltTyInt32), +SVEMAP2(svdup_neonq_s64, SVETypeFlags::EltTyInt64), +SVEMAP2(svdup_neonq_u8, SVETypeFlags::EltTyInt8), +SVEMAP2(svdup_neonq_u16, SVETypeFlags::EltTyInt16), +SVEMAP2(svdup_neonq_u32, SVETypeFlags::EltTyInt32), +SVEMAP2(svdup_neonq_u64, SVETypeFlags::EltTyInt64), +SVEMAP2(svdup_neonq_f16, SVETypeFlags::EltTyFloat16), +SVEMAP2(svdup_neonq_f32, SVETypeFlags::EltTyFloat32), +SVEMAP2(svdup_neonq_f64, SVETypeFlags::EltTyFloat64), +SVEMAP2(svdup_neonq_bf16, SVETypeFlags::EltTyBFloat16), +#endif + diff --git a/clang/include/clang/Basic/BuiltinsHexagon.def b/clang/include/clang/Basic/BuiltinsHexagon.def index 0001bd556117..0f62c235bb62 100644 --- a/clang/include/clang/Basic/BuiltinsHexagon.def +++ b/clang/include/clang/Basic/BuiltinsHexagon.def @@ -17,8 +17,10 @@ # define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS) #endif +#pragma push_macro("V69") +#define V69 "v69" #pragma push_macro("V68") -#define V68 "v68" +#define V68 "v68|" V69 #pragma push_macro("V67") #define V67 "v67|" V68 #pragma push_macro("V66") @@ -34,8 +36,10 @@ #pragma push_macro("V5") #define V5 "v5|" V55 +#pragma push_macro("HVXV69") +#define HVXV69 "hvxv69" #pragma push_macro("HVXV68") -#define HVXV68 "hvxv68" +#define HVXV68 "hvxv68|" HVXV69 #pragma push_macro("HVXV67") #define HVXV67 "hvxv67|" HVXV68 #pragma push_macro("HVXV66") @@ -128,6 +132,7 @@ TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_rtt_acc_128B,"V64iV64iV32iLLi","", " #pragma pop_macro("HVXV66") #pragma pop_macro("HVXV67") #pragma pop_macro("HVXV68") +#pragma pop_macro("HVXV69") #pragma pop_macro("V5") #pragma pop_macro("V55") @@ -137,6 +142,7 @@ TARGET_BUILTIN(__builtin_HEXAGON_V6_vrmpyub_rtt_acc_128B,"V64iV64iV32iLLi","", " #pragma pop_macro("V66") #pragma pop_macro("V67") #pragma pop_macro("V68") +#pragma pop_macro("V69") #undef BUILTIN #undef TARGET_BUILTIN diff --git a/clang/include/clang/Basic/BuiltinsHexagonDep.def b/clang/include/clang/Basic/BuiltinsHexagonDep.def index 152c9c4dd8ad..2eb4ca69c7bd 100644 --- a/clang/include/clang/Basic/BuiltinsHexagonDep.def +++ b/clang/include/clang/Basic/BuiltinsHexagonDep.def @@ -1739,3 +1739,150 @@ TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyvubs10, "V32iV32iV32iUIi", "", HVXV68) TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyvubs10_128B, "V64iV64iV64iUIi", "", HVXV68) TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyvubs10_vxx, "V32iV32iV32iV32iUIi", "", HVXV68) TARGET_BUILTIN(__builtin_HEXAGON_V6_v6mpyvubs10_vxx_128B, "V64iV64iV64iV64iUIi", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabs_hf, "V16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabs_hf_128B, "V32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabs_sf, "V16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vabs_sf_128B, "V32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_hf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_hf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_hf_hf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_hf_hf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf16, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf16_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf16_mix, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf16_mix_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf32, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf32_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf32_mix, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_qf32_mix_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf_hf, "V32iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf_hf_128B, "V64iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf_sf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vadd_sf_sf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vassign_fp, "V16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vassign_fp_128B, "V32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_hf_qf16, "V16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_hf_qf16_128B, "V32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_hf_qf32, "V16iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_hf_qf32_128B, "V32iV64i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_sf_qf32, "V16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vconv_sf_qf32_128B, "V32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_b_hf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_b_hf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_h_hf, "V16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_h_hf_128B, "V32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_hf_b, "V32iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_hf_b_128B, "V64iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_hf_h, "V16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_hf_h_128B, "V32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_hf_sf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_hf_sf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_hf_ub, "V32iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_hf_ub_128B, "V64iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_hf_uh, "V16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_hf_uh_128B, "V32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_sf_hf, "V32iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_sf_hf_128B, "V64iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_ub_hf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_ub_hf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_uh_hf, "V16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vcvt_uh_hf_128B, "V32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpy_sf_hf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpy_sf_hf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpy_sf_hf_acc, "V16iV16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vdmpy_sf_hf_acc_128B, "V32iV32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vfmax_hf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vfmax_hf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vfmax_sf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vfmax_sf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vfmin_hf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vfmin_hf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vfmin_sf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vfmin_sf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vfneg_hf, "V16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vfneg_hf_128B, "V32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vfneg_sf, "V16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vfneg_sf_128B, "V32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgthf, "V64bV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgthf_128B, "V128bV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgthf_and, "V64bV64bV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgthf_and_128B, "V128bV128bV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgthf_or, "V64bV64bV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgthf_or_128B, "V128bV128bV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgthf_xor, "V64bV64bV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgthf_xor_128B, "V128bV128bV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtsf, "V64bV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtsf_128B, "V128bV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtsf_and, "V64bV64bV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtsf_and_128B, "V128bV128bV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtsf_or, "V64bV64bV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtsf_or_128B, "V128bV128bV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtsf_xor, "V64bV64bV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vgtsf_xor_128B, "V128bV128bV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmax_hf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmax_hf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmax_sf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmax_sf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmin_hf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmin_hf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmin_sf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmin_sf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_hf_hf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_hf_hf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_hf_hf_acc, "V16iV16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_hf_hf_acc_128B, "V32iV32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf16, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf16_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf16_hf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf16_hf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf16_mix_hf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf16_mix_hf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf32, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf32_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf32_hf, "V32iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf32_hf_128B, "V64iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf32_mix_hf, "V32iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf32_mix_hf_128B, "V64iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf32_qf16, "V32iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf32_qf16_128B, "V64iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf32_sf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_qf32_sf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_sf_hf, "V32iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_sf_hf_128B, "V64iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_sf_hf_acc, "V32iV32iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_sf_hf_acc_128B, "V64iV64iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_sf_sf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpy_sf_sf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_hf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_hf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_hf_hf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_hf_hf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_qf16, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_qf16_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_qf16_mix, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_qf16_mix_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_qf32, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_qf32_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_qf32_mix, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_qf32_mix_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_sf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_sf_128B, "V32iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_sf_hf, "V32iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_sf_hf_128B, "V64iV32iV32i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_sf_sf, "V16iV16iV16i", "", HVXV68) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vsub_sf_sf_128B, "V32iV32iV32i", "", HVXV68) + +// V69 HVX Instructions. + +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrvuhubrndsat, "V16iV32iV16i", "", HVXV69) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrvuhubrndsat_128B, "V32iV64iV32i", "", HVXV69) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrvuhubsat, "V16iV32iV16i", "", HVXV69) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrvuhubsat_128B, "V32iV64iV32i", "", HVXV69) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrvwuhrndsat, "V16iV32iV16i", "", HVXV69) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrvwuhrndsat_128B, "V32iV64iV32i", "", HVXV69) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrvwuhsat, "V16iV32iV16i", "", HVXV69) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vasrvwuhsat_128B, "V32iV64iV32i", "", HVXV69) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhvs, "V16iV16iV16i", "", HVXV69) +TARGET_BUILTIN(__builtin_HEXAGON_V6_vmpyuhvs_128B, "V32iV32iV32i", "", HVXV69) diff --git a/clang/include/clang/Basic/BuiltinsHexagonMapCustomDep.def b/clang/include/clang/Basic/BuiltinsHexagonMapCustomDep.def index 93f560fc5adc..389eadb21d01 100644 --- a/clang/include/clang/Basic/BuiltinsHexagonMapCustomDep.def +++ b/clang/include/clang/Basic/BuiltinsHexagonMapCustomDep.def @@ -8,199 +8,7 @@ // Automatically generated file, do not edit! //===----------------------------------------------------------------------===// -CUSTOM_BUILTIN_MAPPING(A2_add, 0) -CUSTOM_BUILTIN_MAPPING(A2_addi, 0) -CUSTOM_BUILTIN_MAPPING(A2_addp, 0) -CUSTOM_BUILTIN_MAPPING(A2_and, 0) -CUSTOM_BUILTIN_MAPPING(A2_andir, 0) -CUSTOM_BUILTIN_MAPPING(A2_neg, 0) -CUSTOM_BUILTIN_MAPPING(A2_not, 0) -CUSTOM_BUILTIN_MAPPING(A2_or, 0) -CUSTOM_BUILTIN_MAPPING(A2_orir, 0) -CUSTOM_BUILTIN_MAPPING(A2_sub, 0) -CUSTOM_BUILTIN_MAPPING(A2_subp, 0) -CUSTOM_BUILTIN_MAPPING(A2_subri, 0) -CUSTOM_BUILTIN_MAPPING(A2_sxtb, 0) -CUSTOM_BUILTIN_MAPPING(A2_sxth, 0) -CUSTOM_BUILTIN_MAPPING(A2_xor, 0) -CUSTOM_BUILTIN_MAPPING(A2_zxtb, 0) -CUSTOM_BUILTIN_MAPPING(A2_zxth, 0) -CUSTOM_BUILTIN_MAPPING(M2_dpmpyss_s0, 0) -CUSTOM_BUILTIN_MAPPING(M2_dpmpyuu_s0, 0) -CUSTOM_BUILTIN_MAPPING(M2_mpyi, 0) -CUSTOM_BUILTIN_MAPPING(M2_mpysmi, 0) -CUSTOM_BUILTIN_MAPPING(M2_mpyui, 0) -CUSTOM_BUILTIN_MAPPING(S2_asl_i_p, 0) -CUSTOM_BUILTIN_MAPPING(S2_asl_i_r, 0) -CUSTOM_BUILTIN_MAPPING(S2_asr_i_p, 0) -CUSTOM_BUILTIN_MAPPING(S2_asr_i_r, 0) -CUSTOM_BUILTIN_MAPPING(S2_lsr_i_p, 0) -CUSTOM_BUILTIN_MAPPING(S2_lsr_i_r, 0) -CUSTOM_BUILTIN_MAPPING(V6_pred_and, 64) -CUSTOM_BUILTIN_MAPPING(V6_pred_and_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_pred_and_n, 64) -CUSTOM_BUILTIN_MAPPING(V6_pred_and_n_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_pred_not, 64) -CUSTOM_BUILTIN_MAPPING(V6_pred_not_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_pred_or, 64) -CUSTOM_BUILTIN_MAPPING(V6_pred_or_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_pred_or_n, 64) -CUSTOM_BUILTIN_MAPPING(V6_pred_or_n_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_pred_scalar2, 64) -CUSTOM_BUILTIN_MAPPING(V6_pred_scalar2_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_pred_xor, 64) -CUSTOM_BUILTIN_MAPPING(V6_pred_xor_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vS32b_nqpred_ai, 64) -CUSTOM_BUILTIN_MAPPING(V6_vS32b_nqpred_ai_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vS32b_nt_nqpred_ai, 64) -CUSTOM_BUILTIN_MAPPING(V6_vS32b_nt_nqpred_ai_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vS32b_nt_qpred_ai, 64) -CUSTOM_BUILTIN_MAPPING(V6_vS32b_nt_qpred_ai_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vS32b_qpred_ai, 64) -CUSTOM_BUILTIN_MAPPING(V6_vS32b_qpred_ai_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vaddbnq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vaddbnq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vaddbq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vaddbq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vaddhnq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vaddhnq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vaddhq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vaddhq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vaddwnq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vaddwnq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vaddwq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vaddwq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vandqrt, 64) -CUSTOM_BUILTIN_MAPPING(V6_vandqrt_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vandqrt_acc, 64) -CUSTOM_BUILTIN_MAPPING(V6_vandqrt_acc_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vandvrt, 64) -CUSTOM_BUILTIN_MAPPING(V6_vandvrt_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vandvrt_acc, 64) -CUSTOM_BUILTIN_MAPPING(V6_vandvrt_acc_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_veqb, 64) -CUSTOM_BUILTIN_MAPPING(V6_veqb_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_veqb_and, 64) -CUSTOM_BUILTIN_MAPPING(V6_veqb_and_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_veqb_or, 64) -CUSTOM_BUILTIN_MAPPING(V6_veqb_or_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_veqb_xor, 64) -CUSTOM_BUILTIN_MAPPING(V6_veqb_xor_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_veqh, 64) -CUSTOM_BUILTIN_MAPPING(V6_veqh_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_veqh_and, 64) -CUSTOM_BUILTIN_MAPPING(V6_veqh_and_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_veqh_or, 64) -CUSTOM_BUILTIN_MAPPING(V6_veqh_or_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_veqh_xor, 64) -CUSTOM_BUILTIN_MAPPING(V6_veqh_xor_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_veqw, 64) -CUSTOM_BUILTIN_MAPPING(V6_veqw_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_veqw_and, 64) -CUSTOM_BUILTIN_MAPPING(V6_veqw_and_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_veqw_or, 64) -CUSTOM_BUILTIN_MAPPING(V6_veqw_or_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_veqw_xor, 64) -CUSTOM_BUILTIN_MAPPING(V6_veqw_xor_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtb, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtb_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtb_and, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtb_and_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtb_or, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtb_or_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtb_xor, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtb_xor_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgth, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgth_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgth_and, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgth_and_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgth_or, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgth_or_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgth_xor, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgth_xor_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtub, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtub_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtub_and, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtub_and_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtub_or, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtub_or_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtub_xor, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtub_xor_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtuh, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtuh_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtuh_and, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtuh_and_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtuh_or, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtuh_or_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtuh_xor, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtuh_xor_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtuw, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtuw_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtuw_and, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtuw_and_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtuw_or, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtuw_or_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtuw_xor, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtuw_xor_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtw, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtw_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtw_and, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtw_and_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtw_or, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtw_or_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgtw_xor, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgtw_xor_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vmux, 64) -CUSTOM_BUILTIN_MAPPING(V6_vmux_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vsubbnq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vsubbnq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vsubbq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vsubbq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vsubhnq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vsubhnq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vsubhq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vsubhq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vsubwnq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vsubwnq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vsubwq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vsubwq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vswap, 64) -CUSTOM_BUILTIN_MAPPING(V6_vswap_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_pred_scalar2v2, 64) -CUSTOM_BUILTIN_MAPPING(V6_pred_scalar2v2_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_shuffeqh, 64) -CUSTOM_BUILTIN_MAPPING(V6_shuffeqh_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_shuffeqw, 64) -CUSTOM_BUILTIN_MAPPING(V6_shuffeqw_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vaddcarry, 64) CUSTOM_BUILTIN_MAPPING(V6_vaddcarry_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vandnqrt, 64) -CUSTOM_BUILTIN_MAPPING(V6_vandnqrt_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vandnqrt_acc, 64) -CUSTOM_BUILTIN_MAPPING(V6_vandnqrt_acc_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vandvnqv, 64) -CUSTOM_BUILTIN_MAPPING(V6_vandvnqv_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vandvqv, 64) -CUSTOM_BUILTIN_MAPPING(V6_vandvqv_128B, 128) CUSTOM_BUILTIN_MAPPING(V6_vsubcarry, 64) CUSTOM_BUILTIN_MAPPING(V6_vsubcarry_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgathermhq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgathermhq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgathermhwq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgathermhwq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vgathermwq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vgathermwq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vprefixqb, 64) -CUSTOM_BUILTIN_MAPPING(V6_vprefixqb_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vprefixqh, 64) -CUSTOM_BUILTIN_MAPPING(V6_vprefixqh_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vprefixqw, 64) -CUSTOM_BUILTIN_MAPPING(V6_vprefixqw_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vscattermhq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vscattermhq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vscattermhwq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vscattermhwq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vscattermwq, 64) -CUSTOM_BUILTIN_MAPPING(V6_vscattermwq_128B, 128) -CUSTOM_BUILTIN_MAPPING(V6_vaddcarrysat, 64) -CUSTOM_BUILTIN_MAPPING(V6_vaddcarrysat_128B, 128) diff --git a/clang/include/clang/Basic/BuiltinsSVE.def b/clang/include/clang/Basic/BuiltinsSVE.def index 2839ca992d98..c70525e967b1 100644 --- a/clang/include/clang/Basic/BuiltinsSVE.def +++ b/clang/include/clang/Basic/BuiltinsSVE.def @@ -15,6 +15,7 @@ #define GET_SVE_BUILTINS #include "clang/Basic/arm_sve_builtins.inc" +#include "clang/Basic/BuiltinsAArch64NeonSVEBridge.def" #undef GET_SVE_BUILTINS #undef BUILTIN diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def index 94b3003a9c33..723302f108e2 100644 --- a/clang/include/clang/Basic/CodeGenOptions.def +++ b/clang/include/clang/Basic/CodeGenOptions.def @@ -368,9 +368,6 @@ ENUM_CODEGENOPT(DebuggerTuning, llvm::DebuggerKind, 3, /// emitted. VALUE_CODEGENOPT(DwarfVersion, 3, 0) -/// Whether to use experimental new variable location tracking. -CODEGENOPT(ValueTrackingVariableLocations, 1, 0) - /// Whether we should emit CodeView debug information. It's possible to emit /// CodeView and DWARF into the same object. CODEGENOPT(EmitCodeView, 1, 0) diff --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h index 664e4998b8de..33ec03a17136 100644 --- a/clang/include/clang/Basic/CodeGenOptions.h +++ b/clang/include/clang/Basic/CodeGenOptions.h @@ -227,6 +227,9 @@ public: /// Output filename for the split debug info, not used in the skeleton CU. std::string SplitDwarfOutput; + /// Output filename used in the COFF debug information. + std::string ObjectFilenameForDebug; + /// The name of the relocation model to use. llvm::Reloc::Model RelocationModel; @@ -395,7 +398,7 @@ public: /// Executable and command-line used to create a given CompilerInvocation. /// Most of the time this will be the full -cc1 command. const char *Argv0 = nullptr; - ArrayRef<const char *> CommandLineArgs; + std::vector<std::string> CommandLineArgs; /// The minimum hotness value a diagnostic needs in order to be included in /// optimization diagnostics. diff --git a/clang/include/clang/Basic/Cuda.h b/clang/include/clang/Basic/Cuda.h index 8c08ab3f5d74..04967925e9a4 100644 --- a/clang/include/clang/Basic/Cuda.h +++ b/clang/include/clang/Basic/Cuda.h @@ -95,6 +95,8 @@ enum class CudaArch { GFX1033, GFX1034, GFX1035, + Generic, // A processor model named 'generic' if the target backend defines a + // public one. LAST, }; @@ -103,7 +105,8 @@ static inline bool IsNVIDIAGpuArch(CudaArch A) { } static inline bool IsAMDGpuArch(CudaArch A) { - return A >= CudaArch::GFX600 && A < CudaArch::LAST; + // Generic processor model is for testing only. + return A >= CudaArch::GFX600 && A < CudaArch::Generic; } const char *CudaArchToString(CudaArch A); diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index 2f50918b527b..a7fd2f26478c 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -74,6 +74,14 @@ def err_drv_no_hip_runtime : Error< "cannot find HIP runtime; provide its path via '--rocm-path', or pass " "'-nogpuinc' to build without HIP runtime">; +def err_drv_no_hipspv_device_lib : Error< + "cannot find HIP device library%select{| for %1}0; provide its path via " + "'--hip-path' or '--hip-device-lib-path', or pass '-nogpulib' to build " + "without HIP device library">; +def err_drv_hipspv_no_hip_path : Error< + "'--hip-path' must be specified when offloading to " + "SPIR-V%select{| unless %1 is given}0.">; + def err_drv_undetermined_amdgpu_arch : Error< "cannot determine AMDGPU architecture: %0; consider passing it via " "'--march'">; @@ -108,6 +116,10 @@ def warn_drv_unsupported_option_for_target : Warning< "ignoring '%0' option as it is not currently supported for target '%1'">, InGroup<OptionIgnored>; +def warn_drv_spirv_linking_multiple_inputs_unsupported: Warning< + "Linking multiple input files is not supported for SPIR-V yet">, + InGroup<OptionIgnored>; + def err_drv_invalid_thread_model_for_target : Error< "invalid thread model '%0' in '%1' for this target">; def err_drv_invalid_linker_name : Error< @@ -431,11 +443,13 @@ def err_analyzer_checker_option_invalid_input : Error< def err_analyzer_checker_incompatible_analyzer_option : Error< "checker cannot be enabled with analyzer option '%0' == %1">; -def err_drv_invalid_hvx_length : Error< - "-mhvx-length is not supported without a -mhvx/-mhvx= flag">; -def warn_drv_vectorize_needs_hvx : Warning< - "auto-vectorization requires HVX, use -mhvx to enable it">, +def warn_drv_needs_hvx : Warning< + "%0 requires HVX, use -mhvx/-mhvx= to enable it">, InGroup<OptionIgnored>; +def err_drv_needs_hvx : Error< + "%0 requires HVX, use -mhvx/-mhvx= to enable it">; +def err_drv_needs_hvx_version : Error< + "%0 is not supported on HVX %1">; def err_drv_module_header_wrong_kind : Error< "header file '%0' input type '%1' does not match type of prior input " @@ -551,7 +565,7 @@ def warn_drv_moutline_unsupported_opt : Warning< InGroup<OptionIgnored>; def warn_drv_moutline_atomics_unsupported_opt : Warning< - "'%0' does not support '-moutline-atomics'; flag ignored">, + "'%0' does not support '-%1'; flag ignored">, InGroup<OptionIgnored>; def warn_drv_darwin_sdk_invalid_settings : Warning< @@ -608,7 +622,14 @@ def err_cc1_round_trip_ok_then_fail : Error< "generated arguments parse failed in round-trip">; def err_cc1_round_trip_mismatch : Error< "generated arguments do not match in round-trip">; +def err_cc1_unbounded_vscale_min : Error< + "minimum vscale must be an unsigned integer greater than 0">; def err_drv_ssp_missing_offset_argument : Error< "'%0' is used without '-mstack-protector-guard-offset', and there is no default">; + +def err_drv_only_one_offload_target_supported_in : Error< + "Only one offload target is supported in %0.">; +def err_drv_invalid_or_unsupported_offload_target : Error< + "Invalid or unsupported offload target: '%0'.">; } diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 90df3a424406..c0642efaee4e 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -191,6 +191,7 @@ def DeprecatedVolatile : DiagGroup<"deprecated-volatile">; def DeprecatedWritableStr : DiagGroup<"deprecated-writable-strings", [CXX11CompatDeprecatedWritableStr]>; def DeprecatedPragma : DiagGroup<"deprecated-pragma">; +def DeprecatedType : DiagGroup<"deprecated-type">; // FIXME: Why is DeprecatedImplementations not in this group? def Deprecated : DiagGroup<"deprecated", [DeprecatedAnonEnumEnumConversion, DeprecatedArrayCompare, @@ -208,6 +209,7 @@ def Deprecated : DiagGroup<"deprecated", [DeprecatedAnonEnumEnumConversion, DeprecatedPragma, DeprecatedRegister, DeprecatedThisCapture, + DeprecatedType, DeprecatedVolatile, DeprecatedWritableStr]>, DiagCategory<"Deprecations">; @@ -1044,6 +1046,13 @@ def : DiagGroup<"unused-local-typedefs", [UnusedLocalTypedef]>; def NonGCC : DiagGroup<"non-gcc", [SignCompare, Conversion, LiteralRange]>; +def CXX14Attrs : DiagGroup<"c++14-attribute-extensions">; +def CXX17Attrs : DiagGroup<"c++17-attribute-extensions">; +def CXX20Attrs : DiagGroup<"c++20-attribute-extensions">; +def FutureAttrs : DiagGroup<"future-attribute-extensions", [CXX14Attrs, + CXX17Attrs, + CXX20Attrs]>; + // A warning group for warnings about using C++11 features as extensions in // earlier C++ versions. def CXX11 : DiagGroup<"c++11-extensions", [CXX11ExtraSemi, CXX11InlineNamespace, @@ -1051,15 +1060,15 @@ def CXX11 : DiagGroup<"c++11-extensions", [CXX11ExtraSemi, CXX11InlineNamespace, // A warning group for warnings about using C++14 features as extensions in // earlier C++ versions. -def CXX14 : DiagGroup<"c++14-extensions", [CXX14BinaryLiteral]>; +def CXX14 : DiagGroup<"c++14-extensions", [CXX14BinaryLiteral, CXX14Attrs]>; // A warning group for warnings about using C++17 features as extensions in // earlier C++ versions. -def CXX17 : DiagGroup<"c++17-extensions">; +def CXX17 : DiagGroup<"c++17-extensions", [CXX17Attrs]>; // A warning group for warnings about using C++20 features as extensions in // earlier C++ versions. -def CXX20 : DiagGroup<"c++20-extensions", [CXX20Designator]>; +def CXX20 : DiagGroup<"c++20-extensions", [CXX20Designator, CXX20Attrs]>; // A warning group for warnings about using C++2b features as extensions in // earlier C++ versions. diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index 92e877074ad3..9dc036c03faa 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -1503,6 +1503,15 @@ def warn_pragma_force_cuda_host_device_bad_arg : Warning< def err_pragma_cannot_end_force_cuda_host_device : Error< "force_cuda_host_device end pragma without matching " "force_cuda_host_device begin">; + +def warn_ext_int_deprecated : Warning< + "'_ExtInt' is deprecated; use '_BitInt' instead">, InGroup<DeprecatedType>; +def ext_bit_int : Extension< + "'_BitInt' in %select{C17 and earlier|C++}0 is a Clang extension">, + InGroup<DiagGroup<"bit-int-extension">>; +def warn_c17_compat_bit_int : Warning< + "'_BitInt' is incompatible with C standards before C2x">, + InGroup<CPre2xCompat>, DefaultIgnore; } // end of Parse Issue category. let CategoryName = "Modules Issue" in { diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index fb5bd53f7432..f2089bfda04d 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -838,6 +838,9 @@ def warn_fortify_scanf_overflow : Warning< "%2, but the corresponding specifier may require size %3">, InGroup<FortifySource>; +def err_function_start_invalid_type: Error< + "argument must be a function">; + /// main() // static main() is not an error in C, just in C++. def warn_static_main : Warning<"'main' should not be declared static">, @@ -2956,6 +2959,17 @@ def err_attribute_invalid_argument : Error< def err_attribute_wrong_number_arguments : Error< "%0 attribute %plural{0:takes no arguments|1:takes one argument|" ":requires exactly %1 arguments}1">; +def err_attribute_wrong_number_arguments_for : Error < + "%0 attribute references function %1, which %plural{0:takes no arguments|1:takes one argument|" + ":takes exactly %2 arguments}2">; +def err_attribute_bounds_for_function : Error< + "%0 attribute references parameter %1, but the function %2 has only %3 parameters">; +def err_attribute_no_member_function : Error< + "%0 attribute cannot be applied to non-static member functions">; +def err_attribute_parameter_types : Error< + "%0 attribute parameter types do not match: parameter %1 of function %2 has type %3, " + "but parameter %4 of function %5 has type %6">; + def err_attribute_too_many_arguments : Error< "%0 attribute takes no more than %1 argument%s1">; def err_attribute_too_few_arguments : Error< @@ -3013,7 +3027,7 @@ def err_attribute_sizeless_type : Error< "%0 attribute cannot be applied to sizeless type %1">; def err_attribute_argument_n_type : Error< "%0 attribute requires parameter %1 to be %select{int or bool|an integer " - "constant|a string|an identifier|a constant expression}2">; + "constant|a string|an identifier|a constant expression|a builtin function}2">; def err_attribute_argument_type : Error< "%0 attribute requires %select{int or bool|an integer " "constant|a string|an identifier}1">; @@ -8337,8 +8351,8 @@ def err_atomic_exclusive_builtin_pointer_size : Error< " 1,2,4 or 8 byte type (%0 invalid)">; def err_atomic_builtin_ext_int_size : Error< "Atomic memory operand must have a power-of-two size">; -def err_atomic_builtin_ext_int_prohibit : Error< - "argument to atomic builtin of type '_ExtInt' is not supported">; +def err_atomic_builtin_bit_int_prohibit : Error< + "argument to atomic builtin of type '_BitInt' is not supported">; def err_atomic_op_needs_atomic : Error< "address argument to atomic operation must be a pointer to _Atomic " "type (%0 invalid)">; @@ -8374,8 +8388,8 @@ def err_overflow_builtin_must_be_int : Error< def err_overflow_builtin_must_be_ptr_int : Error< "result argument to overflow builtin must be a pointer " "to a non-const integer (%0 invalid)">; -def err_overflow_builtin_ext_int_max_size : Error< - "__builtin_mul_overflow does not support signed _ExtInt operands of more " +def err_overflow_builtin_bit_int_max_size : Error< + "__builtin_mul_overflow does not support 'signed _BitInt' operands of more " "than %0 bits">; def err_atomic_load_store_uses_lib : Error< @@ -8626,11 +8640,11 @@ def warn_unused_volatile : Warning< InGroup<DiagGroup<"unused-volatile-lvalue">>; def ext_cxx14_attr : Extension< - "use of the %0 attribute is a C++14 extension">, InGroup<CXX14>; + "use of the %0 attribute is a C++14 extension">, InGroup<CXX14Attrs>; def ext_cxx17_attr : Extension< - "use of the %0 attribute is a C++17 extension">, InGroup<CXX17>; + "use of the %0 attribute is a C++17 extension">, InGroup<CXX17Attrs>; def ext_cxx20_attr : Extension< - "use of the %0 attribute is a C++20 extension">, InGroup<CXX20>; + "use of the %0 attribute is a C++20 extension">, InGroup<CXX20Attrs>; def warn_unused_comparison : Warning< "%select{equality|inequality|relational|three-way}0 comparison result unused">, @@ -9140,15 +9154,22 @@ def warn_cxx17_compat_defaulted_comparison : Warning< "before C++20">, InGroup<CXXPre20Compat>, DefaultIgnore; def err_defaulted_comparison_template : Error< "comparison operator template cannot be defaulted">; -def err_defaulted_comparison_out_of_class : Error< - "%sub{select_defaulted_comparison_kind}0 can only be defaulted in a class " - "definition">; +def err_defaulted_comparison_num_args : Error< + "%select{non-member|member}0 %sub{select_defaulted_comparison_kind}1" + " comparison operator must have %select{2|1}0 parameters">; def err_defaulted_comparison_param : Error< "invalid parameter type for defaulted %sub{select_defaulted_comparison_kind}0" "; found %1, expected %2%select{| or %4}3">; +def err_defaulted_comparison_param_unknown : Error< + "invalid parameter type for non-member defaulted" + " %sub{select_defaulted_comparison_kind}0" + "; found %1, expected class or reference to a constant class">; def err_defaulted_comparison_param_mismatch : Error< "parameters for defaulted %sub{select_defaulted_comparison_kind}0 " "must have the same type%diff{ (found $ vs $)|}1,2">; +def err_defaulted_comparison_not_friend : Error< + "%sub{select_defaulted_comparison_kind}0 is not a friend of" + " %select{|incomplete class }1%2">; def err_defaulted_comparison_non_const : Error< "defaulted member %sub{select_defaulted_comparison_kind}0 must be " "const-qualified">; @@ -9811,6 +9832,8 @@ def err_ppc_builtin_only_on_arch : Error< "this builtin is only valid on POWER%0 or later CPUs">; def err_ppc_builtin_requires_vsx : Error< "this builtin requires VSX to be enabled">; +def err_ppc_builtin_requires_htm : Error< + "this builtin requires HTM to be enabled">; def err_ppc_builtin_requires_abi : Error< "this builtin requires ABI -mabi=%0">; def err_ppc_invalid_use_mma_type : Error< @@ -10486,7 +10509,7 @@ def err_omp_atomic_capture_not_compound_statement : Error< def note_omp_atomic_capture: Note< "%select{expected assignment expression|expected compound statement|expected exactly two expression statements|expected in right hand side of the first expression}0">; def err_omp_atomic_several_clauses : Error< - "directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause">; + "directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause">; def err_omp_several_mem_order_clauses : Error< "directive '#pragma omp %0' cannot contain more than one %select{'seq_cst', 'relaxed', |}1'acq_rel', 'acquire' or 'release' clause">; def err_omp_atomic_incompatible_mem_order_clause : Error< @@ -11020,14 +11043,12 @@ def err_implied_coroutine_type_not_found : Error< "a coroutine; include <experimental/coroutine> if your version " "of libcxx is less than 14.0">; def warn_deprecated_coroutine_namespace : Warning< - "Please move from std::experimental::%0 to std::%0. " - "Support for std::experimental::%0 will be removed in LLVM 15.">, + "support for std::experimental::%0 will be removed in LLVM 15; " + "use std::%0 instead">, InGroup<DeprecatedExperimentalCoroutine>; -def err_mixed_use_std_and_experimental_namespace_for_coroutine : Error < - "Found mixed use of std namespace and std::experimental namespace for " - "coroutine, which is disallowed. The coroutine components in " - "std::experimental namespace is deprecated. Please use coroutine components " - "under std namespace.">; +def err_mixed_use_std_and_experimental_namespace_for_coroutine : Error< + "mixed use of std and std::experimental namespaces for " + "coroutine components">; def err_implicit_coroutine_std_nothrow_type_not_found : Error< "std::nothrow was not found; include <new> before defining a coroutine which " "uses get_return_object_on_allocation_failure()">; @@ -11050,8 +11071,6 @@ def err_coroutine_type_missing_specialization : Error< "specialization %0">; def err_coroutine_promise_incompatible_return_functions : Error< "the coroutine promise type %0 declares both 'return_value' and 'return_void'">; -def err_coroutine_promise_requires_return_function : Error< - "the coroutine promise type %0 must declare either 'return_value' or 'return_void'">; def note_coroutine_promise_implicit_await_transform_required_here : Note< "call to 'await_transform' implicitly required by 'co_await' here">; def note_coroutine_promise_suspend_implicitly_required : Note< @@ -11355,8 +11374,10 @@ def err_builtin_launder_invalid_arg : Error< def err_builtin_invalid_arg_type: Error < "%ordinal0 argument must be a " "%select{vector, integer or floating point type|matrix|" - "pointer to a valid matrix element type|" - "signed integer or floating point type|vector type}1 (was %2)">; + "pointer to a valid matrix element type|" + "signed integer or floating point type|vector type|" + "floating point type|" + "vector of integers}1 (was %2)">; def err_builtin_matrix_disabled: Error< "matrix types extension is disabled. Pass -fenable-matrix to enable it">; @@ -11423,9 +11444,9 @@ def warn_sycl_kernel_return_type : Warning< "function template with 'sycl_kernel' attribute must have a 'void' return type">, InGroup<IgnoredAttributes>; -def err_ext_int_bad_size : Error<"%select{signed|unsigned}0 _ExtInt must " +def err_bit_int_bad_size : Error<"%select{signed|unsigned}0 _BitInt must " "have a bit size of at least %select{2|1}0">; -def err_ext_int_max_size : Error<"%select{signed|unsigned}0 _ExtInt of bit " +def err_bit_int_max_size : Error<"%select{signed|unsigned}0 _BitInt of bit " "sizes greater than %1 not supported">; // errors of expect.with.probability diff --git a/clang/include/clang/Basic/Module.h b/clang/include/clang/Basic/Module.h index 3476b05d2e92..de7857347bc2 100644 --- a/clang/include/clang/Basic/Module.h +++ b/clang/include/clang/Basic/Module.h @@ -153,6 +153,10 @@ public: return Kind == ModuleInterfaceUnit || Kind == PrivateModuleFragment; } + /// Does this Module scope describe a fragment of the global module within + /// some C++ module. + bool isGlobalModule() const { return Kind == GlobalModuleFragment; } + private: /// The submodules of this module, indexed by name. std::vector<Module *> SubModules; diff --git a/clang/include/clang/Basic/Specifiers.h b/clang/include/clang/Basic/Specifiers.h index 66cdba3f912e..82b3c1f3c274 100644 --- a/clang/include/clang/Basic/Specifiers.h +++ b/clang/include/clang/Basic/Specifiers.h @@ -59,7 +59,7 @@ namespace clang { TST_char32, // C++11 char32_t TST_int, TST_int128, - TST_extint, // Extended Int types. + TST_bitint, // Bit-precise integer types. TST_half, // OpenCL half, ARM NEON __fp16 TST_Float16, // C11 extension ISO/IEC TS 18661-3 TST_Accum, // ISO/IEC JTC1 SC22 WG14 N1169 Extension diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index 3e1e09417c66..437feba85e23 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -582,9 +582,13 @@ public: return (getPointerWidth(0) >= 64) || getTargetOpts().ForceEnableInt128; } // FIXME - /// Determine whether the _ExtInt type is supported on this target. This + /// Determine whether the _BitInt type is supported on this target. This /// limitation is put into place for ABI reasons. - virtual bool hasExtIntType() const { + /// FIXME: _BitInt is a required type in C23, so there's not much utility in + /// asking whether the target supported it or not; I think this should be + /// removed once backends have been alerted to the type and have had the + /// chance to do implementation work if needed. + virtual bool hasBitIntType() const { return false; } diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def index 0dd5936aa3e6..e55244e1c3ac 100644 --- a/clang/include/clang/Basic/TokenKinds.def +++ b/clang/include/clang/Basic/TokenKinds.def @@ -300,6 +300,7 @@ KEYWORD(if , KEYALL) KEYWORD(inline , KEYC99|KEYCXX|KEYGNU) KEYWORD(int , KEYALL) KEYWORD(_ExtInt , KEYALL) +KEYWORD(_BitInt , KEYALL) KEYWORD(long , KEYALL) KEYWORD(register , KEYALL) KEYWORD(restrict , KEYC99) diff --git a/clang/include/clang/Basic/TypeNodes.td b/clang/include/clang/Basic/TypeNodes.td index 011394c3ef45..b65e8ab521c0 100644 --- a/clang/include/clang/Basic/TypeNodes.td +++ b/clang/include/clang/Basic/TypeNodes.td @@ -75,6 +75,7 @@ def DependentSizedMatrixType : TypeNode<MatrixType>, AlwaysDependent; def FunctionType : TypeNode<Type, 1>; def FunctionProtoType : TypeNode<FunctionType>; def FunctionNoProtoType : TypeNode<FunctionType>; +def UsingType : TypeNode<Type>, NeverCanonical; def UnresolvedUsingType : TypeNode<Type>, AlwaysDependent; def ParenType : TypeNode<Type>, NeverCanonical; def TypedefType : TypeNode<Type>, NeverCanonical; @@ -107,5 +108,5 @@ def ObjCInterfaceType : TypeNode<ObjCObjectType>, LeafType; def ObjCObjectPointerType : TypeNode<Type>; def PipeType : TypeNode<Type>; def AtomicType : TypeNode<Type>; -def ExtIntType : TypeNode<Type>; -def DependentExtIntType : TypeNode<Type>, AlwaysDependent; +def BitIntType : TypeNode<Type>; +def DependentBitIntType : TypeNode<Type>, AlwaysDependent; diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h index 8b1f7091e701..9ae34a2eaf01 100644 --- a/clang/include/clang/Driver/Driver.h +++ b/clang/include/clang/Driver/Driver.h @@ -595,6 +595,21 @@ private: /// @} + /// Retrieves a ToolChain for a particular device \p Target triple + /// + /// \param[in] HostTC is the host ToolChain paired with the device + /// + /// \param[in] Action (e.g. OFK_Cuda/OFK_OpenMP/OFK_SYCL) is an Offloading + /// action that is optionally passed to a ToolChain (used by CUDA, to specify + /// if it's used in conjunction with OpenMP) + /// + /// Will cache ToolChains for the life of the driver object, and create them + /// on-demand. + const ToolChain &getOffloadingDeviceToolChain( + const llvm::opt::ArgList &Args, const llvm::Triple &Target, + const ToolChain &HostTC, + const Action::OffloadKind &TargetDeviceOffloadKind) const; + /// Get bitmasks for which option flags to include and exclude based on /// the driver mode. std::pair<unsigned, unsigned> getIncludeExcludeOptionFlagMasks(bool IsClCompatMode) const; diff --git a/clang/include/clang/Driver/Job.h b/clang/include/clang/Driver/Job.h index 8b287638a271..6e3b51f2a799 100644 --- a/clang/include/clang/Driver/Job.h +++ b/clang/include/clang/Driver/Job.h @@ -204,6 +204,10 @@ public: /// from the parent process will be used. virtual void setEnvironment(llvm::ArrayRef<const char *> NewEnvironment); + void replaceArguments(llvm::opt::ArgStringList List) { + Arguments = std::move(List); + } + const char *getExecutable() const { return Executable; } const llvm::opt::ArgStringList &getArguments() const { return Arguments; } diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 4e6dd2050344..dc8bd831f2a2 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -985,6 +985,9 @@ defm hip_fp32_correctly_rounded_divide_sqrt : BoolFOption<"hip-fp32-correctly-ro BothFlags<[], " that single precision floating-point divide and sqrt used in " "the program source are correctly rounded (HIP device compilation only)">>, ShouldParseIf<hip.KeyPath>; +def hipspv_pass_plugin_EQ : Joined<["--"], "hipspv-pass-plugin=">, + Group<Link_Group>, MetaVarName<"<dsopath>">, + HelpText<"path to a pass plugin for HIP to SPIR-V passes.">; defm gpu_allow_device_init : BoolFOption<"gpu-allow-device-init", LangOpts<"GPUAllowDeviceInit">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Allow">, NegFlag<SetFalse, [], "Don't allow">, @@ -1132,6 +1135,13 @@ defm autolink : BoolFOption<"autolink", NegFlag<SetFalse, [CC1Option], "Disable generation of linker directives for automatic library linking">, PosFlag<SetTrue>>; +// In the future this option will be supported by other offloading +// languages and accept other values such as CPU/GPU architectures, +// offload kinds and target aliases. +def offload_EQ : CommaJoined<["--"], "offload=">, Flags<[NoXarchOption]>, + HelpText<"Specify comma-separated list of offloading target triples" + " (HIP only)">; + // C++ Coroutines TS defm coroutines_ts : BoolFOption<"coroutines-ts", LangOpts<"Coroutines">, Default<cpp20.KeyPath>, @@ -2392,7 +2402,8 @@ def fomit_frame_pointer : Flag<["-"], "fomit-frame-pointer">, Group<f_Group>; def fopenmp : Flag<["-"], "fopenmp">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused, FlangOption, FC1Option]>, HelpText<"Parse OpenMP pragmas and generate parallel code.">; def fno_openmp : Flag<["-"], "fno-openmp">, Group<f_Group>, Flags<[NoArgumentUnused]>; -def fopenmp_version_EQ : Joined<["-"], "fopenmp-version=">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused]>; +def fopenmp_version_EQ : Joined<["-"], "fopenmp-version=">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused]>, + HelpText<"Set OpenMP version (e.g. 45 for OpenMP 4.5, 50 for OpenMP 5.0). Default value is 50.">; defm openmp_extensions: BoolFOption<"openmp-extensions", LangOpts<"OpenMPExtensions">, DefaultTrue, PosFlag<SetTrue, [CC1Option, NoArgumentUnused], @@ -2433,16 +2444,16 @@ def fopenmp_target_debug : Flag<["-"], "fopenmp-target-debug">, Group<f_Group>, HelpText<"Enable debugging in the OpenMP offloading device RTL">; def fno_openmp_target_debug : Flag<["-"], "fno-openmp-target-debug">, Group<f_Group>, Flags<[NoArgumentUnused]>; def fopenmp_target_debug_EQ : Joined<["-"], "fopenmp-target-debug=">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>; -def fopenmp_assume_teams_oversubscription : Flag<["-"], "fopenmp-assume-teams-oversubscription">, +def fopenmp_assume_teams_oversubscription : Flag<["-"], "fopenmp-assume-teams-oversubscription">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>; -def fopenmp_assume_threads_oversubscription : Flag<["-"], "fopenmp-assume-threads-oversubscription">, +def fopenmp_assume_threads_oversubscription : Flag<["-"], "fopenmp-assume-threads-oversubscription">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>; -def fno_openmp_assume_teams_oversubscription : Flag<["-"], "fno-openmp-assume-teams-oversubscription">, +def fno_openmp_assume_teams_oversubscription : Flag<["-"], "fno-openmp-assume-teams-oversubscription">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>; -def fno_openmp_assume_threads_oversubscription : Flag<["-"], "fno-openmp-assume-threads-oversubscription">, +def fno_openmp_assume_threads_oversubscription : Flag<["-"], "fno-openmp-assume-threads-oversubscription">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>; defm openmp_target_new_runtime: BoolFOption<"openmp-target-new-runtime", - LangOpts<"OpenMPTargetNewRuntime">, DefaultFalse, + LangOpts<"OpenMPTargetNewRuntime">, DefaultTrue, PosFlag<SetTrue, [CC1Option], "Use the new bitcode library for OpenMP offloading">, NegFlag<SetFalse>>; defm openmp_optimistic_collapse : BoolFOption<"openmp-optimistic-collapse", @@ -3338,6 +3349,11 @@ def mno_fix_cortex_a53_835769 : Flag<["-"], "mno-fix-cortex-a53-835769">, def mmark_bti_property : Flag<["-"], "mmark-bti-property">, Group<m_aarch64_Features_Group>, HelpText<"Add .note.gnu.property with BTI to assembly files (AArch64 only)">; +def mno_bti_at_return_twice : Flag<["-"], "mno-bti-at-return-twice">, + Group<m_arm_Features_Group>, + HelpText<"Do not add a BTI instruction after a setjmp or other" + " return-twice construct (Arm only)">; + foreach i = {1-31} in def ffixed_x#i : Flag<["-"], "ffixed-x"#i>, Group<m_Group>, HelpText<"Reserve the x"#i#" register (AArch64/RISC-V only)">; @@ -3352,8 +3368,7 @@ def msve_vector_bits_EQ : Joined<["-"], "msve-vector-bits=">, Group<m_aarch64_Fe def mvscale_min_EQ : Joined<["-"], "mvscale-min=">, Group<m_aarch64_Features_Group>, Flags<[NoXarchOption,CC1Option]>, - HelpText<"Specify the vscale minimum. Defaults to the" - " vector length agnostic value of \"0\". (AArch64 only)">, + HelpText<"Specify the vscale minimum. Defaults to \"1\". (AArch64 only)">, MarshallingInfoInt<LangOpts<"VScaleMin">>; def mvscale_max_EQ : Joined<["-"], "mvscale-max=">, Group<m_aarch64_Features_Group>, Flags<[NoXarchOption,CC1Option]>, @@ -3759,6 +3774,8 @@ def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option, CoreOption]>, MarshallingInfoNegativeFlag<HeaderSearchOpts<"UseBuiltinIncludes">>; def nogpuinc : Flag<["-"], "nogpuinc">, HelpText<"Do not add include paths for CUDA/HIP and" " do not include the default CUDA/HIP wrapper headers">; +def nohipwrapperinc : Flag<["-"], "nohipwrapperinc">, + HelpText<"Do not include the default HIP wrapper headers and include paths">; def : Flag<["-"], "nocudainc">, Alias<nogpuinc>; def nogpulib : Flag<["-"], "nogpulib">, HelpText<"Do not link device library for CUDA/HIP device compilation">; @@ -3785,6 +3802,11 @@ def o : JoinedOrSeparate<["-"], "o">, Flags<[NoXarchOption, RenderAsInput, CC1Option, CC1AsOption, FC1Option, FlangOption]>, HelpText<"Write output to <file>">, MetaVarName<"<file>">, MarshallingInfoString<FrontendOpts<"OutputFile">>; +def object_file_name_EQ : Joined<["-"], "object-file-name=">, Flags<[CC1Option, CC1AsOption, CoreOption]>, + HelpText<"Set the output <file> for debug infos">, MetaVarName<"<file>">, + MarshallingInfoString<CodeGenOpts<"ObjectFilenameForDebug">>; +def object_file_name : Separate<["-"], "object-file-name">, Flags<[CC1Option, CC1AsOption, CoreOption]>, + Alias<object_file_name_EQ>; def pagezero__size : JoinedOrSeparate<["-"], "pagezero_size">; def pass_exit_codes : Flag<["-", "--"], "pass-exit-codes">, Flags<[Unsupported]>; def pedantic_errors : Flag<["-", "--"], "pedantic-errors">, Group<pedantic_Group>, Flags<[CC1Option]>, @@ -4138,6 +4160,8 @@ def mv67t : Flag<["-"], "mv67t">, Group<m_hexagon_Features_Group>, Alias<mcpu_EQ>, AliasArgs<["hexagonv67t"]>; def mv68 : Flag<["-"], "mv68">, Group<m_hexagon_Features_Group>, Alias<mcpu_EQ>, AliasArgs<["hexagonv68"]>; +def mv69 : Flag<["-"], "mv69">, Group<m_hexagon_Features_Group>, + Alias<mcpu_EQ>, AliasArgs<["hexagonv69"]>; def mhexagon_hvx : Flag<["-"], "mhvx">, Group<m_hexagon_Features_HVX_Group>, HelpText<"Enable Hexagon Vector eXtensions">; def mhexagon_hvx_EQ : Joined<["-"], "mhvx=">, @@ -4149,6 +4173,18 @@ def mno_hexagon_hvx : Flag<["-"], "mno-hvx">, def mhexagon_hvx_length_EQ : Joined<["-"], "mhvx-length=">, Group<m_hexagon_Features_HVX_Group>, HelpText<"Set Hexagon Vector Length">, Values<"64B,128B">; +def mhexagon_hvx_qfloat : Flag<["-"], "mhvx-qfloat">, + Group<m_hexagon_Features_HVX_Group>, + HelpText<"Enable Hexagon HVX QFloat instructions">; +def mno_hexagon_hvx_qfloat : Flag<["-"], "mno-hvx-qfloat">, + Group<m_hexagon_Features_HVX_Group>, + HelpText<"Disable Hexagon HVX QFloat instructions">; +def mhexagon_hvx_ieee_fp : Flag<["-"], "mhvx-ieee-fp">, + Group<m_hexagon_Features_Group>, + HelpText<"Enable Hexagon HVX IEEE floating-point">; +def mno_hexagon_hvx_ieee_fp : Flag<["-"], "mno-hvx-ieee-fp">, + Group<m_hexagon_Features_Group>, + HelpText<"Disable Hexagon HVX IEEE floating-point">; def ffixed_r19: Flag<["-"], "ffixed-r19">, HelpText<"Reserve register r19 (Hexagon only)">; def mmemops : Flag<["-"], "mmemops">, Group<m_hexagon_Features_Group>, diff --git a/clang/include/clang/Driver/Tool.h b/clang/include/clang/Driver/Tool.h index cc0a09fb2747..42cf99a4a970 100644 --- a/clang/include/clang/Driver/Tool.h +++ b/clang/include/clang/Driver/Tool.h @@ -52,6 +52,7 @@ public: const ToolChain &getToolChain() const { return TheToolChain; } virtual bool hasIntegratedAssembler() const { return false; } + virtual bool hasIntegratedBackend() const { return true; } virtual bool canEmitIR() const { return false; } virtual bool hasIntegratedCPP() const = 0; virtual bool isLinkJob() const { return false; } diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h index dad861d586cb..4afc9bf36b5f 100644 --- a/clang/include/clang/Driver/ToolChain.h +++ b/clang/include/clang/Driver/ToolChain.h @@ -348,10 +348,7 @@ public: /// is LLD. If it's set, it can be assumed that the linker is LLD built /// at the same revision as clang, and clang can make assumptions about /// LLD's supported flags, error output, etc. - /// If LinkerIsLLDDarwinNew is non-nullptr, it's set if the linker is - /// the new version in lld/MachO. - std::string GetLinkerPath(bool *LinkerIsLLD = nullptr, - bool *LinkerIsLLDDarwinNew = nullptr) const; + std::string GetLinkerPath(bool *LinkerIsLLD = nullptr) const; /// Returns the linker path for emitting a static library. std::string GetStaticLibToolPath() const; @@ -387,6 +384,9 @@ public: /// Check if the toolchain should use the integrated assembler. virtual bool useIntegratedAs() const; + /// Check if the toolchain should use the integrated backend. + virtual bool useIntegratedBackend() const { return true; } + /// Check if the toolchain should use AsmParser to parse inlineAsm when /// integrated assembler is not default. virtual bool parseInlineAsmUsingAsmParser() const { return false; } diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h index d38bc6e3f0e6..0f97e80d425e 100644 --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -2669,6 +2669,7 @@ struct FormatStyle { bool isCpp() const { return Language == LK_Cpp || Language == LK_ObjC; } bool isCSharp() const { return Language == LK_CSharp; } bool isJson() const { return Language == LK_Json; } + bool isJavaScript() const { return Language == LK_JavaScript; } /// Language, this format style is targeted at. /// \version 3.5 diff --git a/clang/include/clang/Lex/ModuleMap.h b/clang/include/clang/Lex/ModuleMap.h index 41f85a1f572d..08c61a5dc560 100644 --- a/clang/include/clang/Lex/ModuleMap.h +++ b/clang/include/clang/Lex/ModuleMap.h @@ -538,8 +538,11 @@ public: /// /// We model the global module fragment as a submodule of the module /// interface unit. Unfortunately, we can't create the module interface - /// unit's Module until later, because we don't know what it will be called. - Module *createGlobalModuleFragmentForModuleUnit(SourceLocation Loc); + /// unit's Module until later, because we don't know what it will be called + /// usually. See C++20 [module.unit]/7.2 for the case we could know its + /// parent. + Module *createGlobalModuleFragmentForModuleUnit(SourceLocation Loc, + Module *Parent = nullptr); /// Create a global module fragment for a C++ module interface unit. Module *createPrivateModuleFragmentForInterfaceUnit(Module *Parent, diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index 92a703b42173..741a484390b2 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -2564,6 +2564,10 @@ private: /// full validation of the syntactic structure of attributes. bool TrySkipAttributes(); + /// Diagnoses use of _ExtInt as being deprecated, and diagnoses use of + /// _BitInt as an extension when appropriate. + void DiagnoseBitIntUse(const Token &Tok); + public: TypeResult ParseTypeName(SourceRange *Range = nullptr, diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h index ed5be2da3acd..2704a9c1fc78 100644 --- a/clang/include/clang/Sema/DeclSpec.h +++ b/clang/include/clang/Sema/DeclSpec.h @@ -266,7 +266,7 @@ public: static const TST TST_char32 = clang::TST_char32; static const TST TST_int = clang::TST_int; static const TST TST_int128 = clang::TST_int128; - static const TST TST_extint = clang::TST_extint; + static const TST TST_bitint = clang::TST_bitint; static const TST TST_half = clang::TST_half; static const TST TST_BFloat16 = clang::TST_BFloat16; static const TST TST_float = clang::TST_float; @@ -404,7 +404,7 @@ private: T == TST_underlyingType || T == TST_atomic); } static bool isExprRep(TST T) { - return (T == TST_typeofExpr || T == TST_decltype || T == TST_extint); + return (T == TST_typeofExpr || T == TST_decltype || T == TST_bitint); } static bool isTemplateIdRep(TST T) { return (T == TST_auto || T == TST_decltype_auto); @@ -703,7 +703,7 @@ public: bool SetTypePipe(bool isPipe, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy); - bool SetExtIntType(SourceLocation KWLoc, Expr *BitWidth, + bool SetBitIntType(SourceLocation KWLoc, Expr *BitWidth, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy); bool SetTypeSpecSat(SourceLocation Loc, const char *&PrevSpec, diff --git a/clang/include/clang/Sema/ParsedAttr.h b/clang/include/clang/Sema/ParsedAttr.h index ff2303c84bd2..6403179cb327 100644 --- a/clang/include/clang/Sema/ParsedAttr.h +++ b/clang/include/clang/Sema/ParsedAttr.h @@ -1097,6 +1097,7 @@ enum AttributeArgumentNType { AANT_ArgumentString, AANT_ArgumentIdentifier, AANT_ArgumentConstantExpr, + AANT_ArgumentBuiltinFunction, }; /// These constants match the enumerated choices of diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 1a82a9498d1d..79834554a50d 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -1324,12 +1324,15 @@ public: bool isImmediateFunctionContext() const { return Context == ExpressionEvaluationContext::ImmediateFunctionContext || - InImmediateFunctionContext; + (Context == ExpressionEvaluationContext::DiscardedStatement && + InImmediateFunctionContext); } bool isDiscardedStatementContext() const { return Context == ExpressionEvaluationContext::DiscardedStatement || - InDiscardedStatement; + (Context == + ExpressionEvaluationContext::ImmediateFunctionContext && + InDiscardedStatement); } }; @@ -2043,7 +2046,7 @@ public: SourceLocation Loc); QualType BuildWritePipeType(QualType T, SourceLocation Loc); - QualType BuildExtIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc); + QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc); TypeSourceInfo *GetTypeForDeclarator(Declarator &D, Scope *S); TypeSourceInfo *GetTypeForDeclaratorCast(Declarator &D, QualType FromTy); @@ -2219,6 +2222,17 @@ private: return ModuleScopes.empty() ? nullptr : ModuleScopes.back().Module; } + /// Helper function to judge if we are in module purview. + /// Return false if we are not in a module. + bool isCurrentModulePurview() const { + return getCurrentModule() ? getCurrentModule()->isModulePurview() : false; + } + + /// Enter the scope of the global module. + Module *PushGlobalModuleFragment(SourceLocation BeginLoc, bool IsImplicit); + /// Leave the scope of the global module. + void PopGlobalModuleFragment(); + VisibleModuleSet VisibleModules; public: @@ -11176,6 +11190,9 @@ public: /// Called on well-formed 'capture' clause. OMPClause *ActOnOpenMPCaptureClause(SourceLocation StartLoc, SourceLocation EndLoc); + /// Called on well-formed 'compare' clause. + OMPClause *ActOnOpenMPCompareClause(SourceLocation StartLoc, + SourceLocation EndLoc); /// Called on well-formed 'seq_cst' clause. OMPClause *ActOnOpenMPSeqCstClause(SourceLocation StartLoc, SourceLocation EndLoc); @@ -12769,8 +12786,8 @@ private: bool CheckPPCMMAType(QualType Type, SourceLocation TypeLoc); bool SemaBuiltinElementwiseMath(CallExpr *TheCall); - bool SemaBuiltinElementwiseMathOneArg(CallExpr *TheCall); - bool SemaBuiltinReduceMath(CallExpr *TheCall); + bool PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall); + bool PrepareBuiltinReduceMathOneArgCall(CallExpr *TheCall); // Matrix builtin handling. ExprResult SemaBuiltinMatrixTranspose(CallExpr *TheCall, diff --git a/clang/include/clang/Serialization/TypeBitCodes.def b/clang/include/clang/Serialization/TypeBitCodes.def index e92e05810648..85571ea290f7 100644 --- a/clang/include/clang/Serialization/TypeBitCodes.def +++ b/clang/include/clang/Serialization/TypeBitCodes.def @@ -58,9 +58,10 @@ TYPE_BIT_CODE(DependentSizedExtVector, DEPENDENT_SIZED_EXT_VECTOR, 46) TYPE_BIT_CODE(DependentAddressSpace, DEPENDENT_ADDRESS_SPACE, 47) TYPE_BIT_CODE(DependentVector, DEPENDENT_SIZED_VECTOR, 48) TYPE_BIT_CODE(MacroQualified, MACRO_QUALIFIED, 49) -TYPE_BIT_CODE(ExtInt, EXT_INT, 50) -TYPE_BIT_CODE(DependentExtInt, DEPENDENT_EXT_INT, 51) +TYPE_BIT_CODE(BitInt, BIT_INT, 50) +TYPE_BIT_CODE(DependentBitInt, DEPENDENT_BIT_INT, 51) TYPE_BIT_CODE(ConstantMatrix, CONSTANT_MATRIX, 52) TYPE_BIT_CODE(DependentSizedMatrix, DEPENDENT_SIZE_MATRIX, 53) +TYPE_BIT_CODE(Using, USING, 54) #undef TYPE_BIT_CODE diff --git a/clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h b/clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h index 31a4ed50a723..48cd3395e936 100644 --- a/clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h +++ b/clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h @@ -32,7 +32,7 @@ private: std::string Str; llvm::raw_string_ostream OS(Str); S->printPretty(OS, nullptr, PrintingPolicy(ACtx.getLangOpts())); - return OS.str(); + return Str; } bool isThisObject(const SymbolicRegion *R) { @@ -69,7 +69,7 @@ public: std::string Str; llvm::raw_string_ostream OS(Str); OS << "concrete memory address '" << I << "'"; - return OS.str(); + return Str; } std::string VisitNonLocSymbolVal(nonloc::SymbolVal V) { @@ -82,7 +82,7 @@ public: llvm::raw_string_ostream OS(Str); OS << (I.isSigned() ? "signed " : "unsigned ") << I.getBitWidth() << "-bit integer '" << I << "'"; - return OS.str(); + return Str; } std::string VisitNonLocLazyCompoundVal(nonloc::LazyCompoundVal V) { @@ -123,7 +123,7 @@ public: OS << "(" << Visit(S->getLHS()) << ") " << std::string(BinaryOperator::getOpcodeStr(S->getOpcode())) << " " << S->getRHS(); - return OS.str(); + return Str; } // TODO: IntSymExpr doesn't appear in practice. @@ -177,7 +177,7 @@ public: else OS << "'" << Visit(R->getIndex()) << "'"; OS << " of " + Visit(R->getSuperRegion()); - return OS.str(); + return Str; } std::string VisitNonParamVarRegion(const NonParamVarRegion *R) { diff --git a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def index aab8e1284bf6..c0cade46d614 100644 --- a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def +++ b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def @@ -336,6 +336,18 @@ ANALYZER_OPTION( "might be modeled by the analyzer to never return NULL.", false) +ANALYZER_OPTION( + bool, ShouldIgnoreBisonGeneratedFiles, "ignore-bison-generated-files", + "If enabled, any files containing the \"/* A Bison parser, made by\" " + "won't be analyzed.", + true) + +ANALYZER_OPTION( + bool, ShouldIgnoreFlexGeneratedFiles, "ignore-flex-generated-files", + "If enabled, any files containing the \"/* A lexical scanner generated by " + "flex\" won't be analyzed.", + true) + //===----------------------------------------------------------------------===// // Unsigned analyzer options. //===----------------------------------------------------------------------===// diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h index 396c9a4de440..cd972b7837d0 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h @@ -134,6 +134,9 @@ public: std::initializer_list<std::pair<CallDescription, T>> &&List) : LinearMap(List) {} + template <typename InputIt> + CallDescriptionMap(InputIt First, InputIt Last) : LinearMap(First, Last) {} + ~CallDescriptionMap() = default; // These maps are usually stored once per checker, so let's make sure @@ -141,6 +144,9 @@ public: CallDescriptionMap(const CallDescriptionMap &) = delete; CallDescriptionMap &operator=(const CallDescription &) = delete; + CallDescriptionMap(CallDescriptionMap &&) = default; + CallDescriptionMap &operator=(CallDescriptionMap &&) = default; + LLVM_NODISCARD const T *lookup(const CallEvent &Call) const { // Slow path: linear lookup. // TODO: Implement some sort of fast path. diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h index a80484610131..3a0bec9d04e5 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h @@ -140,6 +140,30 @@ public: /// Complexity: O(N) /// where N = size(Original) RangeSet add(RangeSet Original, const llvm::APSInt &Point); + /// Create a new set which is a union of two given ranges. + /// Possible intersections are not checked here. + /// + /// Complexity: O(N + M) + /// where N = size(LHS), M = size(RHS) + RangeSet unite(RangeSet LHS, RangeSet RHS); + /// Create a new set by uniting given range set with the given range. + /// All intersections and adjacent ranges are handled here. + /// + /// Complexity: O(N) + /// where N = size(Original) + RangeSet unite(RangeSet Original, Range Element); + /// Create a new set by uniting given range set with the given point. + /// All intersections and adjacent ranges are handled here. + /// + /// Complexity: O(N) + /// where N = size(Original) + RangeSet unite(RangeSet Original, llvm::APSInt Point); + /// Create a new set by uniting given range set with the given range + /// between points. All intersections and adjacent ranges are handled here. + /// + /// Complexity: O(N) + /// where N = size(Original) + RangeSet unite(RangeSet Original, llvm::APSInt From, llvm::APSInt To); RangeSet getEmptySet() { return &EmptySet; } @@ -224,6 +248,9 @@ public: ContainerType *construct(ContainerType &&From); RangeSet intersect(const ContainerType &LHS, const ContainerType &RHS); + /// NOTE: This function relies on the fact that all values in the + /// containers are persistent (created via BasicValueFactory::getValue). + ContainerType unite(const ContainerType &LHS, const ContainerType &RHS); // Many operations include producing new APSInt values and that's why // we need this factory. diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h index d2461705d128..bdf9662d5d99 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h @@ -172,9 +172,9 @@ public: /// dynamic_cast. /// - We don't know (base is a symbolic region and we don't have /// enough info to determine if the cast will succeed at run time). - /// The function returns an SVal representing the derived class; it's - /// valid only if Failed flag is set to false. - SVal attemptDownCast(SVal Base, QualType DerivedPtrType, bool &Failed); + /// The function returns an optional with SVal representing the derived class + /// in case of a successful cast and `None` otherwise. + Optional<SVal> evalBaseToDerived(SVal Base, QualType DerivedPtrType); const ElementRegion *GetElementZeroRegion(const SubRegion *R, QualType T); diff --git a/clang/include/clang/Testing/TestClangConfig.h b/clang/include/clang/Testing/TestClangConfig.h index 5d6be4f65d0a..92d5cc3cff99 100644 --- a/clang/include/clang/Testing/TestClangConfig.h +++ b/clang/include/clang/Testing/TestClangConfig.h @@ -73,7 +73,7 @@ struct TestClangConfig { std::string Result; llvm::raw_string_ostream OS(Result); OS << "{ Language=" << Language << ", Target=" << Target << " }"; - return OS.str(); + return Result; } friend std::ostream &operator<<(std::ostream &OS, diff --git a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h index af02fa2e7e87..7d0b8f2138f9 100644 --- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h +++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h @@ -26,57 +26,83 @@ namespace dependencies { /// the dependency scanning filesystem. /// /// It represents one of the following: -/// - an opened source file with minimized contents and a stat value. -/// - an opened source file with original contents and a stat value. -/// - a directory entry with its stat value. -/// - an error value to represent a file system error. -/// - a placeholder with an invalid stat indicating a not yet initialized entry. +/// - opened file with original contents and a stat value, +/// - opened file with original contents, minimized contents and a stat value, +/// - directory entry with its stat value, +/// - filesystem error, +/// - uninitialized entry with unknown status. class CachedFileSystemEntry { public: - /// Default constructor creates an entry with an invalid stat. - CachedFileSystemEntry() : MaybeStat(llvm::vfs::Status()) {} + /// Creates an uninitialized entry. + CachedFileSystemEntry() + : MaybeStat(llvm::vfs::Status()), MinimizedContentsAccess(nullptr) {} - CachedFileSystemEntry(std::error_code Error) : MaybeStat(std::move(Error)) {} + /// Initialize the cached file system entry. + void init(llvm::ErrorOr<llvm::vfs::Status> &&MaybeStatus, StringRef Filename, + llvm::vfs::FileSystem &FS); - /// Create an entry that represents an opened source file with minimized or - /// original contents. + /// Initialize the entry as file with minimized or original contents. /// /// The filesystem opens the file even for `stat` calls open to avoid the /// issues with stat + open of minimized files that might lead to a - /// mismatching size of the file. If file is not minimized, the full file is - /// read and copied into memory to ensure that it's not memory mapped to avoid - /// running out of file descriptors. - static CachedFileSystemEntry createFileEntry(StringRef Filename, - llvm::vfs::FileSystem &FS, - bool Minimize = true); + /// mismatching size of the file. + llvm::ErrorOr<llvm::vfs::Status> initFile(StringRef Filename, + llvm::vfs::FileSystem &FS); - /// Create an entry that represents a directory on the filesystem. - static CachedFileSystemEntry createDirectoryEntry(llvm::vfs::Status &&Stat); + /// Minimize contents of the file. + void minimizeFile(); - /// \returns True if the entry is valid. - bool isValid() const { return !MaybeStat || MaybeStat->isStatusKnown(); } + /// \returns True if the entry is initialized. + bool isInitialized() const { + return !MaybeStat || MaybeStat->isStatusKnown(); + } /// \returns True if the current entry points to a directory. bool isDirectory() const { return MaybeStat && MaybeStat->isDirectory(); } - /// \returns The error or the file's contents. - llvm::ErrorOr<StringRef> getContents() const { + /// \returns The error or the file's original contents. + llvm::ErrorOr<StringRef> getOriginalContents() const { + if (!MaybeStat) + return MaybeStat.getError(); + assert(!MaybeStat->isDirectory() && "not a file"); + assert(isInitialized() && "not initialized"); + assert(OriginalContents && "not read"); + return OriginalContents->getBuffer(); + } + + /// \returns The error or the file's minimized contents. + llvm::ErrorOr<StringRef> getMinimizedContents() const { if (!MaybeStat) return MaybeStat.getError(); assert(!MaybeStat->isDirectory() && "not a file"); - assert(isValid() && "not initialized"); - return Contents.str(); + assert(isInitialized() && "not initialized"); + llvm::MemoryBuffer *Buffer = MinimizedContentsAccess.load(); + assert(Buffer && "not minimized"); + return Buffer->getBuffer(); + } + + /// \returns True if this entry represents a file that can be read. + bool isReadable() const { return MaybeStat && !MaybeStat->isDirectory(); } + + /// \returns True if this cached entry needs to be updated. + bool needsUpdate(bool ShouldBeMinimized) const { + return isReadable() && needsMinimization(ShouldBeMinimized); + } + + /// \returns True if the contents of this entry need to be minimized. + bool needsMinimization(bool ShouldBeMinimized) const { + return ShouldBeMinimized && !MinimizedContentsAccess.load(); } /// \returns The error or the status of the entry. llvm::ErrorOr<llvm::vfs::Status> getStatus() const { - assert(isValid() && "not initialized"); + assert(isInitialized() && "not initialized"); return MaybeStat; } /// \returns the name of the file. StringRef getName() const { - assert(isValid() && "not initialized"); + assert(isInitialized() && "not initialized"); return MaybeStat->getName(); } @@ -86,19 +112,16 @@ public: return PPSkippedRangeMapping; } - CachedFileSystemEntry(CachedFileSystemEntry &&) = default; - CachedFileSystemEntry &operator=(CachedFileSystemEntry &&) = default; - - CachedFileSystemEntry(const CachedFileSystemEntry &) = delete; - CachedFileSystemEntry &operator=(const CachedFileSystemEntry &) = delete; - private: llvm::ErrorOr<llvm::vfs::Status> MaybeStat; - // Store the contents in a small string to allow a - // move from the small string for the minimized contents. - // Note: small size of 1 allows us to store an empty string with an implicit - // null terminator without any allocations. - llvm::SmallString<1> Contents; + std::unique_ptr<llvm::MemoryBuffer> OriginalContents; + + /// Owning storage for the minimized file contents. + std::unique_ptr<llvm::MemoryBuffer> MinimizedContentsStorage; + /// Atomic view of the minimized file contents. + /// This prevents data races when multiple threads call `needsMinimization`. + std::atomic<llvm::MemoryBuffer *> MinimizedContentsAccess; + PreprocessorSkippedRangeMapping PPSkippedRangeMapping; }; @@ -115,61 +138,70 @@ public: CachedFileSystemEntry Value; }; + DependencyScanningFilesystemSharedCache(); + /// Returns a cache entry for the corresponding key. /// /// A new cache entry is created if the key is not in the cache. This is a /// thread safe call. - SharedFileSystemEntry &get(StringRef Key, bool Minimized); + SharedFileSystemEntry &get(StringRef Key); private: - class SingleCache { - public: - SingleCache(); - - SharedFileSystemEntry &get(StringRef Key); - - private: - struct CacheShard { - std::mutex CacheLock; - llvm::StringMap<SharedFileSystemEntry, llvm::BumpPtrAllocator> Cache; - }; - std::unique_ptr<CacheShard[]> CacheShards; - unsigned NumShards; + struct CacheShard { + std::mutex CacheLock; + llvm::StringMap<SharedFileSystemEntry, llvm::BumpPtrAllocator> Cache; }; - - SingleCache CacheMinimized; - SingleCache CacheOriginal; + std::unique_ptr<CacheShard[]> CacheShards; + unsigned NumShards; }; /// This class is a local cache, that caches the 'stat' and 'open' calls to the /// underlying real file system. It distinguishes between minimized and original /// files. class DependencyScanningFilesystemLocalCache { -private: - using SingleCache = - llvm::StringMap<const CachedFileSystemEntry *, llvm::BumpPtrAllocator>; - - SingleCache CacheMinimized; - SingleCache CacheOriginal; + llvm::StringMap<const CachedFileSystemEntry *, llvm::BumpPtrAllocator> Cache; - SingleCache &selectCache(bool Minimized) { - return Minimized ? CacheMinimized : CacheOriginal; +public: + const CachedFileSystemEntry *getCachedEntry(StringRef Filename) { + return Cache[Filename]; } +}; + +/// Reference to a CachedFileSystemEntry. +/// If the underlying entry is an opened file, this wrapper returns the correct +/// contents (original or minimized) and ensures consistency with file size +/// reported by status. +class EntryRef { + /// For entry that is an opened file, this bit signifies whether its contents + /// are minimized. + bool Minimized; + + /// The underlying cached entry. + const CachedFileSystemEntry &Entry; public: - void setCachedEntry(StringRef Filename, bool Minimized, - const CachedFileSystemEntry *Entry) { - SingleCache &Cache = selectCache(Minimized); - bool IsInserted = Cache.try_emplace(Filename, Entry).second; - (void)IsInserted; - assert(IsInserted && "local cache is updated more than once"); + EntryRef(bool Minimized, const CachedFileSystemEntry &Entry) + : Minimized(Minimized), Entry(Entry) {} + + llvm::ErrorOr<llvm::vfs::Status> getStatus() const { + auto MaybeStat = Entry.getStatus(); + if (!MaybeStat || MaybeStat->isDirectory()) + return MaybeStat; + return llvm::vfs::Status::copyWithNewSize(*MaybeStat, + getContents()->size()); + } + + bool isDirectory() const { return Entry.isDirectory(); } + + StringRef getName() const { return Entry.getName(); } + + llvm::ErrorOr<StringRef> getContents() const { + return Minimized ? Entry.getMinimizedContents() + : Entry.getOriginalContents(); } - const CachedFileSystemEntry *getCachedEntry(StringRef Filename, - bool Minimized) { - SingleCache &Cache = selectCache(Minimized); - auto It = Cache.find(Filename); - return It == Cache.end() ? nullptr : It->getValue(); + const PreprocessorSkippedRangeMapping *getPPSkippedRangeMapping() const { + return Minimized ? &Entry.getPPSkippedRangeMapping() : nullptr; } }; @@ -204,19 +236,13 @@ private: /// Check whether the file should be minimized. bool shouldMinimize(StringRef Filename); - llvm::ErrorOr<const CachedFileSystemEntry *> - getOrCreateFileSystemEntry(const StringRef Filename); - - /// Create a cached file system entry based on the initial status result. - CachedFileSystemEntry - createFileSystemEntry(llvm::ErrorOr<llvm::vfs::Status> &&MaybeStatus, - StringRef Filename, bool ShouldMinimize); + llvm::ErrorOr<EntryRef> getOrCreateFileSystemEntry(StringRef Filename); /// The global cache shared between worker threads. DependencyScanningFilesystemSharedCache &SharedCache; /// The local cache is used by the worker thread to cache file system queries /// locally instead of querying the global cache every time. - DependencyScanningFilesystemLocalCache Cache; + DependencyScanningFilesystemLocalCache LocalCache; /// The optional mapping structure which records information about the /// excluded conditional directive skip mappings that are used by the /// currently active preprocessor. diff --git a/clang/include/clang/Tooling/Inclusions/IncludeStyle.h b/clang/include/clang/Tooling/Inclusions/IncludeStyle.h index d54f8a402e2d..d5638642d017 100644 --- a/clang/include/clang/Tooling/Inclusions/IncludeStyle.h +++ b/clang/include/clang/Tooling/Inclusions/IncludeStyle.h @@ -106,7 +106,7 @@ struct IncludeStyle { /// Priority: 2 /// SortPriority: 2 /// CaseSensitive: true - /// - Regex: '^(<|"(gtest|gmock|isl|json)/)' + /// - Regex: '^((<|")(gtest|gmock|isl|json)/)' /// Priority: 3 /// - Regex: '<[[:alnum:].]+>' /// Priority: 4 diff --git a/clang/include/clang/module.modulemap b/clang/include/clang/module.modulemap index e850a1cd4b9a..2b73cd5451b7 100644 --- a/clang/include/clang/module.modulemap +++ b/clang/include/clang/module.modulemap @@ -34,6 +34,8 @@ module Clang_Basic { textual header "Basic/AArch64SVEACLETypes.def" textual header "Basic/BuiltinsAArch64.def" textual header "Basic/BuiltinsAMDGPU.def" + textual header "Basic/BuiltinsAArch64NeonSVEBridge.def" + textual header "Basic/BuiltinsAArch64NeonSVEBridge_cg.def" textual header "Basic/BuiltinsARM.def" textual header "Basic/BuiltinsBPF.def" textual header "Basic/Builtins.def" |