diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2022-03-20 11:40:34 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2022-05-14 11:43:05 +0000 |
commit | 349cc55c9796c4596a5b9904cd3281af295f878f (patch) | |
tree | 410c5a785075730a35f1272ca6a7adf72222ad03 /contrib/llvm-project/clang/include | |
parent | cb2ae6163174b90e999326ecec3699ee093a5d43 (diff) | |
parent | c0981da47d5696fe36474fcf86b4ce03ae3ff818 (diff) | |
download | src-349cc55c9796c4596a5b9904cd3281af295f878f.tar.gz src-349cc55c9796c4596a5b9904cd3281af295f878f.zip |
Merge llvm-project main llvmorg-14-init-10186-gff7f2cfa959b
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14-init-10186-gff7f2cfa959b.
PR: 261742
MFC after: 2 weeks
Diffstat (limited to 'contrib/llvm-project/clang/include')
151 files changed, 4303 insertions, 1303 deletions
diff --git a/contrib/llvm-project/clang/include/clang-c/Index.h b/contrib/llvm-project/clang/include/clang-c/Index.h index 26844d1c74f3..b0d7ef509c26 100644 --- a/contrib/llvm-project/clang/include/clang-c/Index.h +++ b/contrib/llvm-project/clang/include/clang-c/Index.h @@ -2592,7 +2592,15 @@ enum CXCursorKind { */ CXCursor_OMPUnrollDirective = 293, - CXCursor_LastStmt = CXCursor_OMPUnrollDirective, + /** OpenMP metadirective directive. + */ + CXCursor_OMPMetaDirective = 294, + + /** OpenMP loop directive. + */ + CXCursor_OMPGenericLoopDirective = 295, + + CXCursor_LastStmt = CXCursor_OMPGenericLoopDirective, /** * Cursor that represents the translation unit itself. @@ -3298,8 +3306,9 @@ enum CXTypeKind { CXType_UAccum = 37, CXType_ULongAccum = 38, CXType_BFloat16 = 39, + CXType_Ibm128 = 40, CXType_FirstBuiltin = CXType_Void, - CXType_LastBuiltin = CXType_BFloat16, + CXType_LastBuiltin = CXType_Ibm128, CXType_Complex = 100, CXType_Pointer = 101, diff --git a/contrib/llvm-project/clang/include/clang/AST/ASTConcept.h b/contrib/llvm-project/clang/include/clang/AST/ASTConcept.h index d0526f4fa5c5..aba18b060b02 100644 --- a/contrib/llvm-project/clang/include/clang/AST/ASTConcept.h +++ b/contrib/llvm-project/clang/include/clang/AST/ASTConcept.h @@ -1,9 +1,8 @@ //===--- ASTConcept.h - Concepts Related AST Data Structures ----*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// /// diff --git a/contrib/llvm-project/clang/include/clang/AST/ASTContext.h b/contrib/llvm-project/clang/include/clang/AST/ASTContext.h index 34299581d89d..d336342e4cda 100644 --- a/contrib/llvm-project/clang/include/clang/AST/ASTContext.h +++ b/contrib/llvm-project/clang/include/clang/AST/ASTContext.h @@ -102,6 +102,7 @@ class ParentMapContext; class DynTypedNode; class DynTypedNodeList; class Expr; +enum class FloatModeKind; class GlobalDecl; class ItaniumMangleContext; class MangleContext; @@ -164,24 +165,46 @@ namespace serialization { template <class> class AbstractTypeReader; } // namespace serialization +enum class AlignRequirementKind { + /// The alignment was not explicit in code. + None, + + /// The alignment comes from an alignment attribute on a typedef. + RequiredByTypedef, + + /// The alignment comes from an alignment attribute on a record type. + RequiredByRecord, + + /// The alignment comes from an alignment attribute on a enum type. + RequiredByEnum, +}; + struct TypeInfo { uint64_t Width = 0; unsigned Align = 0; - bool AlignIsRequired : 1; + AlignRequirementKind AlignRequirement; - TypeInfo() : AlignIsRequired(false) {} - TypeInfo(uint64_t Width, unsigned Align, bool AlignIsRequired) - : Width(Width), Align(Align), AlignIsRequired(AlignIsRequired) {} + TypeInfo() : AlignRequirement(AlignRequirementKind::None) {} + TypeInfo(uint64_t Width, unsigned Align, + AlignRequirementKind AlignRequirement) + : Width(Width), Align(Align), AlignRequirement(AlignRequirement) {} + bool isAlignRequired() { + return AlignRequirement != AlignRequirementKind::None; + } }; struct TypeInfoChars { CharUnits Width; CharUnits Align; - bool AlignIsRequired : 1; + AlignRequirementKind AlignRequirement; - TypeInfoChars() : AlignIsRequired(false) {} - TypeInfoChars(CharUnits Width, CharUnits Align, bool AlignIsRequired) - : Width(Width), Align(Align), AlignIsRequired(AlignIsRequired) {} + TypeInfoChars() : AlignRequirement(AlignRequirementKind::None) {} + TypeInfoChars(CharUnits Width, CharUnits Align, + AlignRequirementKind AlignRequirement) + : Width(Width), Align(Align), AlignRequirement(AlignRequirement) {} + bool isAlignRequired() { + return AlignRequirement != AlignRequirementKind::None; + } }; /// Holds long-lived AST nodes (such as types and decls) that can be @@ -672,6 +695,12 @@ public: SourceManager& getSourceManager() { return SourceMgr; } const SourceManager& getSourceManager() const { return SourceMgr; } + // Cleans up some of the data structures. This allows us to do cleanup + // normally done in the destructor earlier. Renders much of the ASTContext + // unusable, mostly the actual AST nodes, so should be called when we no + // longer need access to the AST. + void cleanup(); + llvm::BumpPtrAllocator &getAllocator() const { return BumpAlloc; } @@ -728,7 +757,8 @@ public: /// getRealTypeForBitwidth - /// sets floating point QualTy according to specified bitwidth. /// Returns empty type if there is no appropriate target types. - QualType getRealTypeForBitwidth(unsigned DestWidth, bool ExplicitIEEE) const; + QualType getRealTypeForBitwidth(unsigned DestWidth, + FloatModeKind ExplicitType) const; bool AtomicUsesUnsupportedLibcall(const AtomicExpr *E) const; @@ -1054,7 +1084,7 @@ public: CanQualType SignedCharTy, ShortTy, IntTy, LongTy, LongLongTy, Int128Ty; CanQualType UnsignedCharTy, UnsignedShortTy, UnsignedIntTy, UnsignedLongTy; CanQualType UnsignedLongLongTy, UnsignedInt128Ty; - CanQualType FloatTy, DoubleTy, LongDoubleTy, Float128Ty; + CanQualType FloatTy, DoubleTy, LongDoubleTy, Float128Ty, Ibm128Ty; CanQualType ShortAccumTy, AccumTy, LongAccumTy; // ISO/IEC JTC1 SC22 WG14 N1169 Extension CanQualType UnsignedShortAccumTy, UnsignedAccumTy, UnsignedLongAccumTy; @@ -1069,8 +1099,6 @@ public: CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON CanQualType BFloat16Ty; CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3 - CanQualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy; - CanQualType Float128ComplexTy; CanQualType VoidPtrTy, NullPtrTy; CanQualType DependentTy, OverloadTy, BoundMemberTy, UnknownAnyTy; CanQualType BuiltinFnTy; @@ -1340,6 +1368,12 @@ public: /// Get address space for OpenCL type. LangAS getOpenCLTypeAddrSpace(const Type *T) const; + /// Returns default address space based on OpenCL version and enabled features + inline LangAS getDefaultOpenCLPointeeAddrSpace() { + return LangOpts.OpenCLGenericAddressSpace ? LangAS::opencl_generic + : LangAS::opencl_private; + } + void setcudaConfigureCallDecl(FunctionDecl *FD) { cudaConfigureCallDecl = FD; } @@ -1497,6 +1531,12 @@ private: QualType getFunctionTypeInternal(QualType ResultTy, ArrayRef<QualType> Args, const FunctionProtoType::ExtProtoInfo &EPI, bool OnlyWantCanonical) const; + QualType + getAutoTypeInternal(QualType DeducedType, AutoTypeKeyword Keyword, + bool IsDependent, bool IsPack = false, + ConceptDecl *TypeConstraintConcept = nullptr, + ArrayRef<TemplateArgument> TypeConstraintArgs = {}, + bool IsCanon = false) const; public: /// Return the unique reference to the type for the specified type @@ -1631,6 +1671,8 @@ public: QualType getTypeOfExprType(Expr *e) const; QualType getTypeOfType(QualType t) const; + QualType getReferenceQualifiedType(const Expr *e) const; + /// C++11 decltype. QualType getDecltypeType(Expr *e, QualType UnderlyingType) const; @@ -2505,8 +2547,10 @@ public: bool ObjCMethodsAreEqual(const ObjCMethodDecl *MethodDecl, const ObjCMethodDecl *MethodImp); - bool UnwrapSimilarTypes(QualType &T1, QualType &T2); - void UnwrapSimilarArrayTypes(QualType &T1, QualType &T2); + bool UnwrapSimilarTypes(QualType &T1, QualType &T2, + bool AllowPiMismatch = true); + void UnwrapSimilarArrayTypes(QualType &T1, QualType &T2, + bool AllowPiMismatch = true); /// Determine if two types are similar, according to the C++ rules. That is, /// determine if they are the same other than qualifiers on the initial @@ -3209,31 +3253,10 @@ public: StringRef getCUIDHash() const; - void AddSYCLKernelNamingDecl(const CXXRecordDecl *RD); - bool IsSYCLKernelNamingDecl(const NamedDecl *RD) const; - unsigned GetSYCLKernelNamingIndex(const NamedDecl *RD); - /// A SourceLocation to store whether we have evaluated a kernel name already, - /// and where it happened. If so, we need to diagnose an illegal use of the - /// builtin. - llvm::MapVector<const SYCLUniqueStableNameExpr *, std::string> - SYCLUniqueStableNameEvaluatedValues; - private: /// All OMPTraitInfo objects live in this collection, one per /// `pragma omp [begin] declare variant` directive. SmallVector<std::unique_ptr<OMPTraitInfo>, 4> OMPTraitInfoVector; - - /// A list of the (right now just lambda decls) declarations required to - /// name all the SYCL kernels in the translation unit, so that we can get the - /// correct kernel name, as well as implement - /// __builtin_sycl_unique_stable_name. - llvm::DenseMap<const DeclContext *, - llvm::SmallPtrSet<const CXXRecordDecl *, 4>> - SYCLKernelNamingTypes; - std::unique_ptr<ItaniumMangleContext> SYCLKernelFilterContext; - void FilterSYCLKernelNamingDecls( - const CXXRecordDecl *RD, - llvm::SmallVectorImpl<const CXXRecordDecl *> &Decls); }; /// Insertion operator for diagnostics. diff --git a/contrib/llvm-project/clang/include/clang/AST/ASTFwd.h b/contrib/llvm-project/clang/include/clang/AST/ASTFwd.h index 649b57113424..fdbd603ce5d0 100644 --- a/contrib/llvm-project/clang/include/clang/AST/ASTFwd.h +++ b/contrib/llvm-project/clang/include/clang/AST/ASTFwd.h @@ -30,6 +30,9 @@ class OMPClause; #define GEN_CLANG_CLAUSE_CLASS #define CLAUSE_CLASS(Enum, Str, Class) class Class; #include "llvm/Frontend/OpenMP/OMP.inc" +class Attr; +#define ATTR(A) class A##Attr; +#include "clang/Basic/AttrList.inc" } // end namespace clang diff --git a/contrib/llvm-project/clang/include/clang/AST/ASTImporter.h b/contrib/llvm-project/clang/include/clang/AST/ASTImporter.h index 17e673a8471a..c8bdae10a6e6 100644 --- a/contrib/llvm-project/clang/include/clang/AST/ASTImporter.h +++ b/contrib/llvm-project/clang/include/clang/AST/ASTImporter.h @@ -379,6 +379,9 @@ class TypeSourceInfo; return Import(const_cast<Decl *>(FromD)); } + llvm::Expected<InheritedConstructor> + Import(const InheritedConstructor &From); + /// Return the copy of the given declaration in the "to" context if /// it has already been imported from the "from" context. Otherwise return /// nullptr. diff --git a/contrib/llvm-project/clang/include/clang/AST/ASTImporterSharedState.h b/contrib/llvm-project/clang/include/clang/AST/ASTImporterSharedState.h index 829eb1c611c3..686a8e22b2fa 100644 --- a/contrib/llvm-project/clang/include/clang/AST/ASTImporterSharedState.h +++ b/contrib/llvm-project/clang/include/clang/AST/ASTImporterSharedState.h @@ -1,9 +1,8 @@ //===- ASTImporterSharedState.h - ASTImporter specific state --*- C++ -*---===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/contrib/llvm-project/clang/include/clang/AST/ASTStructuralEquivalence.h b/contrib/llvm-project/clang/include/clang/AST/ASTStructuralEquivalence.h index c958a16aba21..0b9e9e4e605f 100644 --- a/contrib/llvm-project/clang/include/clang/AST/ASTStructuralEquivalence.h +++ b/contrib/llvm-project/clang/include/clang/AST/ASTStructuralEquivalence.h @@ -117,7 +117,7 @@ struct StructuralEquivalenceContext { static llvm::Optional<unsigned> findUntaggedStructOrUnionIndex(RecordDecl *Anon); - // If ErrorOnTagTypeMismatch is set, return the the error, otherwise get the + // If ErrorOnTagTypeMismatch is set, return the error, otherwise get the // relevant warning for the input error diagnostic. unsigned getApplicableDiagnostic(unsigned ErrorDiagnostic); diff --git a/contrib/llvm-project/clang/include/clang/AST/ASTTypeTraits.h b/contrib/llvm-project/clang/include/clang/AST/ASTTypeTraits.h index 57195a9d6066..6d96146a4d45 100644 --- a/contrib/llvm-project/clang/include/clang/AST/ASTTypeTraits.h +++ b/contrib/llvm-project/clang/include/clang/AST/ASTTypeTraits.h @@ -17,6 +17,7 @@ #include "clang/AST/ASTFwd.h" #include "clang/AST/DeclCXX.h" +#include "clang/AST/LambdaCapture.h" #include "clang/AST/NestedNameSpecifier.h" #include "clang/AST/TemplateBase.h" #include "clang/AST/TypeLoc.h" @@ -25,10 +26,8 @@ #include "llvm/Support/AlignOf.h" namespace llvm { - class raw_ostream; - -} +} // namespace llvm namespace clang { @@ -65,7 +64,10 @@ public: static ASTNodeKind getFromNode(const Decl &D); static ASTNodeKind getFromNode(const Stmt &S); static ASTNodeKind getFromNode(const Type &T); + static ASTNodeKind getFromNode(const TypeLoc &T); + static ASTNodeKind getFromNode(const LambdaCapture &L); static ASTNodeKind getFromNode(const OMPClause &C); + static ASTNodeKind getFromNode(const Attr &A); /// \} /// Returns \c true if \c this and \c Other represent the same kind. @@ -131,9 +133,12 @@ private: NKI_None, NKI_TemplateArgument, NKI_TemplateArgumentLoc, + NKI_LambdaCapture, NKI_TemplateName, NKI_NestedNameSpecifierLoc, NKI_QualType, +#define TYPELOC(CLASS, PARENT) NKI_##CLASS##TypeLoc, +#include "clang/AST/TypeLocNodes.def" NKI_TypeLoc, NKI_LastKindWithoutPointerIdentity = NKI_TypeLoc, NKI_CXXBaseSpecifier, @@ -152,6 +157,9 @@ private: #define GEN_CLANG_CLAUSE_CLASS #define CLAUSE_CLASS(Enum, Str, Class) NKI_##Class, #include "llvm/Frontend/OpenMP/OMP.inc" + NKI_Attr, +#define ATTR(A) NKI_##A##Attr, +#include "clang/Basic/AttrList.inc" NKI_NumberOfKinds }; @@ -192,15 +200,19 @@ private: KIND_TO_KIND_ID(CXXCtorInitializer) KIND_TO_KIND_ID(TemplateArgument) KIND_TO_KIND_ID(TemplateArgumentLoc) +KIND_TO_KIND_ID(LambdaCapture) KIND_TO_KIND_ID(TemplateName) KIND_TO_KIND_ID(NestedNameSpecifier) KIND_TO_KIND_ID(NestedNameSpecifierLoc) KIND_TO_KIND_ID(QualType) +#define TYPELOC(CLASS, PARENT) KIND_TO_KIND_ID(CLASS##TypeLoc) +#include "clang/AST/TypeLocNodes.def" KIND_TO_KIND_ID(TypeLoc) KIND_TO_KIND_ID(Decl) KIND_TO_KIND_ID(Stmt) KIND_TO_KIND_ID(Type) KIND_TO_KIND_ID(OMPClause) +KIND_TO_KIND_ID(Attr) KIND_TO_KIND_ID(CXXBaseSpecifier) #define DECL(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Decl) #include "clang/AST/DeclNodes.inc" @@ -211,6 +223,8 @@ KIND_TO_KIND_ID(CXXBaseSpecifier) #define GEN_CLANG_CLAUSE_CLASS #define CLAUSE_CLASS(Enum, Str, Class) KIND_TO_KIND_ID(Class) #include "llvm/Frontend/OpenMP/OMP.inc" +#define ATTR(A) KIND_TO_KIND_ID(A##Attr) +#include "clang/Basic/AttrList.inc" #undef KIND_TO_KIND_ID inline raw_ostream &operator<<(raw_ostream &OS, ASTNodeKind K) { @@ -299,7 +313,7 @@ public: return getUnchecked<QualType>().getAsOpaquePtr() < Other.getUnchecked<QualType>().getAsOpaquePtr(); - if (ASTNodeKind::getFromNodeKind<TypeLoc>().isSame(NodeKind)) { + if (ASTNodeKind::getFromNodeKind<TypeLoc>().isBaseOf(NodeKind)) { auto TLA = getUnchecked<TypeLoc>(); auto TLB = Other.getUnchecked<TypeLoc>(); return std::make_pair(TLA.getType().getAsOpaquePtr(), @@ -331,7 +345,7 @@ public: if (ASTNodeKind::getFromNodeKind<QualType>().isSame(NodeKind)) return getUnchecked<QualType>() == Other.getUnchecked<QualType>(); - if (ASTNodeKind::getFromNodeKind<TypeLoc>().isSame(NodeKind)) + if (ASTNodeKind::getFromNodeKind<TypeLoc>().isBaseOf(NodeKind)) return getUnchecked<TypeLoc>() == Other.getUnchecked<TypeLoc>(); if (ASTNodeKind::getFromNodeKind<NestedNameSpecifierLoc>().isSame(NodeKind)) @@ -360,7 +374,7 @@ public: } static unsigned getHashValue(const DynTypedNode &Val) { // FIXME: Add hashing support for the remaining types. - if (ASTNodeKind::getFromNodeKind<TypeLoc>().isSame(Val.NodeKind)) { + if (ASTNodeKind::getFromNodeKind<TypeLoc>().isBaseOf(Val.NodeKind)) { auto TL = Val.getUnchecked<TypeLoc>(); return llvm::hash_combine(TL.getType().getAsOpaquePtr(), TL.getOpaqueData()); @@ -450,6 +464,29 @@ private: } }; + /// Converter that stores nodes by value. It must be possible to dynamically + /// cast the stored node within a type hierarchy without breaking (especially + /// through slicing). + template <typename T, typename BaseT, + typename = std::enable_if_t<(sizeof(T) == sizeof(BaseT))>> + struct DynCastValueConverter { + static const T *get(ASTNodeKind NodeKind, const void *Storage) { + if (ASTNodeKind::getFromNodeKind<T>().isBaseOf(NodeKind)) + return &getUnchecked(NodeKind, Storage); + return nullptr; + } + static const T &getUnchecked(ASTNodeKind NodeKind, const void *Storage) { + assert(ASTNodeKind::getFromNodeKind<T>().isBaseOf(NodeKind)); + return *static_cast<const T *>(reinterpret_cast<const BaseT *>(Storage)); + } + static DynTypedNode create(const T &Node) { + DynTypedNode Result; + Result.NodeKind = ASTNodeKind::getFromNode(Node); + new (&Result.Storage) T(Node); + return Result; + } + }; + ASTNodeKind NodeKind; /// Stores the data of the node. @@ -486,6 +523,11 @@ struct DynTypedNode::BaseConverter< T, std::enable_if_t<std::is_base_of<OMPClause, T>::value>> : public DynCastPtrConverter<T, OMPClause> {}; +template <typename T> +struct DynTypedNode::BaseConverter< + T, std::enable_if_t<std::is_base_of<Attr, T>::value>> + : public DynCastPtrConverter<T, Attr> {}; + template <> struct DynTypedNode::BaseConverter< NestedNameSpecifier, void> : public PtrConverter<NestedNameSpecifier> {}; @@ -503,6 +545,10 @@ struct DynTypedNode::BaseConverter<TemplateArgumentLoc, void> : public ValueConverter<TemplateArgumentLoc> {}; template <> +struct DynTypedNode::BaseConverter<LambdaCapture, void> + : public ValueConverter<LambdaCapture> {}; + +template <> struct DynTypedNode::BaseConverter< TemplateName, void> : public ValueConverter<TemplateName> {}; @@ -515,9 +561,10 @@ template <> struct DynTypedNode::BaseConverter<QualType, void> : public ValueConverter<QualType> {}; -template <> +template <typename T> struct DynTypedNode::BaseConverter< - TypeLoc, void> : public ValueConverter<TypeLoc> {}; + T, std::enable_if_t<std::is_base_of<TypeLoc, T>::value>> + : public DynCastValueConverter<T, TypeLoc> {}; template <> struct DynTypedNode::BaseConverter<CXXBaseSpecifier, void> diff --git a/contrib/llvm-project/clang/include/clang/AST/Attr.h b/contrib/llvm-project/clang/include/clang/AST/Attr.h index dbfecc125049..6366d6e8837e 100644 --- a/contrib/llvm-project/clang/include/clang/AST/Attr.h +++ b/contrib/llvm-project/clang/include/clang/AST/Attr.h @@ -109,6 +109,8 @@ public: // Pretty print this attribute. void printPretty(raw_ostream &OS, const PrintingPolicy &Policy) const; + + static StringRef getDocumentation(attr::Kind); }; class TypeAttr : public Attr { @@ -372,8 +374,7 @@ struct ParsedTargetAttr { inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB, const Attr *At) { - DB.AddTaggedVal(reinterpret_cast<intptr_t>(At), - DiagnosticsEngine::ak_attr); + DB.AddTaggedVal(reinterpret_cast<uint64_t>(At), DiagnosticsEngine::ak_attr); return DB; } } // end namespace clang diff --git a/contrib/llvm-project/clang/include/clang/AST/BuiltinTypes.def b/contrib/llvm-project/clang/include/clang/AST/BuiltinTypes.def index 039765dfdfea..c04f6f6f1271 100644 --- a/contrib/llvm-project/clang/include/clang/AST/BuiltinTypes.def +++ b/contrib/llvm-project/clang/include/clang/AST/BuiltinTypes.def @@ -218,6 +218,9 @@ FLOATING_TYPE(BFloat16, BFloat16Ty) // '__float128' FLOATING_TYPE(Float128, Float128Ty) +// '__ibm128' +FLOATING_TYPE(Ibm128, Ibm128Ty) + //===- Language-specific types --------------------------------------------===// // This is the type of C++0x 'nullptr'. diff --git a/contrib/llvm-project/clang/include/clang/AST/Comment.h b/contrib/llvm-project/clang/include/clang/AST/Comment.h index 54a4b0a9cfe6..4184e103206d 100644 --- a/contrib/llvm-project/clang/include/clang/AST/Comment.h +++ b/contrib/llvm-project/clang/include/clang/AST/Comment.h @@ -1019,8 +1019,6 @@ struct DeclInfo { /// \li member function template, /// \li member function template specialization, /// \li ObjC method, - /// \li a typedef for a function pointer, member function pointer, - /// ObjC block. FunctionKind, /// Something that we consider a "class": @@ -1030,8 +1028,8 @@ struct DeclInfo { ClassKind, /// Something that we consider a "variable": - /// \li namespace scope variables; - /// \li static and non-static class data members; + /// \li namespace scope variables and variable templates; + /// \li static and non-static class data members and member templates; /// \li enumerators. VariableKind, @@ -1076,6 +1074,9 @@ struct DeclInfo { /// Can be true only if \c IsFunctionDecl is true. unsigned IsClassMethod : 1; + /// Is \c CommentDecl something we consider a "function" that's variadic. + unsigned IsVariadic : 1; + void fill(); DeclKind getKind() const LLVM_READONLY { @@ -1085,6 +1086,8 @@ struct DeclInfo { TemplateDeclKind getTemplateKind() const LLVM_READONLY { return static_cast<TemplateDeclKind>(TemplateKind); } + + bool involvesFunctionType() const { return !ReturnType.isNull(); } }; /// A full comment attached to a declaration, contains block content. diff --git a/contrib/llvm-project/clang/include/clang/AST/CommentCommands.td b/contrib/llvm-project/clang/include/clang/AST/CommentCommands.td index fbbfc9f7e0b7..7e962a4b4171 100644 --- a/contrib/llvm-project/clang/include/clang/AST/CommentCommands.td +++ b/contrib/llvm-project/clang/include/clang/AST/CommentCommands.td @@ -87,8 +87,21 @@ def P : InlineCommand<"p">; def A : InlineCommand<"a">; def E : InlineCommand<"e">; def Em : InlineCommand<"em">; -def Ref : InlineCommand<"ref">; -def Anchor : InlineCommand<"anchor">; +def Emoji : InlineCommand<"emoji">; + +def Anchor : InlineCommand<"anchor">; +def Ref : InlineCommand<"ref">; +def RefItem : InlineCommand<"refitem">; +def Cite : InlineCommand<"cite">; + +def CopyBrief : InlineCommand<"copybrief">; +def CopyDetails : InlineCommand<"copydetails">; +def CopyDoc : InlineCommand<"copydoc">; + +// Typically not used inline, but they take a single word. +def Extends : InlineCommand<"extends">; +def Implements : InlineCommand<"implements">; +def MemberOf : InlineCommand<"memberof">; //===----------------------------------------------------------------------===// // BlockCommand @@ -145,9 +158,11 @@ def Retval : BlockCommand<"retval">; def Sa : BlockCommand<"sa">; def See : BlockCommand<"see">; def Since : BlockCommand<"since">; +def Test : BlockCommand<"test">; def Todo : BlockCommand<"todo">; def Version : BlockCommand<"version">; def Warning : BlockCommand<"warning">; +def XRefItem : BlockCommand<"xrefitem">; // HeaderDoc commands def Abstract : BlockCommand<"abstract"> { let IsBriefCommand = 1; } def ClassDesign : RecordLikeDetailCommand<"classdesign">; @@ -170,6 +185,8 @@ def SuperClass : RecordLikeDetailCommand<"superclass">; defm Code : VerbatimBlockCommand<"code", "endcode">; defm Verbatim : VerbatimBlockCommand<"verbatim", "endverbatim">; + +defm DocbookOnly : VerbatimBlockCommand<"docbookonly", "enddocbookonly">; defm Htmlonly : VerbatimBlockCommand<"htmlonly", "endhtmlonly">; defm Latexonly : VerbatimBlockCommand<"latexonly", "endlatexonly">; defm Xmlonly : VerbatimBlockCommand<"xmlonly", "endxmlonly">; @@ -178,10 +195,19 @@ defm Rtfonly : VerbatimBlockCommand<"rtfonly", "endrtfonly">; defm Dot : VerbatimBlockCommand<"dot", "enddot">; defm Msc : VerbatimBlockCommand<"msc", "endmsc">; +defm Uml : VerbatimBlockCommand<"startuml", "enduml">; + +// Actually not verbatim blocks, we should also parse commands within them. +defm Internal : VerbatimBlockCommand<"internal", "endinternal">; +// TODO: conflicts with HeaderDoc link, /link. +//defm Link : VerbatimBlockCommand<"link", "endlink">; +defm ParBlock : VerbatimBlockCommand<"parblock", "endparblock">; +defm SecRefList : VerbatimBlockCommand<"secreflist", "endsecreflist">; // These three commands have special support in CommentLexer to recognize their // names. def FDollar : VerbatimBlockCommand<"f$">; // Inline LaTeX formula +defm FParen : VerbatimBlockCommand<"f(", "f)">; // Inline LaTeX text defm FBracket : VerbatimBlockCommand<"f[", "f]">; // Displayed LaTeX formula defm FBrace : VerbatimBlockCommand<"f{", "f}">; // LaTeX environment @@ -199,11 +225,18 @@ def Addtogroup : VerbatimLineCommand<"addtogroup">; def Weakgroup : VerbatimLineCommand<"weakgroup">; def Name : VerbatimLineCommand<"name">; +// These actually take a single word, but it's optional. +// And they're used on a separate line typically, not inline. +def Dir : VerbatimLineCommand<"dir">; +def File : VerbatimLineCommand<"file">; + def Section : VerbatimLineCommand<"section">; def Subsection : VerbatimLineCommand<"subsection">; def Subsubsection : VerbatimLineCommand<"subsubsection">; def Paragraph : VerbatimLineCommand<"paragraph">; +def TableOfContents : VerbatimLineCommand<"tableofcontents">; +def Page : VerbatimLineCommand<"page">; def Mainpage : VerbatimLineCommand<"mainpage">; def Subpage : VerbatimLineCommand<"subpage">; @@ -212,13 +245,79 @@ def Related : VerbatimLineCommand<"related">; def RelatesAlso : VerbatimLineCommand<"relatesalso">; def RelatedAlso : VerbatimLineCommand<"relatedalso">; +def AddIndex : VerbatimLineCommand<"addindex">; + +// These take a single argument mostly, but since they include a file they'll +// typically be on their own line. +def DocbookInclude : VerbatimLineCommand<"docbookinclude">; +def DontInclude : VerbatimLineCommand<"dontinclude">; +def Example : VerbatimLineCommand<"example">; +def HtmlInclude : VerbatimLineCommand<"htmlinclude">; +def Include : VerbatimLineCommand<"include">; +def ManInclude : VerbatimLineCommand<"maninclude">; +def LatexInclude : VerbatimLineCommand<"latexinclude">; +def RtfInclude : VerbatimLineCommand<"rtfinclude">; +def Snippet : VerbatimLineCommand<"snippet">; +def VerbInclude : VerbatimLineCommand<"verbinclude">; +def XmlInclude : VerbatimLineCommand<"xmlinclude">; + +def Image : VerbatimLineCommand<"image">; +def DotFile : VerbatimLineCommand<"dotfile">; +def MscFile : VerbatimLineCommand<"mscfile">; +def DiaFile : VerbatimLineCommand<"diafile">; + +def Line : VerbatimLineCommand<"line">; +def Skip : VerbatimLineCommand<"skip">; +def SkipLine : VerbatimLineCommand<"skipline">; +def Until : VerbatimLineCommand<"until">; + +def NoOp : VerbatimLineCommand<"noop">; + +// These have actually no arguments, but we can treat them as line commands. +def CallGraph : VerbatimLineCommand<"callgraph">; +def HideCallGraph : VerbatimLineCommand<"hidecallgraph">; +def CallerGraph : VerbatimLineCommand<"callergraph">; +def HideCallerGraph : VerbatimLineCommand<"hidecallergraph">; +def ShowInitializer : VerbatimLineCommand<"showinitializer">; +def HideInitializer : VerbatimLineCommand<"hideinitializer">; +def ShowRefBy : VerbatimLineCommand<"showrefby">; +def HideRefBy : VerbatimLineCommand<"hiderefby">; +def ShowRefs : VerbatimLineCommand<"showrefs">; +def HideRefs : VerbatimLineCommand<"hiderefs">; + +// These also have no argument. +def Private : VerbatimLineCommand<"private">; +def Protected : VerbatimLineCommand<"protected">; +def Public : VerbatimLineCommand<"public">; +def Pure : VerbatimLineCommand<"pure">; +def Static : VerbatimLineCommand<"static">; + +// These also have no argument. +def NoSubgrouping : VerbatimLineCommand<"nosubgrouping">; +def PrivateSection : VerbatimLineCommand<"privatesection">; +def ProtectedSection : VerbatimLineCommand<"protectedsection">; +def PublicSection : VerbatimLineCommand<"publicsection">; + +// We might also build proper support for if/ifnot/else/elseif/endif. +def If : VerbatimLineCommand<"if">; +def IfNot : VerbatimLineCommand<"ifnot">; +def Else : VerbatimLineCommand<"else">; +def ElseIf : VerbatimLineCommand<"elseif">; +def Endif : VerbatimLineCommand<"endif">; + +// Not treated as VerbatimBlockCommand because it spans multiple comments. +def Cond : VerbatimLineCommand<"cond">; +def EndCond : VerbatimLineCommand<"endcond">; + //===----------------------------------------------------------------------===// // DeclarationVerbatimLineCommand //===----------------------------------------------------------------------===// // Doxygen commands. +def Concept : DeclarationVerbatimLineCommand<"concept">; def Def : DeclarationVerbatimLineCommand<"def">; def Fn : DeclarationVerbatimLineCommand<"fn">; +def IDLExcept : DeclarationVerbatimLineCommand<"idlexcept">; def Namespace : DeclarationVerbatimLineCommand<"namespace">; def Overload : DeclarationVerbatimLineCommand<"overload">; def Property : DeclarationVerbatimLineCommand<"property">; diff --git a/contrib/llvm-project/clang/include/clang/AST/CommentHTMLTags.td b/contrib/llvm-project/clang/include/clang/AST/CommentHTMLTags.td index 251490094940..a1ce8c6da96c 100644 --- a/contrib/llvm-project/clang/include/clang/AST/CommentHTMLTags.td +++ b/contrib/llvm-project/clang/include/clang/AST/CommentHTMLTags.td @@ -52,11 +52,11 @@ def Tr : Tag<"tr"> { let EndTagOptional = 1; } def Th : Tag<"th"> { let EndTagOptional = 1; } def Td : Tag<"td"> { let EndTagOptional = 1; } -// Define a blacklist of attributes that are not safe to pass through to HTML +// Define a list of attributes that are not safe to pass through to HTML // output if the input is untrusted. // -// FIXME: this should be a whitelist. When changing this to a whitelist, don't -// forget to change the default in the TableGen backend. +// FIXME: This should be a list of attributes that _are_ safe. When changing +// this change, don't forget to change the default in the TableGen backend. class Attribute<string spelling> { string Spelling = spelling; bit IsSafeToPassThrough = 1; diff --git a/contrib/llvm-project/clang/include/clang/AST/CommentSema.h b/contrib/llvm-project/clang/include/clang/AST/CommentSema.h index 6dfe0f4920d0..015ce8f8652a 100644 --- a/contrib/llvm-project/clang/include/clang/AST/CommentSema.h +++ b/contrib/llvm-project/clang/include/clang/AST/CommentSema.h @@ -181,6 +181,7 @@ public: FullComment *actOnFullComment(ArrayRef<BlockContentComment *> Blocks); +private: void checkBlockCommandEmptyParagraph(BlockCommandComment *Command); void checkReturnsCommand(const BlockCommandComment *Command); @@ -201,16 +202,16 @@ public: /// Emit diagnostics about unknown parametrs. void resolveParamCommandIndexes(const FullComment *FC); + /// \returns \c true if the declaration that this comment is attached to + /// is a pointer to function/method/block type or has such a type. + bool involvesFunctionType(); + bool isFunctionDecl(); bool isAnyFunctionDecl(); /// \returns \c true if declaration that this comment is attached to declares /// a function pointer. bool isFunctionPointerVarDecl(); - /// \returns \c true if the declaration that this comment is attached to - /// declares a variable or a field whose type is a function or a block - /// pointer. - bool isFunctionOrBlockPointerVarLikeDecl(); bool isFunctionOrMethodVariadic(); bool isObjCMethodDecl(); bool isObjCPropertyDecl(); diff --git a/contrib/llvm-project/clang/include/clang/AST/ComparisonCategories.h b/contrib/llvm-project/clang/include/clang/AST/ComparisonCategories.h index b41e934142ee..7b73b582fe2a 100644 --- a/contrib/llvm-project/clang/include/clang/AST/ComparisonCategories.h +++ b/contrib/llvm-project/clang/include/clang/AST/ComparisonCategories.h @@ -115,8 +115,7 @@ private: public: /// The declaration for the comparison category type from the /// standard library. - // FIXME: Make this const - CXXRecordDecl *Record = nullptr; + const CXXRecordDecl *Record = nullptr; /// The Kind of the comparison category type ComparisonCategoryType Kind; @@ -146,7 +145,7 @@ public: return Kind == CCK::PartialOrdering; } - /// Converts the specified result kind into the the correct result kind + /// Converts the specified result kind into the correct result kind /// for this category. Specifically it lowers strong equality results to /// weak equivalence if needed. ComparisonCategoryResult makeWeakResult(ComparisonCategoryResult Res) const { diff --git a/contrib/llvm-project/clang/include/clang/AST/CurrentSourceLocExprScope.h b/contrib/llvm-project/clang/include/clang/AST/CurrentSourceLocExprScope.h index 4ebbdf63abb5..34df8ce1309e 100644 --- a/contrib/llvm-project/clang/include/clang/AST/CurrentSourceLocExprScope.h +++ b/contrib/llvm-project/clang/include/clang/AST/CurrentSourceLocExprScope.h @@ -1,9 +1,8 @@ //===--- CurrentSourceLocExprScope.h ----------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/contrib/llvm-project/clang/include/clang/AST/Decl.h b/contrib/llvm-project/clang/include/clang/AST/Decl.h index 30a9458bc2ee..cc0e8de7c071 100644 --- a/contrib/llvm-project/clang/include/clang/AST/Decl.h +++ b/contrib/llvm-project/clang/include/clang/AST/Decl.h @@ -614,7 +614,9 @@ public: if (!isInline()) return false; auto X = lookup(Name); - auto Y = getParent()->lookup(Name); + // We should not perform a lookup within a transparent context, so find a + // non-transparent parent context. + auto Y = getParent()->getNonTransparentContext()->lookup(Name); return std::distance(X.begin(), X.end()) == std::distance(Y.begin(), Y.end()); } @@ -1987,8 +1989,8 @@ private: protected: FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, - TypeSourceInfo *TInfo, StorageClass S, bool isInlineSpecified, - ConstexprSpecKind ConstexprKind, + TypeSourceInfo *TInfo, StorageClass S, bool UsesFPIntrin, + bool isInlineSpecified, ConstexprSpecKind ConstexprKind, Expr *TrailingRequiresClause = nullptr); using redeclarable_base = Redeclarable<FunctionDecl>; @@ -2022,23 +2024,23 @@ public: static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, - TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified = false, - bool hasWrittenPrototype = true, + TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin = false, + bool isInlineSpecified = false, bool hasWrittenPrototype = true, ConstexprSpecKind ConstexprKind = ConstexprSpecKind::Unspecified, Expr *TrailingRequiresClause = nullptr) { DeclarationNameInfo NameInfo(N, NLoc); return FunctionDecl::Create(C, DC, StartLoc, NameInfo, T, TInfo, SC, - isInlineSpecified, hasWrittenPrototype, - ConstexprKind, TrailingRequiresClause); + UsesFPIntrin, isInlineSpecified, + hasWrittenPrototype, ConstexprKind, + TrailingRequiresClause); } - static FunctionDecl *Create(ASTContext &C, DeclContext *DC, - SourceLocation StartLoc, - const DeclarationNameInfo &NameInfo, QualType T, - TypeSourceInfo *TInfo, StorageClass SC, - bool isInlineSpecified, bool hasWrittenPrototype, - ConstexprSpecKind ConstexprKind, - Expr *TrailingRequiresClause); + static FunctionDecl * + Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, + const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, + StorageClass SC, bool UsesFPIntrin, bool isInlineSpecified, + bool hasWrittenPrototype, ConstexprSpecKind ConstexprKind, + Expr *TrailingRequiresClause); static FunctionDecl *CreateDeserialized(ASTContext &C, unsigned ID); @@ -2591,6 +2593,14 @@ public: FunctionDeclBits.IsInline = I; } + /// Determine whether the function was declared in source context + /// that requires constrained FP intrinsics + bool UsesFPIntrin() const { return FunctionDeclBits.UsesFPIntrin; } + + /// Set whether the function was declared in source context + /// that requires constrained FP intrinsics + void setUsesFPIntrin(bool I) { FunctionDeclBits.UsesFPIntrin = I; } + /// Flag that this function is implicitly inline. void setImplicitlyInline(bool I = true) { FunctionDeclBits.IsInline = I; } @@ -3688,6 +3698,10 @@ public: bool IsFixed); static EnumDecl *CreateDeserialized(ASTContext &C, unsigned ID); + /// Overrides to provide correct range when there's an enum-base specifier + /// with forward declarations. + SourceRange getSourceRange() const override LLVM_READONLY; + /// When created, the EnumDecl corresponds to a /// forward-declared enum. This method is used to mark the /// declaration as being defined; its enumerators have already been @@ -4576,7 +4590,7 @@ public: /// into a diagnostic with <<. inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &PD, const NamedDecl *ND) { - PD.AddTaggedVal(reinterpret_cast<intptr_t>(ND), + PD.AddTaggedVal(reinterpret_cast<uint64_t>(ND), DiagnosticsEngine::ak_nameddecl); return PD; } diff --git a/contrib/llvm-project/clang/include/clang/AST/DeclBase.h b/contrib/llvm-project/clang/include/clang/AST/DeclBase.h index 482d2889a25a..18468c8ca1c4 100644 --- a/contrib/llvm-project/clang/include/clang/AST/DeclBase.h +++ b/contrib/llvm-project/clang/include/clang/AST/DeclBase.h @@ -1997,6 +1997,12 @@ public: return const_cast<DeclContext*>(this)->getNonClosureAncestor(); } + // Retrieve the nearest context that is not a transparent context. + DeclContext *getNonTransparentContext(); + const DeclContext *getNonTransparentContext() const { + return const_cast<DeclContext *>(this)->getNonTransparentContext(); + } + /// getPrimaryContext - There may be many different /// declarations of the same entity (including forward declarations /// of classes, multiple definitions of namespaces, etc.), each with diff --git a/contrib/llvm-project/clang/include/clang/AST/DeclCXX.h b/contrib/llvm-project/clang/include/clang/AST/DeclCXX.h index 0d5ad40fc19e..cc7bfc86a521 100644 --- a/contrib/llvm-project/clang/include/clang/AST/DeclCXX.h +++ b/contrib/llvm-project/clang/include/clang/AST/DeclCXX.h @@ -1857,7 +1857,7 @@ private: TypeSourceInfo *TInfo, SourceLocation EndLocation, CXXConstructorDecl *Ctor) : FunctionDecl(CXXDeductionGuide, C, DC, StartLoc, NameInfo, T, TInfo, - SC_None, false, ConstexprSpecKind::Unspecified), + SC_None, false, false, ConstexprSpecKind::Unspecified), Ctor(Ctor), ExplicitSpec(ES) { if (EndLocation.isValid()) setRangeEnd(EndLocation); @@ -1952,23 +1952,22 @@ protected: CXXMethodDecl(Kind DK, ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, - bool isInline, ConstexprSpecKind ConstexprKind, - SourceLocation EndLocation, + bool UsesFPIntrin, bool isInline, + ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, Expr *TrailingRequiresClause = nullptr) - : FunctionDecl(DK, C, RD, StartLoc, NameInfo, T, TInfo, SC, isInline, - ConstexprKind, TrailingRequiresClause) { + : FunctionDecl(DK, C, RD, StartLoc, NameInfo, T, TInfo, SC, UsesFPIntrin, + isInline, ConstexprKind, TrailingRequiresClause) { if (EndLocation.isValid()) setRangeEnd(EndLocation); } public: - static CXXMethodDecl *Create(ASTContext &C, CXXRecordDecl *RD, - SourceLocation StartLoc, - const DeclarationNameInfo &NameInfo, QualType T, - TypeSourceInfo *TInfo, StorageClass SC, - bool isInline, ConstexprSpecKind ConstexprKind, - SourceLocation EndLocation, - Expr *TrailingRequiresClause = nullptr); + static CXXMethodDecl * + Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, + const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, + StorageClass SC, bool UsesFPIntrin, bool isInline, + ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, + Expr *TrailingRequiresClause = nullptr); static CXXMethodDecl *CreateDeserialized(ASTContext &C, unsigned ID); @@ -2413,7 +2412,8 @@ class CXXConstructorDecl final CXXConstructorDecl(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, - TypeSourceInfo *TInfo, ExplicitSpecifier ES, bool isInline, + TypeSourceInfo *TInfo, ExplicitSpecifier ES, + bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited, Expr *TrailingRequiresClause); @@ -2456,8 +2456,8 @@ public: static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, - ExplicitSpecifier ES, bool isInline, bool isImplicitlyDeclared, - ConstexprSpecKind ConstexprKind, + ExplicitSpecifier ES, bool UsesFPIntrin, bool isInline, + bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited = InheritedConstructor(), Expr *TrailingRequiresClause = nullptr); @@ -2676,25 +2676,24 @@ class CXXDestructorDecl : public CXXMethodDecl { CXXDestructorDecl(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, - TypeSourceInfo *TInfo, bool isInline, + TypeSourceInfo *TInfo, bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, Expr *TrailingRequiresClause = nullptr) : CXXMethodDecl(CXXDestructor, C, RD, StartLoc, NameInfo, T, TInfo, - SC_None, isInline, ConstexprKind, SourceLocation(), - TrailingRequiresClause) { + SC_None, UsesFPIntrin, isInline, ConstexprKind, + SourceLocation(), TrailingRequiresClause) { setImplicit(isImplicitlyDeclared); } void anchor() override; public: - static CXXDestructorDecl *Create(ASTContext &C, CXXRecordDecl *RD, - SourceLocation StartLoc, - const DeclarationNameInfo &NameInfo, - QualType T, TypeSourceInfo *TInfo, - bool isInline, bool isImplicitlyDeclared, - ConstexprSpecKind ConstexprKind, - Expr *TrailingRequiresClause = nullptr); + static CXXDestructorDecl * + Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, + const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, + bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared, + ConstexprSpecKind ConstexprKind, + Expr *TrailingRequiresClause = nullptr); static CXXDestructorDecl *CreateDeserialized(ASTContext & C, unsigned ID); void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg); @@ -2732,12 +2731,13 @@ public: class CXXConversionDecl : public CXXMethodDecl { CXXConversionDecl(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, - TypeSourceInfo *TInfo, bool isInline, ExplicitSpecifier ES, - ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, + TypeSourceInfo *TInfo, bool UsesFPIntrin, bool isInline, + ExplicitSpecifier ES, ConstexprSpecKind ConstexprKind, + SourceLocation EndLocation, Expr *TrailingRequiresClause = nullptr) : CXXMethodDecl(CXXConversion, C, RD, StartLoc, NameInfo, T, TInfo, - SC_None, isInline, ConstexprKind, EndLocation, - TrailingRequiresClause), + SC_None, UsesFPIntrin, isInline, ConstexprKind, + EndLocation, TrailingRequiresClause), ExplicitSpec(ES) {} void anchor() override; @@ -2750,8 +2750,9 @@ public: static CXXConversionDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, - bool isInline, ExplicitSpecifier ES, ConstexprSpecKind ConstexprKind, - SourceLocation EndLocation, Expr *TrailingRequiresClause = nullptr); + bool UsesFPIntrin, bool isInline, ExplicitSpecifier ES, + ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, + Expr *TrailingRequiresClause = nullptr); static CXXConversionDecl *CreateDeserialized(ASTContext &C, unsigned ID); ExplicitSpecifier getExplicitSpecifier() { diff --git a/contrib/llvm-project/clang/include/clang/AST/DeclContextInternals.h b/contrib/llvm-project/clang/include/clang/AST/DeclContextInternals.h index 2eef2343b750..9899fc29b82d 100644 --- a/contrib/llvm-project/clang/include/clang/AST/DeclContextInternals.h +++ b/contrib/llvm-project/clang/include/clang/AST/DeclContextInternals.h @@ -78,8 +78,7 @@ class StoredDeclsList { } Data.setPointer(NewHead); - assert(llvm::find_if(getLookupResult(), ShouldErase) == - getLookupResult().end() && "Still exists!"); + assert(llvm::none_of(getLookupResult(), ShouldErase) && "Still exists!"); } void erase(NamedDecl *ND) { diff --git a/contrib/llvm-project/clang/include/clang/AST/DeclObjC.h b/contrib/llvm-project/clang/include/clang/AST/DeclObjC.h index 6bb9cdf67034..79ec1d6e5c3c 100644 --- a/contrib/llvm-project/clang/include/clang/AST/DeclObjC.h +++ b/contrib/llvm-project/clang/include/clang/AST/DeclObjC.h @@ -487,6 +487,9 @@ public: /// True if the method is tagged as objc_direct bool isDirectMethod() const; + /// True if the method has a parameter that's destroyed in the callee. + bool hasParamDestroyedInCallee() const; + /// Returns the property associated with this method's selector. /// /// Note that even if this particular method is not marked as a property @@ -1955,6 +1958,13 @@ public: const ObjCIvarDecl *getNextIvar() const { return NextIvar; } void setNextIvar(ObjCIvarDecl *ivar) { NextIvar = ivar; } + ObjCIvarDecl *getCanonicalDecl() override { + return cast<ObjCIvarDecl>(FieldDecl::getCanonicalDecl()); + } + const ObjCIvarDecl *getCanonicalDecl() const { + return const_cast<ObjCIvarDecl *>(this)->getCanonicalDecl(); + } + void setAccessControl(AccessControl ac) { DeclAccess = ac; } AccessControl getAccessControl() const { return AccessControl(DeclAccess); } diff --git a/contrib/llvm-project/clang/include/clang/AST/DeclTemplate.h b/contrib/llvm-project/clang/include/clang/AST/DeclTemplate.h index cbaa287f225a..d33babef958e 100755 --- a/contrib/llvm-project/clang/include/clang/AST/DeclTemplate.h +++ b/contrib/llvm-project/clang/include/clang/AST/DeclTemplate.h @@ -203,7 +203,8 @@ public: void print(raw_ostream &Out, const ASTContext &Context, const PrintingPolicy &Policy, bool OmitTemplateKW = false) const; - static bool shouldIncludeTypeForArgument(const TemplateParameterList *TPL, + static bool shouldIncludeTypeForArgument(const PrintingPolicy &Policy, + const TemplateParameterList *TPL, unsigned Idx); }; @@ -729,6 +730,10 @@ public: /// Returns the number of explicit template arguments that were given. unsigned getNumTemplateArgs() const { return NumArgs; } + llvm::ArrayRef<TemplateArgumentLoc> arguments() const { + return llvm::makeArrayRef(getTemplateArgs(), getNumTemplateArgs()); + } + /// Returns the nth template argument. const TemplateArgumentLoc &getTemplateArg(unsigned I) const { assert(I < getNumTemplateArgs() && "template arg index out of range"); @@ -1189,7 +1194,7 @@ class TemplateTypeParmDecl final : public TypeDecl, /// Whether the type constraint has been initialized. This can be false if the /// constraint was not initialized yet or if there was an error forming the - /// type constriant. + /// type constraint. bool TypeConstraintInitialized : 1; /// Whether this non-type template parameter is an "expanded" diff --git a/contrib/llvm-project/clang/include/clang/AST/Expr.h b/contrib/llvm-project/clang/include/clang/AST/Expr.h index 8efa8fdbe2bb..5d42e5284a56 100644 --- a/contrib/llvm-project/clang/include/clang/AST/Expr.h +++ b/contrib/llvm-project/clang/include/clang/AST/Expr.h @@ -739,6 +739,12 @@ public: bool tryEvaluateObjectSize(uint64_t &Result, ASTContext &Ctx, unsigned Type) const; + /// If the current Expr is a pointer, this will try to statically + /// determine the strlen of the string pointed to. + /// Returns true if all of the above holds and we were able to figure out the + /// strlen, false otherwise. + bool tryEvaluateStrLen(uint64_t &Result, ASTContext &Ctx) const; + /// Enumeration used to describe the kind of Null pointer constant /// returned from \c isNullPointerConstant(). enum NullPointerConstantKind { diff --git a/contrib/llvm-project/clang/include/clang/AST/JSONNodeDumper.h b/contrib/llvm-project/clang/include/clang/AST/JSONNodeDumper.h index a96e21993e20..5638df42a1c5 100644 --- a/contrib/llvm-project/clang/include/clang/AST/JSONNodeDumper.h +++ b/contrib/llvm-project/clang/include/clang/AST/JSONNodeDumper.h @@ -1,9 +1,8 @@ //===--- JSONNodeDumper.h - Printing of AST nodes to JSON -----------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/contrib/llvm-project/clang/include/clang/AST/LambdaCapture.h b/contrib/llvm-project/clang/include/clang/AST/LambdaCapture.h index 8e2806545dd6..7ad1e2361e42 100644 --- a/contrib/llvm-project/clang/include/clang/AST/LambdaCapture.h +++ b/contrib/llvm-project/clang/include/clang/AST/LambdaCapture.h @@ -86,7 +86,7 @@ public: /// Determine whether this capture handles a variable. bool capturesVariable() const { - return dyn_cast_or_null<VarDecl>(DeclAndBits.getPointer()); + return isa_and_nonnull<VarDecl>(DeclAndBits.getPointer()); } /// Determine whether this captures a variable length array bound diff --git a/contrib/llvm-project/clang/include/clang/AST/NestedNameSpecifier.h b/contrib/llvm-project/clang/include/clang/AST/NestedNameSpecifier.h index 8bc3e25c0f4b..eb01780598a7 100644 --- a/contrib/llvm-project/clang/include/clang/AST/NestedNameSpecifier.h +++ b/contrib/llvm-project/clang/include/clang/AST/NestedNameSpecifier.h @@ -521,7 +521,7 @@ public: /// NestedNameSpecifiers into a diagnostic with <<. inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB, NestedNameSpecifier *NNS) { - DB.AddTaggedVal(reinterpret_cast<intptr_t>(NNS), + DB.AddTaggedVal(reinterpret_cast<uint64_t>(NNS), DiagnosticsEngine::ak_nestednamespec); return DB; } diff --git a/contrib/llvm-project/clang/include/clang/AST/OpenMPClause.h b/contrib/llvm-project/clang/include/clang/AST/OpenMPClause.h index aaddcfa307da..565eb0c9cf99 100644 --- a/contrib/llvm-project/clang/include/clang/AST/OpenMPClause.h +++ b/contrib/llvm-project/clang/include/clang/AST/OpenMPClause.h @@ -322,6 +322,81 @@ public: } }; +/// This represents the 'align' clause in the '#pragma omp allocate' +/// directive. +/// +/// \code +/// #pragma omp allocate(a) allocator(omp_default_mem_alloc) align(8) +/// \endcode +/// In this example directive '#pragma omp allocate' has simple 'allocator' +/// clause with the allocator 'omp_default_mem_alloc' and align clause with +/// value of 8. +class OMPAlignClause final : public OMPClause { + friend class OMPClauseReader; + + /// Location of '('. + SourceLocation LParenLoc; + + /// Alignment specified with align clause. + Stmt *Alignment = nullptr; + + /// Set alignment value. + void setAlignment(Expr *A) { Alignment = A; } + + /// Sets the location of '('. + void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } + + /// Build 'align' clause with the given alignment + /// + /// \param A Alignment value. + /// \param StartLoc Starting location of the clause. + /// \param LParenLoc Location of '('. + /// \param EndLoc Ending location of the clause. + OMPAlignClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, + SourceLocation EndLoc) + : OMPClause(llvm::omp::OMPC_align, StartLoc, EndLoc), + LParenLoc(LParenLoc), Alignment(A) {} + + /// Build an empty clause. + OMPAlignClause() + : OMPClause(llvm::omp::OMPC_align, SourceLocation(), SourceLocation()) {} + +public: + /// Build 'align' clause with the given alignment + /// + /// \param A Alignment value. + /// \param StartLoc Starting location of the clause. + /// \param LParenLoc Location of '('. + /// \param EndLoc Ending location of the clause. + static OMPAlignClause *Create(const ASTContext &C, Expr *A, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc); + + /// Returns the location of '('. + SourceLocation getLParenLoc() const { return LParenLoc; } + + /// Returns alignment + Expr *getAlignment() const { return cast_or_null<Expr>(Alignment); } + + child_range children() { return child_range(&Alignment, &Alignment + 1); } + + const_child_range children() const { + return const_child_range(&Alignment, &Alignment + 1); + } + + 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_align; + } +}; + /// This represents clause 'allocate' in the '#pragma omp ...' directives. /// /// \code @@ -2005,13 +2080,13 @@ class OMPUpdateClause final return IsExtended ? 2 : 0; } - /// Sets the the location of '(' in clause for 'depobj' directive. + /// Sets the location of '(' in clause for 'depobj' directive. void setLParenLoc(SourceLocation Loc) { assert(IsExtended && "Expected extended clause."); *getTrailingObjects<SourceLocation>() = Loc; } - /// Sets the the location of '(' in clause for 'depobj' directive. + /// Sets the location of '(' in clause for 'depobj' directive. void setArgumentLoc(SourceLocation Loc) { assert(IsExtended && "Expected extended clause."); *std::next(getTrailingObjects<SourceLocation>(), 1) = Loc; @@ -2085,13 +2160,13 @@ public: return const_child_range(const_child_iterator(), const_child_iterator()); } - /// Gets the the location of '(' in clause for 'depobj' directive. + /// Gets the location of '(' in clause for 'depobj' directive. SourceLocation getLParenLoc() const { assert(IsExtended && "Expected extended clause."); return *getTrailingObjects<SourceLocation>(); } - /// Gets the the location of argument in clause for 'depobj' directive. + /// Gets the location of argument in clause for 'depobj' directive. SourceLocation getArgumentLoc() const { assert(IsExtended && "Expected extended clause."); return *std::next(getTrailingObjects<SourceLocation>(), 1); @@ -5606,7 +5681,8 @@ private: /// Map-type-modifiers for the 'map' clause. OpenMPMapModifierKind MapTypeModifiers[NumberOfOMPMapClauseModifiers] = { OMPC_MAP_MODIFIER_unknown, OMPC_MAP_MODIFIER_unknown, - OMPC_MAP_MODIFIER_unknown, OMPC_MAP_MODIFIER_unknown}; + OMPC_MAP_MODIFIER_unknown, OMPC_MAP_MODIFIER_unknown, + OMPC_MAP_MODIFIER_unknown}; /// Location of map-type-modifiers for the 'map' clause. SourceLocation MapTypeModifiersLoc[NumberOfOMPMapClauseModifiers]; @@ -8404,6 +8480,96 @@ public: } }; +/// This represents 'bind' clause in the '#pragma omp ...' directives. +/// +/// \code +/// #pragma omp loop bind(parallel) +/// \endcode +class OMPBindClause final : public OMPClause { + friend class OMPClauseReader; + + /// Location of '('. + SourceLocation LParenLoc; + + /// The binding kind of 'bind' clause. + OpenMPBindClauseKind Kind = OMPC_BIND_unknown; + + /// Start location of the kind in source code. + SourceLocation KindLoc; + + /// Sets the location of '('. + void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } + + /// Set the binding kind. + void setBindKind(OpenMPBindClauseKind K) { Kind = K; } + + /// Set the binding kind location. + void setBindKindLoc(SourceLocation KLoc) { KindLoc = KLoc; } + + /// Build 'bind' clause with kind \a K ('teams', 'parallel', or 'thread'). + /// + /// \param K Binding kind of the clause ('teams', 'parallel' or 'thread'). + /// \param KLoc Starting location of the binding kind. + /// \param StartLoc Starting location of the clause. + /// \param LParenLoc Location of '('. + /// \param EndLoc Ending location of the clause. + OMPBindClause(OpenMPBindClauseKind K, SourceLocation KLoc, + SourceLocation StartLoc, SourceLocation LParenLoc, + SourceLocation EndLoc) + : OMPClause(llvm::omp::OMPC_bind, StartLoc, EndLoc), LParenLoc(LParenLoc), + Kind(K), KindLoc(KLoc) {} + + /// Build an empty clause. + OMPBindClause() + : OMPClause(llvm::omp::OMPC_bind, SourceLocation(), SourceLocation()) {} + +public: + /// Build 'bind' clause with kind \a K ('teams', 'parallel', or 'thread'). + /// + /// \param C AST context + /// \param K Binding kind of the clause ('teams', 'parallel' or 'thread'). + /// \param KLoc Starting location of the binding kind. + /// \param StartLoc Starting location of the clause. + /// \param LParenLoc Location of '('. + /// \param EndLoc Ending location of the clause. + static OMPBindClause *Create(const ASTContext &C, OpenMPBindClauseKind K, + SourceLocation KLoc, SourceLocation StartLoc, + SourceLocation LParenLoc, SourceLocation EndLoc); + + /// Build an empty 'bind' clause. + /// + /// \param C AST context + static OMPBindClause *CreateEmpty(const ASTContext &C); + + /// Returns the location of '('. + SourceLocation getLParenLoc() const { return LParenLoc; } + + /// Returns kind of the clause. + OpenMPBindClauseKind getBindKind() const { return Kind; } + + /// Returns location of clause kind. + SourceLocation getBindKindLoc() const { return KindLoc; } + + 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_bind; + } +}; + /// This class implements a simple visitor for OMPClause /// subclasses. template<class ImplClass, template <typename> class Ptr, typename RetTy> @@ -8546,10 +8712,11 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo *TI); /// Clang specific specialization of the OMPContext to lookup target features. struct TargetOMPContext final : public llvm::omp::OMPContext { - TargetOMPContext(ASTContext &ASTCtx, std::function<void(StringRef)> &&DiagUnknownTrait, - const FunctionDecl *CurrentFunctionDecl); + const FunctionDecl *CurrentFunctionDecl, + ArrayRef<llvm::omp::TraitProperty> ConstructTraits); + virtual ~TargetOMPContext() = default; /// See llvm::omp::OMPContext::matchesISATrait diff --git a/contrib/llvm-project/clang/include/clang/AST/PrettyPrinter.h b/contrib/llvm-project/clang/include/clang/AST/PrettyPrinter.h index 3baf2b2ba94d..f6816e938f2a 100644 --- a/contrib/llvm-project/clang/include/clang/AST/PrettyPrinter.h +++ b/contrib/llvm-project/clang/include/clang/AST/PrettyPrinter.h @@ -74,7 +74,8 @@ struct PrintingPolicy { MSWChar(LO.MicrosoftExt && !LO.WChar), IncludeNewlines(true), MSVCFormatting(false), ConstantsAsWritten(false), SuppressImplicitBase(false), FullyQualifiedName(false), - PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true) {} + PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true), + UsePreferredNames(true), AlwaysIncludeTypeForTemplateArgument(false) {} /// Adjust this printing policy for cases where it's known that we're /// printing C++ code (for instance, if AST dumping reaches a C++-only @@ -273,6 +274,14 @@ struct PrintingPolicy { /// invalid C++ code. unsigned PrintInjectedClassNameWithArguments : 1; + /// Whether to use C++ template preferred_name attributes when printing + /// templates. + unsigned UsePreferredNames : 1; + + /// Whether to use type suffixes (eg: 1U) on integral non-type template + /// parameters. + unsigned AlwaysIncludeTypeForTemplateArgument : 1; + /// Callbacks to use to allow the behavior of printing to be customized. const PrintingCallbacks *Callbacks = nullptr; }; diff --git a/contrib/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h b/contrib/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h index 9bfa5b9c2326..9797eac53dde 100644 --- a/contrib/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/contrib/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h @@ -1681,10 +1681,7 @@ bool RecursiveASTVisitor<Derived>::TraverseTemplateInstantiations( ClassTemplateDecl *D) { for (auto *SD : D->specializations()) { for (auto *RD : SD->redecls()) { - // We don't want to visit injected-class-names in this traversal. - if (cast<CXXRecordDecl>(RD)->isInjectedClassName()) - continue; - + assert(!cast<CXXRecordDecl>(RD)->isInjectedClassName()); switch ( cast<ClassTemplateSpecializationDecl>(RD)->getSpecializationKind()) { // Visit the implicit instantiations with the requested pattern. @@ -1863,10 +1860,9 @@ DEF_TRAVERSE_DECL(UnresolvedUsingIfExistsDecl, {}) DEF_TRAVERSE_DECL(EnumDecl, { TRY_TO(TraverseDeclTemplateParameterLists(D)); - if (D->getTypeForDecl()) - TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0))); - TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc())); + if (auto *TSI = D->getIntegerTypeSourceInfo()) + TRY_TO(TraverseTypeLoc(TSI->getTypeLoc())); // The enumerators are already traversed by // decls_begin()/decls_end(). }) @@ -2842,6 +2838,9 @@ RecursiveASTVisitor<Derived>::TraverseOMPLoopDirective(OMPLoopDirective *S) { return TraverseOMPExecutableDirective(S); } +DEF_TRAVERSE_STMT(OMPMetaDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + DEF_TRAVERSE_STMT(OMPParallelDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) @@ -3021,6 +3020,9 @@ DEF_TRAVERSE_STMT(OMPDispatchDirective, DEF_TRAVERSE_STMT(OMPMaskedDirective, { TRY_TO(TraverseOMPExecutableDirective(S)); }) +DEF_TRAVERSE_STMT(OMPGenericLoopDirective, + { TRY_TO(TraverseOMPExecutableDirective(S)); }) + // OpenMP clauses. template <typename Derived> bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) { @@ -3092,6 +3094,12 @@ RecursiveASTVisitor<Derived>::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) { } template <typename Derived> +bool RecursiveASTVisitor<Derived>::VisitOMPAlignClause(OMPAlignClause *C) { + TRY_TO(TraverseStmt(C->getAlignment())); + return true; +} + +template <typename Derived> bool RecursiveASTVisitor<Derived>::VisitOMPSafelenClause(OMPSafelenClause *C) { TRY_TO(TraverseStmt(C->getSafelen())); return true; @@ -3674,6 +3682,11 @@ bool RecursiveASTVisitor<Derived>::VisitOMPFilterClause(OMPFilterClause *C) { return true; } +template <typename Derived> +bool RecursiveASTVisitor<Derived>::VisitOMPBindClause(OMPBindClause *C) { + return true; +} + // FIXME: look at the following tricky-seeming exprs to see if we // need to recurse on anything. These are ones that have methods // returning decls or qualtypes or nestednamespecifier -- though I'm diff --git a/contrib/llvm-project/clang/include/clang/AST/Stmt.h b/contrib/llvm-project/clang/include/clang/AST/Stmt.h index 8e1d7df97096..a32126d23d31 100644 --- a/contrib/llvm-project/clang/include/clang/AST/Stmt.h +++ b/contrib/llvm-project/clang/include/clang/AST/Stmt.h @@ -20,6 +20,7 @@ #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/SourceLocation.h" +#include "clang/Basic/Specifiers.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/BitmaskEnum.h" #include "llvm/ADT/PointerIntPair.h" @@ -160,8 +161,8 @@ protected: unsigned : NumStmtBits; - /// True if this if statement is a constexpr if. - unsigned IsConstexpr : 1; + /// Whether this is a constexpr if, or a consteval if, or neither. + unsigned Kind : 3; /// True if this if statement has storage for an else statement. unsigned HasElse : 1; @@ -1215,6 +1216,11 @@ public: const PrintingPolicy &Policy, unsigned Indentation = 0, StringRef NewlineSymbol = "\n", const ASTContext *Context = nullptr) const; + void printPrettyControlled(raw_ostream &OS, PrinterHelper *Helper, + const PrintingPolicy &Policy, + unsigned Indentation = 0, + StringRef NewlineSymbol = "\n", + const ASTContext *Context = nullptr) const; /// Pretty-prints in JSON format. void printJson(raw_ostream &Out, PrinterHelper *Helper, @@ -1950,8 +1956,8 @@ class IfStmt final unsigned elseOffset() const { return condOffset() + ElseOffsetFromCond; } /// Build an if/then/else statement. - IfStmt(const ASTContext &Ctx, SourceLocation IL, bool IsConstexpr, Stmt *Init, - VarDecl *Var, Expr *Cond, SourceLocation LParenLoc, + IfStmt(const ASTContext &Ctx, SourceLocation IL, IfStatementKind Kind, + Stmt *Init, VarDecl *Var, Expr *Cond, SourceLocation LParenLoc, SourceLocation RParenLoc, Stmt *Then, SourceLocation EL, Stmt *Else); /// Build an empty if/then/else statement. @@ -1960,9 +1966,9 @@ class IfStmt final public: /// Create an IfStmt. static IfStmt *Create(const ASTContext &Ctx, SourceLocation IL, - bool IsConstexpr, Stmt *Init, VarDecl *Var, Expr *Cond, - SourceLocation LPL, SourceLocation RPL, Stmt *Then, - SourceLocation EL = SourceLocation(), + IfStatementKind Kind, Stmt *Init, VarDecl *Var, + Expr *Cond, SourceLocation LPL, SourceLocation RPL, + Stmt *Then, SourceLocation EL = SourceLocation(), Stmt *Else = nullptr); /// Create an empty IfStmt optionally with storage for an else statement, @@ -2077,8 +2083,30 @@ public: *getTrailingObjects<SourceLocation>() = ElseLoc; } - bool isConstexpr() const { return IfStmtBits.IsConstexpr; } - void setConstexpr(bool C) { IfStmtBits.IsConstexpr = C; } + bool isConsteval() const { + return getStatementKind() == IfStatementKind::ConstevalNonNegated || + getStatementKind() == IfStatementKind::ConstevalNegated; + } + + bool isNonNegatedConsteval() const { + return getStatementKind() == IfStatementKind::ConstevalNonNegated; + } + + bool isNegatedConsteval() const { + return getStatementKind() == IfStatementKind::ConstevalNegated; + } + + bool isConstexpr() const { + return getStatementKind() == IfStatementKind::Constexpr; + } + + void setStatementKind(IfStatementKind Kind) { + IfStmtBits.Kind = static_cast<unsigned>(Kind); + } + + IfStatementKind getStatementKind() const { + return static_cast<IfStatementKind>(IfStmtBits.Kind); + } /// If this is an 'if constexpr', determine which substatement will be taken. /// Otherwise, or if the condition is value-dependent, returns None. @@ -2101,13 +2129,19 @@ public: // Iterators over subexpressions. The iterators will include iterating // over the initialization expression referenced by the condition variable. child_range children() { - return child_range(getTrailingObjects<Stmt *>(), + // We always store a condition, but there is none for consteval if + // statements, so skip it. + return child_range(getTrailingObjects<Stmt *>() + + (isConsteval() ? thenOffset() : 0), getTrailingObjects<Stmt *>() + numTrailingObjects(OverloadToken<Stmt *>())); } const_child_range children() const { - return const_child_range(getTrailingObjects<Stmt *>(), + // We always store a condition, but there is none for consteval if + // statements, so skip it. + return const_child_range(getTrailingObjects<Stmt *>() + + (isConsteval() ? thenOffset() : 0), getTrailingObjects<Stmt *>() + numTrailingObjects(OverloadToken<Stmt *>())); } diff --git a/contrib/llvm-project/clang/include/clang/AST/StmtObjC.h b/contrib/llvm-project/clang/include/clang/AST/StmtObjC.h index 948ef2421cb9..c46ff4634c82 100644 --- a/contrib/llvm-project/clang/include/clang/AST/StmtObjC.h +++ b/contrib/llvm-project/clang/include/clang/AST/StmtObjC.h @@ -162,8 +162,14 @@ public: }; /// Represents Objective-C's \@try ... \@catch ... \@finally statement. -class ObjCAtTryStmt : public Stmt { -private: +class ObjCAtTryStmt final + : public Stmt, + private llvm::TrailingObjects<ObjCAtTryStmt, Stmt *> { + friend TrailingObjects; + size_t numTrailingObjects(OverloadToken<Stmt *>) const { + return 1 + NumCatchStmts + HasFinally; + } + // The location of the @ in the \@try. SourceLocation AtTryLoc; @@ -178,10 +184,8 @@ private: /// The order of the statements in memory follows the order in the source, /// with the \@try body first, followed by the \@catch statements (if any) /// and, finally, the \@finally (if it exists). - Stmt **getStmts() { return reinterpret_cast<Stmt **> (this + 1); } - const Stmt* const *getStmts() const { - return reinterpret_cast<const Stmt * const*> (this + 1); - } + Stmt **getStmts() { return getTrailingObjects<Stmt *>(); } + Stmt *const *getStmts() const { return getTrailingObjects<Stmt *>(); } ObjCAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt, Stmt **CatchStmts, unsigned NumCatchStmts, @@ -257,13 +261,34 @@ public: } child_range children() { - return child_range(getStmts(), - getStmts() + 1 + NumCatchStmts + HasFinally); + return child_range( + getStmts(), getStmts() + numTrailingObjects(OverloadToken<Stmt *>())); } const_child_range children() const { return const_child_range(const_cast<ObjCAtTryStmt *>(this)->children()); } + + using catch_stmt_iterator = CastIterator<ObjCAtCatchStmt>; + using const_catch_stmt_iterator = ConstCastIterator<ObjCAtCatchStmt>; + using catch_range = llvm::iterator_range<catch_stmt_iterator>; + using catch_const_range = llvm::iterator_range<const_catch_stmt_iterator>; + + catch_stmt_iterator catch_stmts_begin() { return getStmts() + 1; } + catch_stmt_iterator catch_stmts_end() { + return catch_stmts_begin() + NumCatchStmts; + } + catch_range catch_stmts() { + return catch_range(catch_stmts_begin(), catch_stmts_end()); + } + + const_catch_stmt_iterator catch_stmts_begin() const { return getStmts() + 1; } + const_catch_stmt_iterator catch_stmts_end() const { + return catch_stmts_begin() + NumCatchStmts; + } + catch_const_range catch_stmts() const { + return catch_const_range(catch_stmts_begin(), catch_stmts_end()); + } }; /// Represents Objective-C's \@synchronized statement. diff --git a/contrib/llvm-project/clang/include/clang/AST/StmtOpenMP.h b/contrib/llvm-project/clang/include/clang/AST/StmtOpenMP.h index 9c85df741f48..d5b5c9580da9 100644 --- a/contrib/llvm-project/clang/include/clang/AST/StmtOpenMP.h +++ b/contrib/llvm-project/clang/include/clang/AST/StmtOpenMP.h @@ -889,22 +889,23 @@ public: /// Calls the specified callback function for all the loops in \p CurStmt, /// from the outermost to the innermost. - static bool doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops, - unsigned NumLoops, - llvm::function_ref<bool(unsigned, Stmt *)> Callback, - llvm::function_ref<void(OMPLoopBasedDirective *)> - OnTransformationCallback); + static bool + doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops, + unsigned NumLoops, + llvm::function_ref<bool(unsigned, Stmt *)> Callback, + llvm::function_ref<void(OMPLoopTransformationDirective *)> + OnTransformationCallback); static bool doForAllLoops(const Stmt *CurStmt, bool TryImperfectlyNestedLoops, unsigned NumLoops, llvm::function_ref<bool(unsigned, const Stmt *)> Callback, - llvm::function_ref<void(const OMPLoopBasedDirective *)> + llvm::function_ref<void(const OMPLoopTransformationDirective *)> OnTransformationCallback) { auto &&NewCallback = [Callback](unsigned Cnt, Stmt *CurStmt) { return Callback(Cnt, CurStmt); }; auto &&NewTransformCb = - [OnTransformationCallback](OMPLoopBasedDirective *A) { + [OnTransformationCallback](OMPLoopTransformationDirective *A) { OnTransformationCallback(A); }; return doForAllLoops(const_cast<Stmt *>(CurStmt), TryImperfectlyNestedLoops, @@ -917,7 +918,7 @@ public: doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops, unsigned NumLoops, llvm::function_ref<bool(unsigned, Stmt *)> Callback) { - auto &&TransformCb = [](OMPLoopBasedDirective *) {}; + auto &&TransformCb = [](OMPLoopTransformationDirective *) {}; return doForAllLoops(CurStmt, TryImperfectlyNestedLoops, NumLoops, Callback, TransformCb); } @@ -954,6 +955,47 @@ public: } }; +/// The base class for all loop transformation directives. +class OMPLoopTransformationDirective : public OMPLoopBasedDirective { + friend class ASTStmtReader; + + /// Number of loops generated by this loop transformation. + unsigned NumGeneratedLoops = 0; + +protected: + explicit OMPLoopTransformationDirective(StmtClass SC, + OpenMPDirectiveKind Kind, + SourceLocation StartLoc, + SourceLocation EndLoc, + unsigned NumAssociatedLoops) + : OMPLoopBasedDirective(SC, Kind, StartLoc, EndLoc, NumAssociatedLoops) {} + + /// Set the number of loops generated by this loop transformation. + void setNumGeneratedLoops(unsigned Num) { NumGeneratedLoops = Num; } + +public: + /// Return the number of associated (consumed) loops. + unsigned getNumAssociatedLoops() const { return getLoopsNumber(); } + + /// Return the number of loops generated by this loop transformation. + unsigned getNumGeneratedLoops() { return NumGeneratedLoops; } + + /// Get the de-sugared statements after after the loop transformation. + /// + /// Might be nullptr if either the directive generates no loops and is handled + /// directly in CodeGen, or resolving a template-dependence context is + /// required. + Stmt *getTransformedStmt() const; + + /// Return preinits statement. + Stmt *getPreInits() const; + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPTileDirectiveClass || + T->getStmtClass() == OMPUnrollDirectiveClass; + } +}; + /// This is a common base class for loop directives ('omp simd', 'omp /// for', 'omp for simd' etc.). It is responsible for the loop code generation. /// @@ -1102,7 +1144,7 @@ protected: if (isOpenMPLoopBoundSharingDirective(Kind)) return CombinedDistributeEnd; if (isOpenMPWorksharingDirective(Kind) || isOpenMPTaskLoopDirective(Kind) || - isOpenMPDistributeDirective(Kind)) + isOpenMPGenericLoopDirective(Kind) || isOpenMPDistributeDirective(Kind)) return WorksharingEnd; return DefaultEnd; } @@ -1134,6 +1176,7 @@ protected: } void setIsLastIterVariable(Expr *IL) { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || + isOpenMPGenericLoopDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); @@ -1141,6 +1184,7 @@ protected: } void setLowerBoundVariable(Expr *LB) { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || + isOpenMPGenericLoopDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); @@ -1148,6 +1192,7 @@ protected: } void setUpperBoundVariable(Expr *UB) { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || + isOpenMPGenericLoopDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); @@ -1155,6 +1200,7 @@ protected: } void setStrideVariable(Expr *ST) { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || + isOpenMPGenericLoopDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); @@ -1162,6 +1208,7 @@ protected: } void setEnsureUpperBound(Expr *EUB) { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || + isOpenMPGenericLoopDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); @@ -1169,6 +1216,7 @@ protected: } void setNextLowerBound(Expr *NLB) { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || + isOpenMPGenericLoopDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); @@ -1176,6 +1224,7 @@ protected: } void setNextUpperBound(Expr *NUB) { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || + isOpenMPGenericLoopDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); @@ -1183,6 +1232,7 @@ protected: } void setNumIterations(Expr *NI) { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || + isOpenMPGenericLoopDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); @@ -1285,6 +1335,7 @@ public: Stmt *getPreInits() { return Data->getChildren()[PreInitsOffset]; } Expr *getIsLastIterVariable() const { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || + isOpenMPGenericLoopDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); @@ -1292,6 +1343,7 @@ public: } Expr *getLowerBoundVariable() const { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || + isOpenMPGenericLoopDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); @@ -1299,6 +1351,7 @@ public: } Expr *getUpperBoundVariable() const { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || + isOpenMPGenericLoopDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); @@ -1306,6 +1359,7 @@ public: } Expr *getStrideVariable() const { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || + isOpenMPGenericLoopDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); @@ -1313,6 +1367,7 @@ public: } Expr *getEnsureUpperBound() const { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || + isOpenMPGenericLoopDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); @@ -1320,6 +1375,7 @@ public: } Expr *getNextLowerBound() const { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || + isOpenMPGenericLoopDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); @@ -1327,6 +1383,7 @@ public: } Expr *getNextUpperBound() const { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || + isOpenMPGenericLoopDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); @@ -1334,6 +1391,7 @@ public: } Expr *getNumIterations() const { assert((isOpenMPWorksharingDirective(getDirectiveKind()) || + isOpenMPGenericLoopDirective(getDirectiveKind()) || isOpenMPTaskLoopDirective(getDirectiveKind()) || isOpenMPDistributeDirective(getDirectiveKind())) && "expected worksharing loop directive"); @@ -1467,6 +1525,7 @@ public: T->getStmtClass() == OMPTaskLoopSimdDirectiveClass || T->getStmtClass() == OMPMasterTaskLoopDirectiveClass || T->getStmtClass() == OMPMasterTaskLoopSimdDirectiveClass || + T->getStmtClass() == OMPGenericLoopDirectiveClass || T->getStmtClass() == OMPParallelMasterTaskLoopDirectiveClass || T->getStmtClass() == OMPParallelMasterTaskLoopSimdDirectiveClass || T->getStmtClass() == OMPDistributeDirectiveClass || @@ -2510,15 +2569,20 @@ public: /// \param C AST context. /// \param StartLoc Starting location of the directive kind. /// \param EndLoc Ending Location of the directive. + /// \param Clauses List of clauses. /// - static OMPTaskwaitDirective * - Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc); + static OMPTaskwaitDirective *Create(const ASTContext &C, + SourceLocation StartLoc, + SourceLocation EndLoc, + ArrayRef<OMPClause *> Clauses); /// Creates an empty directive. /// /// \param C AST context. + /// \param NumClauses Number of clauses. /// - static OMPTaskwaitDirective *CreateEmpty(const ASTContext &C, EmptyShell); + static OMPTaskwaitDirective *CreateEmpty(const ASTContext &C, + unsigned NumClauses, EmptyShell); static bool classof(const Stmt *T) { return T->getStmtClass() == OMPTaskwaitDirectiveClass; @@ -2794,16 +2858,25 @@ class OMPAtomicDirective : public OMPExecutableDirective { : OMPExecutableDirective(OMPAtomicDirectiveClass, llvm::omp::OMPD_atomic, SourceLocation(), SourceLocation()) {} + enum DataPositionTy : size_t { + POS_X = 0, + POS_V, + POS_E, + POS_UpdateExpr, + }; + /// Set 'x' part of the associated expression/statement. - void setX(Expr *X) { Data->getChildren()[0] = X; } + void setX(Expr *X) { Data->getChildren()[DataPositionTy::POS_X] = X; } /// Set helper expression of the form /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'. - void setUpdateExpr(Expr *UE) { Data->getChildren()[1] = UE; } + void setUpdateExpr(Expr *UE) { + Data->getChildren()[DataPositionTy::POS_UpdateExpr] = UE; + } /// Set 'v' part of the associated expression/statement. - void setV(Expr *V) { Data->getChildren()[2] = V; } + void setV(Expr *V) { Data->getChildren()[DataPositionTy::POS_V] = V; } /// Set 'expr' part of the associated expression/statement. - void setExpr(Expr *E) { Data->getChildren()[3] = E; } + void setExpr(Expr *E) { Data->getChildren()[DataPositionTy::POS_E] = E; } public: /// Creates directive with a list of \a Clauses and 'x', 'v' and 'expr' @@ -2840,16 +2913,22 @@ public: unsigned NumClauses, EmptyShell); /// Get 'x' part of the associated expression/statement. - Expr *getX() { return cast_or_null<Expr>(Data->getChildren()[0]); } + Expr *getX() { + return cast_or_null<Expr>(Data->getChildren()[DataPositionTy::POS_X]); + } const Expr *getX() const { - return cast_or_null<Expr>(Data->getChildren()[0]); + return cast_or_null<Expr>(Data->getChildren()[DataPositionTy::POS_X]); } /// Get helper expression of the form /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'. - Expr *getUpdateExpr() { return cast_or_null<Expr>(Data->getChildren()[1]); } + Expr *getUpdateExpr() { + return cast_or_null<Expr>( + Data->getChildren()[DataPositionTy::POS_UpdateExpr]); + } const Expr *getUpdateExpr() const { - return cast_or_null<Expr>(Data->getChildren()[1]); + return cast_or_null<Expr>( + Data->getChildren()[DataPositionTy::POS_UpdateExpr]); } /// Return true if helper update expression has form /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' and false if it has form @@ -2859,14 +2938,18 @@ public: /// 'x', false if 'v' must be updated to the new value of 'x'. bool isPostfixUpdate() const { return IsPostfixUpdate; } /// Get 'v' part of the associated expression/statement. - Expr *getV() { return cast_or_null<Expr>(Data->getChildren()[2]); } + Expr *getV() { + return cast_or_null<Expr>(Data->getChildren()[DataPositionTy::POS_V]); + } const Expr *getV() const { - return cast_or_null<Expr>(Data->getChildren()[2]); + return cast_or_null<Expr>(Data->getChildren()[DataPositionTy::POS_V]); } /// Get 'expr' part of the associated expression/statement. - Expr *getExpr() { return cast_or_null<Expr>(Data->getChildren()[3]); } + Expr *getExpr() { + return cast_or_null<Expr>(Data->getChildren()[DataPositionTy::POS_E]); + } const Expr *getExpr() const { - return cast_or_null<Expr>(Data->getChildren()[3]); + return cast_or_null<Expr>(Data->getChildren()[DataPositionTy::POS_E]); } static bool classof(const Stmt *T) { @@ -4992,7 +5075,7 @@ public: }; /// This represents the '#pragma omp tile' loop transformation directive. -class OMPTileDirective final : public OMPLoopBasedDirective { +class OMPTileDirective final : public OMPLoopTransformationDirective { friend class ASTStmtReader; friend class OMPExecutableDirective; @@ -5004,8 +5087,11 @@ class OMPTileDirective final : public OMPLoopBasedDirective { explicit OMPTileDirective(SourceLocation StartLoc, SourceLocation EndLoc, unsigned NumLoops) - : OMPLoopBasedDirective(OMPTileDirectiveClass, llvm::omp::OMPD_tile, - StartLoc, EndLoc, NumLoops) {} + : OMPLoopTransformationDirective(OMPTileDirectiveClass, + llvm::omp::OMPD_tile, StartLoc, EndLoc, + NumLoops) { + setNumGeneratedLoops(3 * NumLoops); + } void setPreInits(Stmt *PreInits) { Data->getChildren()[PreInitsOffset] = PreInits; @@ -5042,8 +5128,6 @@ public: static OMPTileDirective *CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned NumLoops); - unsigned getNumAssociatedLoops() const { return getLoopsNumber(); } - /// Gets/sets the associated loops after tiling. /// /// This is in de-sugared format stored as a CompoundStmt. @@ -5073,7 +5157,7 @@ public: /// #pragma omp unroll /// for (int i = 0; i < 64; ++i) /// \endcode -class OMPUnrollDirective final : public OMPLoopBasedDirective { +class OMPUnrollDirective final : public OMPLoopTransformationDirective { friend class ASTStmtReader; friend class OMPExecutableDirective; @@ -5084,8 +5168,9 @@ class OMPUnrollDirective final : public OMPLoopBasedDirective { }; explicit OMPUnrollDirective(SourceLocation StartLoc, SourceLocation EndLoc) - : OMPLoopBasedDirective(OMPUnrollDirectiveClass, llvm::omp::OMPD_unroll, - StartLoc, EndLoc, 1) {} + : OMPLoopTransformationDirective(OMPUnrollDirectiveClass, + llvm::omp::OMPD_unroll, StartLoc, EndLoc, + 1) {} /// Set the pre-init statements. void setPreInits(Stmt *PreInits) { @@ -5111,7 +5196,7 @@ public: static OMPUnrollDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, - Stmt *TransformedStmt, Stmt *PreInits); + unsigned NumGeneratedLoops, Stmt *TransformedStmt, Stmt *PreInits); /// Build an empty '#pragma omp unroll' AST node for deserialization. /// @@ -5360,6 +5445,107 @@ public: } }; +/// This represents '#pragma omp metadirective' directive. +/// +/// \code +/// #pragma omp metadirective when(user={condition(N>10)}: parallel for) +/// \endcode +/// In this example directive '#pragma omp metadirective' has clauses 'when' +/// with a dynamic user condition to check if a variable 'N > 10' +/// +class OMPMetaDirective final : public OMPExecutableDirective { + friend class ASTStmtReader; + friend class OMPExecutableDirective; + Stmt *IfStmt; + + OMPMetaDirective(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPExecutableDirective(OMPMetaDirectiveClass, + llvm::omp::OMPD_metadirective, StartLoc, + EndLoc) {} + explicit OMPMetaDirective() + : OMPExecutableDirective(OMPMetaDirectiveClass, + llvm::omp::OMPD_metadirective, SourceLocation(), + SourceLocation()) {} + + void setIfStmt(Stmt *S) { IfStmt = S; } + +public: + static OMPMetaDirective *Create(const ASTContext &C, SourceLocation StartLoc, + SourceLocation EndLoc, + ArrayRef<OMPClause *> Clauses, + Stmt *AssociatedStmt, Stmt *IfStmt); + static OMPMetaDirective *CreateEmpty(const ASTContext &C, unsigned NumClauses, + EmptyShell); + Stmt *getIfStmt() const { return IfStmt; } + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPMetaDirectiveClass; + } +}; + +/// This represents '#pragma omp loop' directive. +/// +/// \code +/// #pragma omp loop private(a,b) binding(parallel) order(concurrent) +/// \endcode +/// In this example directive '#pragma omp loop' has +/// clauses 'private' with the variables 'a' and 'b', 'binding' with +/// modifier 'parallel' and 'order(concurrent). +/// +class OMPGenericLoopDirective final : public OMPLoopDirective { + friend class ASTStmtReader; + friend class OMPExecutableDirective; + /// Build directive with the given start and end location. + /// + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending location of the directive. + /// \param CollapsedNum Number of collapsed nested loops. + /// + OMPGenericLoopDirective(SourceLocation StartLoc, SourceLocation EndLoc, + unsigned CollapsedNum) + : OMPLoopDirective(OMPGenericLoopDirectiveClass, llvm::omp::OMPD_loop, + StartLoc, EndLoc, CollapsedNum) {} + + /// Build an empty directive. + /// + /// \param CollapsedNum Number of collapsed nested loops. + /// + explicit OMPGenericLoopDirective(unsigned CollapsedNum) + : OMPLoopDirective(OMPGenericLoopDirectiveClass, llvm::omp::OMPD_loop, + SourceLocation(), SourceLocation(), CollapsedNum) {} + +public: + /// Creates directive with a list of \p Clauses. + /// + /// \param C AST context. + /// \param StartLoc Starting location of the directive kind. + /// \param EndLoc Ending Location of the directive. + /// \param CollapsedNum Number of collapsed loops. + /// \param Clauses List of clauses. + /// \param AssociatedStmt Statement, associated with the directive. + /// \param Exprs Helper expressions for CodeGen. + /// + static OMPGenericLoopDirective * + Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, + unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, + Stmt *AssociatedStmt, const HelperExprs &Exprs); + + /// Creates an empty directive with a place for \a NumClauses clauses. + /// + /// \param C AST context. + /// \param NumClauses Number of clauses. + /// \param CollapsedNum Number of collapsed nested loops. + /// + static OMPGenericLoopDirective *CreateEmpty(const ASTContext &C, + unsigned NumClauses, + unsigned CollapsedNum, + EmptyShell); + + static bool classof(const Stmt *T) { + return T->getStmtClass() == OMPGenericLoopDirectiveClass; + } +}; + } // end namespace clang #endif diff --git a/contrib/llvm-project/clang/include/clang/AST/TemplateName.h b/contrib/llvm-project/clang/include/clang/AST/TemplateName.h index 010b813dc525..2befb5c1b45e 100644 --- a/contrib/llvm-project/clang/include/clang/AST/TemplateName.h +++ b/contrib/llvm-project/clang/include/clang/AST/TemplateName.h @@ -309,16 +309,17 @@ public: /// unexpanded parameter pack (for C++0x variadic templates). bool containsUnexpandedParameterPack() const; + enum class Qualified { None, AsWritten, Fully }; /// Print the template name. /// /// \param OS the output stream to which the template name will be /// printed. /// - /// \param SuppressNNS if true, don't print the - /// nested-name-specifier that precedes the template name (if it has - /// one). + /// \param Qual print the (Qualified::None) simple name, + /// (Qualified::AsWritten) any written (possibly partial) qualifier, or + /// (Qualified::Fully) the fully qualified name. void print(raw_ostream &OS, const PrintingPolicy &Policy, - bool SuppressNNS = false) const; + Qualified Qual = Qualified::AsWritten) const; /// Debugging aid that dumps the template name. void dump(raw_ostream &OS) const; diff --git a/contrib/llvm-project/clang/include/clang/AST/Type.h b/contrib/llvm-project/clang/include/clang/AST/Type.h index 9f46d5337897..fd25ec25d4f2 100644 --- a/contrib/llvm-project/clang/include/clang/AST/Type.h +++ b/contrib/llvm-project/clang/include/clang/AST/Type.h @@ -495,7 +495,12 @@ public: (A == LangAS::Default && (B == LangAS::sycl_private || B == LangAS::sycl_local || B == LangAS::sycl_global || B == LangAS::sycl_global_device || - B == LangAS::sycl_global_host)); + B == LangAS::sycl_global_host)) || + // In HIP device compilation, any cuda address space is allowed + // to implicitly cast into the default address space. + (A == LangAS::Default && + (B == LangAS::cuda_constant || B == LangAS::cuda_device || + B == LangAS::cuda_shared)); } /// Returns true if the address space in these qualifiers is equal to or @@ -1998,6 +2003,7 @@ public: bool isFloat16Type() const; // C11 extension ISO/IEC TS 18661 bool isBFloat16Type() const; bool isFloat128Type() const; + bool isIbm128Type() const; bool isRealType() const; // C99 6.2.5p17 (real floating + integer) bool isArithmeticType() const; // C99 6.2.5p18 (integer + floating) bool isVoidType() const; // C99 6.2.5p19 @@ -2545,7 +2551,7 @@ public: } bool isFloatingPoint() const { - return getKind() >= Half && getKind() <= Float128; + return getKind() >= Half && getKind() <= Ibm128; } /// Determines whether the given kind corresponds to a placeholder type. @@ -3450,10 +3456,6 @@ class ConstantMatrixType final : public MatrixType { protected: friend class ASTContext; - /// The element type of the matrix. - // FIXME: Appears to be unused? There is also MatrixType::ElementType... - QualType ElementType; - /// Number of rows and columns. unsigned NumRows; unsigned NumColumns; @@ -3523,14 +3525,10 @@ class DependentSizedMatrixType final : public MatrixType { Expr *ColumnExpr, SourceLocation loc); public: - QualType getElementType() const { return ElementType; } Expr *getRowExpr() const { return RowExpr; } Expr *getColumnExpr() const { return ColumnExpr; } SourceLocation getAttributeLoc() const { return loc; } - bool isSugared() const { return false; } - QualType desugar() const { return QualType(this, 0); } - static bool classof(const Type *T) { return T->getTypeClass() == DependentSizedMatrix; } @@ -4946,29 +4944,29 @@ public: /// type-dependent, there is no deduced type and the type is canonical. In /// the latter case, it is also a dependent type. class DeducedType : public Type { + QualType DeducedAsType; + protected: DeducedType(TypeClass TC, QualType DeducedAsType, - TypeDependence ExtraDependence) - : Type(TC, - // FIXME: Retain the sugared deduced type? - DeducedAsType.isNull() ? QualType(this, 0) - : DeducedAsType.getCanonicalType(), + TypeDependence ExtraDependence, QualType Canon) + : Type(TC, Canon, ExtraDependence | (DeducedAsType.isNull() ? TypeDependence::None : DeducedAsType->getDependence() & - ~TypeDependence::VariablyModified)) {} + ~TypeDependence::VariablyModified)), + DeducedAsType(DeducedAsType) {} public: - bool isSugared() const { return !isCanonicalUnqualified(); } - QualType desugar() const { return getCanonicalTypeInternal(); } - - /// Get the type deduced for this placeholder type, or null if it's - /// either not been deduced or was deduced to a dependent type. - QualType getDeducedType() const { - return !isCanonicalUnqualified() ? getCanonicalTypeInternal() : QualType(); + bool isSugared() const { return !DeducedAsType.isNull(); } + QualType desugar() const { + return isSugared() ? DeducedAsType : QualType(this, 0); } + + /// Get the type deduced for this placeholder type, or null if it + /// has not been deduced. + QualType getDeducedType() const { return DeducedAsType; } bool isDeduced() const { - return !isCanonicalUnqualified() || isDependentType(); + return !DeducedAsType.isNull() || isDependentType(); } static bool classof(const Type *T) { @@ -4985,7 +4983,7 @@ class alignas(8) AutoType : public DeducedType, public llvm::FoldingSetNode { ConceptDecl *TypeConstraintConcept; AutoType(QualType DeducedAsType, AutoTypeKeyword Keyword, - TypeDependence ExtraDependence, ConceptDecl *CD, + TypeDependence ExtraDependence, QualType Canon, ConceptDecl *CD, ArrayRef<TemplateArgument> TypeConstraintArgs); const TemplateArgument *getArgBuffer() const { @@ -5059,7 +5057,9 @@ class DeducedTemplateSpecializationType : public DeducedType, toTypeDependence(Template.getDependence()) | (IsDeducedAsDependent ? TypeDependence::DependentInstantiation - : TypeDependence::None)), + : TypeDependence::None), + DeducedAsType.isNull() ? QualType(this, 0) + : DeducedAsType.getCanonicalType()), Template(Template) {} public: @@ -6018,10 +6018,9 @@ inline ObjCProtocolDecl **ObjCTypeParamType::getProtocolStorageImpl() { class ObjCInterfaceType : public ObjCObjectType { friend class ASTContext; // ASTContext creates these. friend class ASTReader; - friend class ObjCInterfaceDecl; template <class T> friend class serialization::AbstractTypeReader; - mutable ObjCInterfaceDecl *Decl; + ObjCInterfaceDecl *Decl; ObjCInterfaceType(const ObjCInterfaceDecl *D) : ObjCObjectType(Nonce_ObjCInterface), @@ -6029,7 +6028,7 @@ class ObjCInterfaceType : public ObjCObjectType { public: /// Get the declaration of this interface. - ObjCInterfaceDecl *getDecl() const { return Decl; } + ObjCInterfaceDecl *getDecl() const; bool isSugared() const { return false; } QualType desugar() const { return QualType(this, 0); } @@ -6976,6 +6975,10 @@ inline bool Type::isFloat128Type() const { return isSpecificBuiltinType(BuiltinType::Float128); } +inline bool Type::isIbm128Type() const { + return isSpecificBuiltinType(BuiltinType::Ibm128); +} + inline bool Type::isNullPtrType() const { return isSpecificBuiltinType(BuiltinType::NullPtr); } @@ -7144,7 +7147,7 @@ inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &PD, /// into a diagnostic with <<. inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &PD, QualType T) { - PD.AddTaggedVal(reinterpret_cast<intptr_t>(T.getAsOpaquePtr()), + PD.AddTaggedVal(reinterpret_cast<uint64_t>(T.getAsOpaquePtr()), DiagnosticsEngine::ak_qualtype); return PD; } diff --git a/contrib/llvm-project/clang/include/clang/AST/TypeLoc.h b/contrib/llvm-project/clang/include/clang/AST/TypeLoc.h index 65e95d52c303..bb668c1980fe 100644 --- a/contrib/llvm-project/clang/include/clang/AST/TypeLoc.h +++ b/contrib/llvm-project/clang/include/clang/AST/TypeLoc.h @@ -581,10 +581,9 @@ public: bool needsExtraLocalData() const { BuiltinType::Kind bk = getTypePtr()->getKind(); - return (bk >= BuiltinType::UShort && bk <= BuiltinType::UInt128) - || (bk >= BuiltinType::Short && bk <= BuiltinType::Float128) - || bk == BuiltinType::UChar - || bk == BuiltinType::SChar; + return (bk >= BuiltinType::UShort && bk <= BuiltinType::UInt128) || + (bk >= BuiltinType::Short && bk <= BuiltinType::Ibm128) || + bk == BuiltinType::UChar || bk == BuiltinType::SChar; } unsigned getExtraLocalDataSize() const { diff --git a/contrib/llvm-project/clang/include/clang/AST/TypeOrdering.h b/contrib/llvm-project/clang/include/clang/AST/TypeOrdering.h index 6630105136f5..8037f98cc965 100644 --- a/contrib/llvm-project/clang/include/clang/AST/TypeOrdering.h +++ b/contrib/llvm-project/clang/include/clang/AST/TypeOrdering.h @@ -34,7 +34,6 @@ struct QualTypeOrdering { } namespace llvm { - template<class> struct DenseMapInfo; template<> struct DenseMapInfo<clang::QualType> { static inline clang::QualType getEmptyKey() { return clang::QualType(); } diff --git a/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchFinder.h b/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchFinder.h index 91024f9425e0..dafafa151a60 100644 --- a/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchFinder.h +++ b/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchFinder.h @@ -167,6 +167,7 @@ public: MatchCallback *Action); void addMatcher(const TemplateArgumentLocMatcher &NodeMatch, MatchCallback *Action); + void addMatcher(const AttrMatcher &NodeMatch, MatchCallback *Action); /// @} /// Adds a matcher to execute when running over the AST. @@ -219,6 +220,7 @@ public: std::vector<std::pair<CXXCtorInitializerMatcher, MatchCallback *>> CtorInit; std::vector<std::pair<TemplateArgumentLocMatcher, MatchCallback *>> TemplateArgumentLoc; + std::vector<std::pair<AttrMatcher, MatchCallback *>> Attr; /// All the callbacks in one container to simplify iteration. llvm::SmallPtrSet<MatchCallback *, 16> AllCallbacks; }; diff --git a/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchers.h b/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchers.h index 8e3ee6cb9e7e..d6e5b215462b 100644 --- a/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -148,6 +148,8 @@ using CXXBaseSpecifierMatcher = internal::Matcher<CXXBaseSpecifier>; using CXXCtorInitializerMatcher = internal::Matcher<CXXCtorInitializer>; using TemplateArgumentMatcher = internal::Matcher<TemplateArgument>; using TemplateArgumentLocMatcher = internal::Matcher<TemplateArgumentLoc>; +using LambdaCaptureMatcher = internal::Matcher<LambdaCapture>; +using AttrMatcher = internal::Matcher<Attr>; /// @} /// Matches any node. @@ -307,7 +309,7 @@ AST_POLYMORPHIC_MATCHER_REGEX(isExpansionInFileMatching, /// Matches statements that are (transitively) expanded from the named macro. /// Does not match if only part of the statement is expanded from that macro or -/// if different parts of the the statement are expanded from different +/// if different parts of the statement are expanded from different /// appearances of the macro. AST_POLYMORPHIC_MATCHER_P(isExpandedFromMacro, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc), @@ -752,9 +754,11 @@ AST_MATCHER_P(ClassTemplateSpecializationDecl, hasSpecializedTemplate, InnerMatcher.matches(*Decl, Finder, Builder)); } -/// Matches a declaration that has been implicitly added -/// by the compiler (eg. implicit default/copy constructors). -AST_MATCHER(Decl, isImplicit) { +/// Matches an entity that has been implicitly added by the compiler (e.g. +/// implicit default/copy constructors). +AST_POLYMORPHIC_MATCHER(isImplicit, + AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Attr, + LambdaCapture)) { return Node.isImplicit(); } @@ -3489,8 +3493,8 @@ internal::Matcher<T> findAll(const internal::Matcher<T> &Matcher) { /// Usable as: Any Matcher extern const internal::ArgumentAdaptingMatcherFunc< internal::HasParentMatcher, - internal::TypeList<Decl, NestedNameSpecifierLoc, Stmt, TypeLoc>, - internal::TypeList<Decl, NestedNameSpecifierLoc, Stmt, TypeLoc>> + internal::TypeList<Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr>, + internal::TypeList<Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr>> hasParent; /// Matches AST nodes that have an ancestor that matches the provided @@ -3506,8 +3510,8 @@ extern const internal::ArgumentAdaptingMatcherFunc< /// Usable as: Any Matcher extern const internal::ArgumentAdaptingMatcherFunc< internal::HasAncestorMatcher, - internal::TypeList<Decl, NestedNameSpecifierLoc, Stmt, TypeLoc>, - internal::TypeList<Decl, NestedNameSpecifierLoc, Stmt, TypeLoc>> + internal::TypeList<Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr>, + internal::TypeList<Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr>> hasAncestor; /// Matches if the provided matcher does not match. @@ -4201,6 +4205,45 @@ AST_MATCHER_P( InnerMatcher.matches(*Initializer, Finder, Builder)); } +/// Matches a variable serving as the implicit variable for a lambda init- +/// capture. +/// +/// Example matches x (matcher = varDecl(isInitCapture())) +/// \code +/// auto f = [x=3]() { return x; }; +/// \endcode +AST_MATCHER(VarDecl, isInitCapture) { return Node.isInitCapture(); } + +/// Matches each lambda capture in a lambda expression. +/// +/// Given +/// \code +/// int main() { +/// int x, y; +/// float z; +/// auto f = [=]() { return x + y + z; }; +/// } +/// \endcode +/// lambdaExpr(forEachLambdaCapture( +/// lambdaCapture(capturesVar(varDecl(hasType(isInteger())))))) +/// will trigger two matches, binding for 'x' and 'y' respectively. +AST_MATCHER_P(LambdaExpr, forEachLambdaCapture, LambdaCaptureMatcher, + InnerMatcher) { + BoundNodesTreeBuilder Result; + bool Matched = false; + for (const auto &Capture : Node.captures()) { + if (Finder->isTraversalIgnoringImplicitNodes() && Capture.isImplicit()) + continue; + BoundNodesTreeBuilder CaptureBuilder(*Builder); + if (InnerMatcher.matches(Capture, Finder, &CaptureBuilder)) { + Matched = true; + Result.addMatch(CaptureBuilder); + } + } + *Builder = std::move(Result); + return Matched; +} + /// \brief Matches a static variable with local scope. /// /// Example matches y (matcher = varDecl(isStaticLocal())) @@ -4586,50 +4629,80 @@ AST_POLYMORPHIC_MATCHER_P(hasAnyArgument, return false; } -/// Matches any capture of a lambda expression. +/// Matches lambda captures. /// /// Given /// \code -/// void foo() { +/// int main() { /// int x; /// auto f = [x](){}; +/// auto g = [x = 1](){}; /// } /// \endcode -/// lambdaExpr(hasAnyCapture(anything())) -/// matches [x](){}; -AST_MATCHER_P_OVERLOAD(LambdaExpr, hasAnyCapture, internal::Matcher<VarDecl>, - InnerMatcher, 0) { +/// In the matcher `lambdaExpr(hasAnyCapture(lambdaCapture()))`, +/// `lambdaCapture()` matches `x` and `x=1`. +extern const internal::VariadicAllOfMatcher<LambdaCapture> lambdaCapture; + +/// Matches any capture in a lambda expression. +/// +/// Given +/// \code +/// void foo() { +/// int t = 5; +/// auto f = [=](){ return t; }; +/// } +/// \endcode +/// lambdaExpr(hasAnyCapture(lambdaCapture())) and +/// lambdaExpr(hasAnyCapture(lambdaCapture(refersToVarDecl(hasName("t"))))) +/// both match `[=](){ return t; }`. +AST_MATCHER_P(LambdaExpr, hasAnyCapture, LambdaCaptureMatcher, InnerMatcher) { for (const LambdaCapture &Capture : Node.captures()) { - if (Capture.capturesVariable()) { - BoundNodesTreeBuilder Result(*Builder); - if (InnerMatcher.matches(*Capture.getCapturedVar(), Finder, &Result)) { - *Builder = std::move(Result); - return true; - } + clang::ast_matchers::internal::BoundNodesTreeBuilder Result(*Builder); + if (InnerMatcher.matches(Capture, Finder, &Result)) { + *Builder = std::move(Result); + return true; } } return false; } -/// Matches any capture of 'this' in a lambda expression. +/// Matches a `LambdaCapture` that refers to the specified `VarDecl`. The +/// `VarDecl` can be a separate variable that is captured by value or +/// reference, or a synthesized variable if the capture has an initializer. /// /// Given /// \code -/// struct foo { -/// void bar() { -/// auto f = [this](){}; -/// } +/// void foo() { +/// int x; +/// auto f = [x](){}; +/// auto g = [x = 1](){}; /// } /// \endcode -/// lambdaExpr(hasAnyCapture(cxxThisExpr())) -/// matches [this](){}; -AST_MATCHER_P_OVERLOAD(LambdaExpr, hasAnyCapture, - internal::Matcher<CXXThisExpr>, InnerMatcher, 1) { - return llvm::any_of(Node.captures(), [](const LambdaCapture &LC) { - return LC.capturesThis(); - }); +/// In the matcher +/// lambdaExpr(hasAnyCapture(lambdaCapture(capturesVar(hasName("x")))), +/// capturesVar(hasName("x")) matches `x` and `x = 1`. +AST_MATCHER_P(LambdaCapture, capturesVar, internal::Matcher<VarDecl>, + InnerMatcher) { + auto *capturedVar = Node.getCapturedVar(); + return capturedVar && InnerMatcher.matches(*capturedVar, Finder, Builder); } +/// Matches a `LambdaCapture` that refers to 'this'. +/// +/// Given +/// \code +/// class C { +/// int cc; +/// int f() { +/// auto l = [this]() { return cc; }; +/// return l(); +/// } +/// }; +/// \endcode +/// lambdaExpr(hasAnyCapture(lambdaCapture(capturesThis()))) +/// matches `[this]() { return cc; }`. +AST_MATCHER(LambdaCapture, capturesThis) { return Node.capturesThis(); } + /// Matches a constructor call expression which uses list initialization. AST_MATCHER(CXXConstructExpr, isListInitialization) { return Node.isListInitialization(); @@ -5875,6 +5948,10 @@ AST_MATCHER(CXXMethodDecl, isVirtualAsWritten) { return Node.isVirtualAsWritten(); } +AST_MATCHER(CXXConstructorDecl, isInheritingConstructor) { + return Node.isInheritingConstructor(); +} + /// Matches if the given method or class declaration is final. /// /// Given: @@ -6333,6 +6410,187 @@ AST_MATCHER_FUNCTION_P_OVERLOAD(internal::BindableMatcher<TypeLoc>, loc, new internal::TypeLocTypeMatcher(InnerMatcher)); } +/// Matches `QualifiedTypeLoc`s in the clang AST. +/// +/// Given +/// \code +/// const int x = 0; +/// \endcode +/// qualifiedTypeLoc() +/// matches `const int`. +extern const internal::VariadicDynCastAllOfMatcher<TypeLoc, QualifiedTypeLoc> + qualifiedTypeLoc; + +/// Matches `QualifiedTypeLoc`s that have an unqualified `TypeLoc` matching +/// `InnerMatcher`. +/// +/// Given +/// \code +/// int* const x; +/// const int y; +/// \endcode +/// qualifiedTypeLoc(hasUnqualifiedLoc(pointerTypeLoc())) +/// matches the `TypeLoc` of the variable declaration of `x`, but not `y`. +AST_MATCHER_P(QualifiedTypeLoc, hasUnqualifiedLoc, internal::Matcher<TypeLoc>, + InnerMatcher) { + return InnerMatcher.matches(Node.getUnqualifiedLoc(), Finder, Builder); +} + +/// Matches a function declared with the specified return `TypeLoc`. +/// +/// Given +/// \code +/// int f() { return 5; } +/// void g() {} +/// \endcode +/// functionDecl(hasReturnTypeLoc(loc(asString("int")))) +/// matches the declaration of `f`, but not `g`. +AST_MATCHER_P(FunctionDecl, hasReturnTypeLoc, internal::Matcher<TypeLoc>, + ReturnMatcher) { + auto Loc = Node.getFunctionTypeLoc(); + return Loc && ReturnMatcher.matches(Loc.getReturnLoc(), Finder, Builder); +} + +/// Matches pointer `TypeLoc`s. +/// +/// Given +/// \code +/// int* x; +/// \endcode +/// pointerTypeLoc() +/// matches `int*`. +extern const internal::VariadicDynCastAllOfMatcher<TypeLoc, PointerTypeLoc> + pointerTypeLoc; + +/// Matches pointer `TypeLoc`s that have a pointee `TypeLoc` matching +/// `PointeeMatcher`. +/// +/// Given +/// \code +/// int* x; +/// \endcode +/// pointerTypeLoc(hasPointeeLoc(loc(asString("int")))) +/// matches `int*`. +AST_MATCHER_P(PointerTypeLoc, hasPointeeLoc, internal::Matcher<TypeLoc>, + PointeeMatcher) { + return PointeeMatcher.matches(Node.getPointeeLoc(), Finder, Builder); +} + +/// Matches reference `TypeLoc`s. +/// +/// Given +/// \code +/// int x = 3; +/// int& l = x; +/// int&& r = 3; +/// \endcode +/// referenceTypeLoc() +/// matches `int&` and `int&&`. +extern const internal::VariadicDynCastAllOfMatcher<TypeLoc, ReferenceTypeLoc> + referenceTypeLoc; + +/// Matches reference `TypeLoc`s that have a referent `TypeLoc` matching +/// `ReferentMatcher`. +/// +/// Given +/// \code +/// int x = 3; +/// int& xx = x; +/// \endcode +/// referenceTypeLoc(hasReferentLoc(loc(asString("int")))) +/// matches `int&`. +AST_MATCHER_P(ReferenceTypeLoc, hasReferentLoc, internal::Matcher<TypeLoc>, + ReferentMatcher) { + return ReferentMatcher.matches(Node.getPointeeLoc(), Finder, Builder); +} + +/// Matches template specialization `TypeLoc`s. +/// +/// Given +/// \code +/// template <typename T> class C {}; +/// C<char> var; +/// \endcode +/// varDecl(hasTypeLoc(templateSpecializationTypeLoc(typeLoc()))) +/// matches `C<char> var`. +extern const internal::VariadicDynCastAllOfMatcher< + TypeLoc, TemplateSpecializationTypeLoc> + templateSpecializationTypeLoc; + +/// Matches template specialization `TypeLoc`s that have at least one +/// `TemplateArgumentLoc` matching the given `InnerMatcher`. +/// +/// Given +/// \code +/// template<typename T> class A {}; +/// A<int> a; +/// \endcode +/// varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasAnyTemplateArgumentLoc( +/// hasTypeLoc(loc(asString("int"))))))) +/// matches `A<int> a`. +AST_MATCHER_P(TemplateSpecializationTypeLoc, hasAnyTemplateArgumentLoc, + internal::Matcher<TemplateArgumentLoc>, InnerMatcher) { + for (unsigned Index = 0, N = Node.getNumArgs(); Index < N; ++Index) { + clang::ast_matchers::internal::BoundNodesTreeBuilder Result(*Builder); + if (InnerMatcher.matches(Node.getArgLoc(Index), Finder, &Result)) { + *Builder = std::move(Result); + return true; + } + } + return false; +} + +/// Matches template specialization `TypeLoc`s where the n'th +/// `TemplateArgumentLoc` matches the given `InnerMatcher`. +/// +/// Given +/// \code +/// template<typename T, typename U> class A {}; +/// A<double, int> b; +/// A<int, double> c; +/// \endcode +/// varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0, +/// hasTypeLoc(loc(asString("double"))))))) +/// matches `A<double, int> b`, but not `A<int, double> c`. +AST_POLYMORPHIC_MATCHER_P2( + hasTemplateArgumentLoc, + AST_POLYMORPHIC_SUPPORTED_TYPES(DeclRefExpr, TemplateSpecializationTypeLoc), + unsigned, Index, internal::Matcher<TemplateArgumentLoc>, InnerMatcher) { + return internal::MatchTemplateArgLocAt(Node, Index, InnerMatcher, Finder, + Builder); +} + +/// Matches C or C++ elaborated `TypeLoc`s. +/// +/// Given +/// \code +/// struct s {}; +/// struct s ss; +/// \endcode +/// elaboratedTypeLoc() +/// matches the `TypeLoc` of the variable declaration of `ss`. +extern const internal::VariadicDynCastAllOfMatcher<TypeLoc, ElaboratedTypeLoc> + elaboratedTypeLoc; + +/// Matches elaborated `TypeLoc`s that have a named `TypeLoc` matching +/// `InnerMatcher`. +/// +/// Given +/// \code +/// template <typename T> +/// class C {}; +/// class C<int> c; +/// +/// class D {}; +/// class D d; +/// \endcode +/// elaboratedTypeLoc(hasNamedTypeLoc(templateSpecializationTypeLoc())); +/// matches the `TypeLoc` of the variable declaration of `c`, but not `d`. +AST_MATCHER_P(ElaboratedTypeLoc, hasNamedTypeLoc, internal::Matcher<TypeLoc>, + InnerMatcher) { + return InnerMatcher.matches(Node.getNamedTypeLoc(), Finder, Builder); +} + /// Matches type \c bool. /// /// Given @@ -7133,6 +7391,24 @@ AST_MATCHER_P(NestedNameSpecifier, specifiesNamespace, return InnerMatcher.matches(*Node.getAsNamespace(), Finder, Builder); } +/// Matches attributes. +/// Attributes may be attached with a variety of different syntaxes (including +/// keywords, C++11 attributes, GNU ``__attribute``` and MSVC `__declspec``, +/// and ``#pragma``s). They may also be implicit. +/// +/// Given +/// \code +/// struct [[nodiscard]] Foo{}; +/// void bar(int * __attribute__((nonnull)) ); +/// __declspec(noinline) void baz(); +/// +/// #pragma omp declare simd +/// int min(); +/// \endcode +/// attr() +/// matches "nodiscard", "nonnull", "noinline", and the whole "#pragma" line. +extern const internal::VariadicAllOfMatcher<Attr> attr; + /// Overloads for the \c equalsNode matcher. /// FIXME: Implement for other node types. /// @{ diff --git a/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchersInternal.h b/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchersInternal.h index 71f4f2d17ae3..a77611001fb1 100644 --- a/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchersInternal.h +++ b/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchersInternal.h @@ -312,8 +312,7 @@ public: template <typename ExcludePredicate> bool removeBindings(const ExcludePredicate &Predicate) { - Bindings.erase(std::remove_if(Bindings.begin(), Bindings.end(), Predicate), - Bindings.end()); + llvm::erase_if(Bindings, Predicate); return !Bindings.empty(); } @@ -757,7 +756,8 @@ public: std::is_base_of<NestedNameSpecifier, T>::value || std::is_base_of<NestedNameSpecifierLoc, T>::value || std::is_base_of<TypeLoc, T>::value || - std::is_base_of<QualType, T>::value, + std::is_base_of<QualType, T>::value || + std::is_base_of<Attr, T>::value, "unsupported type for recursive matching"); return matchesChildOf(DynTypedNode::create(Node), getASTContext(), Matcher, Builder, Bind); @@ -771,7 +771,8 @@ public: std::is_base_of<NestedNameSpecifier, T>::value || std::is_base_of<NestedNameSpecifierLoc, T>::value || std::is_base_of<TypeLoc, T>::value || - std::is_base_of<QualType, T>::value, + std::is_base_of<QualType, T>::value || + std::is_base_of<Attr, T>::value, "unsupported type for recursive matching"); return matchesDescendantOf(DynTypedNode::create(Node), getASTContext(), Matcher, Builder, Bind); @@ -785,7 +786,8 @@ public: static_assert(std::is_base_of<Decl, T>::value || std::is_base_of<NestedNameSpecifierLoc, T>::value || std::is_base_of<Stmt, T>::value || - std::is_base_of<TypeLoc, T>::value, + std::is_base_of<TypeLoc, T>::value || + std::is_base_of<Attr, T>::value, "type not allowed for recursive matching"); return matchesAncestorOf(DynTypedNode::create(Node), getASTContext(), Matcher, Builder, MatchMode); @@ -954,7 +956,7 @@ class HasNameMatcher : public SingleNodeMatcherInterface<NamedDecl> { bool matchesNode(const NamedDecl &Node) const override; - private: +private: /// Unqualified match routine. /// /// It is much faster than the full match, but it only works for unqualified @@ -1025,31 +1027,29 @@ private: BoundNodesTreeBuilder *Builder) const { // DeducedType does not have declarations of its own, so // match the deduced type instead. - const Type *EffectiveType = &Node; if (const auto *S = dyn_cast<DeducedType>(&Node)) { - EffectiveType = S->getDeducedType().getTypePtrOrNull(); - if (!EffectiveType) - return false; + QualType DT = S->getDeducedType(); + return !DT.isNull() ? matchesSpecialized(*DT, Finder, Builder) : false; } // First, for any types that have a declaration, extract the declaration and // match on it. - if (const auto *S = dyn_cast<TagType>(EffectiveType)) { + if (const auto *S = dyn_cast<TagType>(&Node)) { return matchesDecl(S->getDecl(), Finder, Builder); } - if (const auto *S = dyn_cast<InjectedClassNameType>(EffectiveType)) { + if (const auto *S = dyn_cast<InjectedClassNameType>(&Node)) { return matchesDecl(S->getDecl(), Finder, Builder); } - if (const auto *S = dyn_cast<TemplateTypeParmType>(EffectiveType)) { + if (const auto *S = dyn_cast<TemplateTypeParmType>(&Node)) { return matchesDecl(S->getDecl(), Finder, Builder); } - if (const auto *S = dyn_cast<TypedefType>(EffectiveType)) { + if (const auto *S = dyn_cast<TypedefType>(&Node)) { return matchesDecl(S->getDecl(), Finder, Builder); } - if (const auto *S = dyn_cast<UnresolvedUsingType>(EffectiveType)) { + if (const auto *S = dyn_cast<UnresolvedUsingType>(&Node)) { return matchesDecl(S->getDecl(), Finder, Builder); } - if (const auto *S = dyn_cast<ObjCObjectType>(EffectiveType)) { + if (const auto *S = dyn_cast<ObjCObjectType>(&Node)) { return matchesDecl(S->getInterface(), Finder, Builder); } @@ -1061,14 +1061,14 @@ private: // template<typename T> struct X { T t; } class A {}; X<A> a; // The following matcher will match, which otherwise would not: // fieldDecl(hasType(pointerType())). - if (const auto *S = dyn_cast<SubstTemplateTypeParmType>(EffectiveType)) { + if (const auto *S = dyn_cast<SubstTemplateTypeParmType>(&Node)) { return matchesSpecialized(S->getReplacementType(), Finder, Builder); } // For template specialization types, we want to match the template // declaration, as long as the type is still dependent, and otherwise the // declaration of the instantiated tag type. - if (const auto *S = dyn_cast<TemplateSpecializationType>(EffectiveType)) { + if (const auto *S = dyn_cast<TemplateSpecializationType>(&Node)) { if (!S->isTypeAlias() && S->isSugared()) { // If the template is non-dependent, we want to match the instantiated // tag type. @@ -1087,7 +1087,7 @@ private: // FIXME: We desugar elaborated types. This makes the assumption that users // do never want to match on whether a type is elaborated - there are // arguments for both sides; for now, continue desugaring. - if (const auto *S = dyn_cast<ElaboratedType>(EffectiveType)) { + if (const auto *S = dyn_cast<ElaboratedType>(&Node)) { return matchesSpecialized(S->desugar(), Finder, Builder); } return false; @@ -1175,7 +1175,8 @@ struct IsBaseType { std::is_same<T, NestedNameSpecifier>::value || std::is_same<T, NestedNameSpecifierLoc>::value || std::is_same<T, CXXCtorInitializer>::value || - std::is_same<T, TemplateArgumentLoc>::value; + std::is_same<T, TemplateArgumentLoc>::value || + std::is_same<T, Attr>::value; }; template <typename T> const bool IsBaseType<T>::value; @@ -1185,7 +1186,7 @@ const bool IsBaseType<T>::value; /// Useful for matchers like \c anything and \c unless. using AllNodeBaseTypes = TypeList<Decl, Stmt, NestedNameSpecifier, NestedNameSpecifierLoc, QualType, - Type, TypeLoc, CXXCtorInitializer>; + Type, TypeLoc, CXXCtorInitializer, Attr>; /// Helper meta-function to extract the argument out of a function of /// type void(Arg). @@ -1212,7 +1213,7 @@ template <class T, class Tuple> constexpr T *new_from_tuple(Tuple &&t) { using AdaptativeDefaultFromTypes = AllNodeBaseTypes; using AdaptativeDefaultToTypes = TypeList<Decl, Stmt, NestedNameSpecifier, NestedNameSpecifierLoc, TypeLoc, - QualType>; + QualType, Attr>; /// All types that are supported by HasDeclarationMatcher above. using HasDeclarationSupportedTypes = @@ -2245,11 +2246,7 @@ public: bool matchesNode(const T &Node) const override { Optional<StringRef> OptOpName = getOpName(Node); - if (!OptOpName) - return false; - return llvm::any_of(Names, [OpName = *OptOpName](const std::string &Name) { - return Name == OpName; - }); + return OptOpName && llvm::is_contained(Names, *OptOpName); } private: @@ -2304,6 +2301,26 @@ std::shared_ptr<llvm::Regex> createAndVerifyRegex(StringRef Regex, llvm::Regex::RegexFlags Flags, StringRef MatcherID); +inline bool +MatchTemplateArgLocAt(const DeclRefExpr &Node, unsigned int Index, + internal::Matcher<TemplateArgumentLoc> InnerMatcher, + internal::ASTMatchFinder *Finder, + internal::BoundNodesTreeBuilder *Builder) { + llvm::ArrayRef<TemplateArgumentLoc> ArgLocs = Node.template_arguments(); + return Index < ArgLocs.size() && + InnerMatcher.matches(ArgLocs[Index], Finder, Builder); +} + +inline bool +MatchTemplateArgLocAt(const TemplateSpecializationTypeLoc &Node, + unsigned int Index, + internal::Matcher<TemplateArgumentLoc> InnerMatcher, + internal::ASTMatchFinder *Finder, + internal::BoundNodesTreeBuilder *Builder) { + return !Node.isNull() && Index < Node.getNumArgs() && + InnerMatcher.matches(Node.getArgLoc(Index), Finder, Builder); +} + } // namespace internal } // namespace ast_matchers diff --git a/contrib/llvm-project/clang/include/clang/Analysis/Analyses/Dominators.h b/contrib/llvm-project/clang/include/clang/Analysis/Analyses/Dominators.h index 25a5ba9d83fe..f588a5c7d1d7 100644 --- a/contrib/llvm-project/clang/include/clang/Analysis/Analyses/Dominators.h +++ b/contrib/llvm-project/clang/include/clang/Analysis/Analyses/Dominators.h @@ -202,7 +202,7 @@ struct ChildrenGetterTy<clang::CFGBlock, IsPostDom> { auto Children = children<OrderedNodeTy>(N); ChildrenTy Ret{Children.begin(), Children.end()}; - Ret.erase(std::remove(Ret.begin(), Ret.end(), nullptr), Ret.end()); + llvm::erase_value(Ret, nullptr); return Ret; } }; diff --git a/contrib/llvm-project/clang/include/clang/Analysis/CFG.h b/contrib/llvm-project/clang/include/clang/Analysis/CFG.h index 9e32eb8e066a..f9223fe58a27 100644 --- a/contrib/llvm-project/clang/include/clang/Analysis/CFG.h +++ b/contrib/llvm-project/clang/include/clang/Analysis/CFG.h @@ -1337,6 +1337,7 @@ public: const CFGBlock * getIndirectGotoBlock() const { return IndirectGotoBlock; } using try_block_iterator = std::vector<const CFGBlock *>::const_iterator; + using try_block_range = llvm::iterator_range<try_block_iterator>; try_block_iterator try_blocks_begin() const { return TryDispatchBlocks.begin(); @@ -1346,6 +1347,10 @@ public: return TryDispatchBlocks.end(); } + try_block_range try_blocks() const { + return try_block_range(try_blocks_begin(), try_blocks_end()); + } + void addTryDispatchBlock(const CFGBlock *block) { TryDispatchBlocks.push_back(block); } diff --git a/contrib/llvm-project/clang/include/clang/Analysis/CloneDetection.h b/contrib/llvm-project/clang/include/clang/Analysis/CloneDetection.h index db827c3a6d6f..0b86c7fd86dd 100644 --- a/contrib/llvm-project/clang/include/clang/Analysis/CloneDetection.h +++ b/contrib/llvm-project/clang/include/clang/Analysis/CloneDetection.h @@ -235,9 +235,7 @@ public: static void filterGroups( std::vector<CloneDetector::CloneGroup> &CloneGroups, llvm::function_ref<bool(const CloneDetector::CloneGroup &)> Filter) { - CloneGroups.erase( - std::remove_if(CloneGroups.begin(), CloneGroups.end(), Filter), - CloneGroups.end()); + llvm::erase_if(CloneGroups, Filter); } /// Splits the given CloneGroups until the given Compare function returns true diff --git a/contrib/llvm-project/clang/include/clang/Analysis/PathDiagnostic.h b/contrib/llvm-project/clang/include/clang/Analysis/PathDiagnostic.h index 539aa20b8168..235d26083191 100644 --- a/contrib/llvm-project/clang/include/clang/Analysis/PathDiagnostic.h +++ b/contrib/llvm-project/clang/include/clang/Analysis/PathDiagnostic.h @@ -75,14 +75,8 @@ struct PathDiagnosticConsumerOptions { bool ShouldSerializeStats = false; /// If the consumer intends to produce multiple output files, should it - /// use randomly generated file names for these files (with the tiny risk of - /// having random collisions) or deterministic human-readable file names - /// (with a larger risk of deterministic collisions or invalid characters - /// in the file name). We should not really give this choice to the users - /// because deterministic mode is always superior when done right, but - /// for some consumers this mode is experimental and needs to be - /// off by default. - bool ShouldWriteStableReportFilename = false; + /// use a pseudo-random file name name or a human-readable file name. + bool ShouldWriteVerboseReportFilename = false; /// Whether the consumer should treat consumed diagnostics as hard errors. /// Useful for breaking your build when issues are found. @@ -151,11 +145,14 @@ public: /// Only runs visitors, no output generated. None, - /// Used for HTML, SARIF, and text output. + /// Used for SARIF and text output. Minimal, /// Used for plist output, used for "arrows" generation. Extensive, + + /// Used for HTML, shows both "arrows" and control notes. + Everything }; virtual PathGenerationScheme getGenerationScheme() const { return Minimal; } @@ -164,7 +161,11 @@ public: return getGenerationScheme() != None; } - bool shouldAddPathEdges() const { return getGenerationScheme() == Extensive; } + bool shouldAddPathEdges() const { return getGenerationScheme() >= Extensive; } + bool shouldAddControlNotes() const { + return getGenerationScheme() == Minimal || + getGenerationScheme() == Everything; + } virtual bool supportsLogicalOpControlFlow() const { return false; } @@ -552,7 +553,7 @@ public: /// Return true if the diagnostic piece is prunable. bool isPrunable() const { - return IsPrunable.hasValue() ? IsPrunable.getValue() : false; + return IsPrunable.getValueOr(false); } void dump() const override; diff --git a/contrib/llvm-project/clang/include/clang/Basic/Attr.td b/contrib/llvm-project/clang/include/clang/Basic/Attr.td index 12d09181a2ea..d8f0fcd56550 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/Attr.td +++ b/contrib/llvm-project/clang/include/clang/Basic/Attr.td @@ -848,6 +848,7 @@ def Availability : InheritableAttr { [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) { return llvm::StringSwitch<llvm::StringRef>(Platform) .Case("android", "Android") + .Case("fuchsia", "Fuchsia") .Case("ios", "iOS") .Case("macos", "macOS") .Case("tvos", "tvOS") @@ -1835,6 +1836,22 @@ def BPFPreserveAccessIndex : InheritableAttr, let LangOpts = [COnly]; } +def BTFDeclTag : InheritableAttr { + let Spellings = [Clang<"btf_decl_tag">]; + let Args = [StringArgument<"BTFDeclTag">]; + let Subjects = SubjectList<[Var, Function, Record, Field, TypedefName], + ErrorDiag>; + let Documentation = [BTFDeclTagDocs]; + let LangOpts = [COnly]; +} + +def BTFTypeTag : TypeAttr { + let Spellings = [Clang<"btf_type_tag">]; + let Args = [StringArgument<"BTFTypeTag">]; + let Documentation = [BTFTypeTagDocs]; + let LangOpts = [COnly]; +} + def WebAssemblyExportName : InheritableAttr, TargetSpecificAttr<TargetWebAssembly> { let Spellings = [Clang<"export_name">]; @@ -1971,7 +1988,7 @@ def NoReturn : InheritableAttr { def NoInstrumentFunction : InheritableAttr { let Spellings = [GCC<"no_instrument_function">]; - let Subjects = SubjectList<[Function]>; + let Subjects = SubjectList<[Function, ObjCMethod]>; let Documentation = [Undocumented]; let SimpleHandler = 1; } @@ -2940,6 +2957,13 @@ def NoSanitizeSpecific : InheritableAttr { let ASTNode = 0; } +def DisableSanitizerInstrumentation : InheritableAttr { + let Spellings = [Clang<"disable_sanitizer_instrumentation">]; + let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar]>; + let Documentation = [DisableSanitizerInstrumentationDocs]; + let SimpleHandler = 1; +} + def CFICanonicalJumpTable : InheritableAttr { let Spellings = [Clang<"cfi_canonical_jump_table">]; let Subjects = SubjectList<[Function], ErrorDiag>; @@ -3659,7 +3683,8 @@ def OMPAllocateDecl : InheritableAttr { "OMPCGroupMemAlloc", "OMPPTeamMemAlloc", "OMPThreadMemAlloc", "OMPUserDefinedMemAlloc" ]>, - ExprArgument<"Allocator"> + ExprArgument<"Allocator">, + ExprArgument<"Alignment"> ]; let Documentation = [Undocumented]; } @@ -3674,6 +3699,11 @@ def OMPDeclareVariant : InheritableAttr { let Args = [ ExprArgument<"VariantFuncRef">, OMPTraitInfoArgument<"TraitInfos">, + VariadicExprArgument<"AdjustArgsNothing">, + VariadicExprArgument<"AdjustArgsNeedDevicePtr">, + VariadicEnumArgument<"AppendArgs", "InteropType", + ["target", "targetsync", "target,targetsync"], + ["Target", "TargetSync", "Target_TargetSync"]> ]; let AdditionalMembers = [{ OMPTraitInfo &getTraitInfo() { return *traitInfos; } @@ -3823,3 +3853,12 @@ def EnforceTCBLeaf : InheritableAttr { let Documentation = [EnforceTCBLeafDocs]; bit InheritEvenIfAlreadyPresent = 1; } + +def Error : InheritableAttr { + let Spellings = [GCC<"error">, GCC<"warning">]; + let Accessors = [Accessor<"isError", [GCC<"error">]>, + Accessor<"isWarning", [GCC<"warning">]>]; + let Args = [StringArgument<"UserDiagnostic">]; + let Subjects = SubjectList<[Function], ErrorDiag>; + let Documentation = [ErrorAttrDocs]; +} diff --git a/contrib/llvm-project/clang/include/clang/Basic/AttrDocs.td b/contrib/llvm-project/clang/include/clang/Basic/AttrDocs.td index c265a877e3b1..e7afb3699eb1 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/AttrDocs.td +++ b/contrib/llvm-project/clang/include/clang/Basic/AttrDocs.td @@ -22,7 +22,7 @@ // Windows (from within the clang\docs directory): // make.bat html // Non-Windows (from within the clang\docs directory): -// make -f Makefile.sphinx html +// sphinx-build -b html _build/html def GlobalDocumentation { code Intro =[{.. @@ -2011,6 +2011,34 @@ preserving struct or union member access debuginfo indices of this struct or union, similar to clang ``__builtin_preserve_access_index()``. }]; } +def BTFDeclTagDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +Clang supports the ``__attribute__((btf_decl_tag("ARGUMENT")))`` attribute for +all targets. This attribute may be attached to a struct/union, struct/union +field, function, function parameter, variable or typedef declaration. If -g is +specified, the ``ARGUMENT`` info will be preserved in IR and be emitted to +dwarf. For BPF targets, the ``ARGUMENT`` info will be emitted to .BTF ELF +section too. + }]; +} + +def BTFTypeTagDocs : Documentation { + let Category = DocCatType; + let Content = [{ +Clang supports the ``__attribute__((btf_type_tag("ARGUMENT")))`` attribute for +all targets. It only has effect when ``-g`` is specified on the command line and +is currently silently ignored when not applied to a pointer type (note: this +scenario may be diagnosed in the future). + +The ``ARGUMENT`` string will be preserved in IR and emitted to DWARF for the +types used in variable declarations, function declarations, or typedef +declarations. + +For BPF targets, the ``ARGUMENT`` string will also be emitted to .BTF ELF +section. + }]; +} def MipsInterruptDocs : Documentation { let Category = DocCatFunction; @@ -2592,6 +2620,18 @@ full list of supported sanitizer flags. }]; } +def DisableSanitizerInstrumentationDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +Use the ``disable_sanitizer_instrumentation`` attribute on a function, +Objective-C method, or global variable, to specify that no sanitizer +instrumentation should be applied. + +This is not the same as ``__attribute__((no_sanitize(...)))``, which depending +on the tool may still insert instrumentation to prevent false positive reports. + }]; +} + def NoSanitizeAddressDocs : Documentation { let Category = DocCatFunction; // This function has multiple distinct spellings, and so it requires a custom @@ -5859,19 +5899,21 @@ def AcquireHandleDocs : Documentation { If this annotation is on a function or a function type it is assumed to return a new handle. In case this annotation is on an output parameter, the function is assumed to fill the corresponding argument with a new -handle. +handle. The attribute requires a string literal argument which used to +identify the handle with later uses of ``use_handle`` or +``release_handle``. .. code-block:: c++ // Output arguments from Zircon. zx_status_t zx_socket_create(uint32_t options, - zx_handle_t __attribute__((acquire_handle)) * out0, - zx_handle_t* out1 [[clang::acquire_handle]]); + zx_handle_t __attribute__((acquire_handle("zircon"))) * out0, + zx_handle_t* out1 [[clang::acquire_handle("zircon")]]); // Returned handle. - [[clang::acquire_handle]] int open(const char *path, int oflag, ... ); - int open(const char *path, int oflag, ... ) __attribute__((acquire_handle)); + [[clang::acquire_handle("tag")]] int open(const char *path, int oflag, ... ); + int open(const char *path, int oflag, ... ) __attribute__((acquire_handle("tag"))); }]; } @@ -5879,12 +5921,13 @@ def UseHandleDocs : Documentation { let Category = HandleDocs; let Content = [{ A function taking a handle by value might close the handle. If a function -parameter is annotated with ``use_handle`` it is assumed to not to change +parameter is annotated with ``use_handle(tag)`` it is assumed to not to change the state of the handle. It is also assumed to require an open handle to work with. +The attribute requires a string literal argument to identify the handle being used. .. code-block:: c++ - zx_status_t zx_port_wait(zx_handle_t handle [[clang::use_handle]], + zx_status_t zx_port_wait(zx_handle_t handle [[clang::use_handle("zircon")]], zx_time_t deadline, zx_port_packet_t* packet); }]; @@ -5893,12 +5936,13 @@ the state of the handle. It is also assumed to require an open handle to work wi def ReleaseHandleDocs : Documentation { let Category = HandleDocs; let Content = [{ -If a function parameter is annotated with ``release_handle`` it is assumed to -close the handle. It is also assumed to require an open handle to work with. +If a function parameter is annotated with ``release_handle(tag)`` it is assumed to +close the handle. It is also assumed to require an open handle to work with. The +attribute requires a string literal argument to identify the handle being released. .. code-block:: c++ - zx_status_t zx_handle_close(zx_handle_t handle [[clang::release_handle]]); + zx_status_t zx_handle_close(zx_handle_t handle [[clang::release_handle("tag")]]); }]; } @@ -6045,3 +6089,29 @@ def EnforceTCBLeafDocs : Documentation { - ``enforce_tcb_leaf(Name)`` indicates that this function is a part of the TCB named ``Name`` }]; } + +def ErrorAttrDocs : Documentation { + let Category = DocCatFunction; + let Heading = "error, warning"; + let Content = [{ +The ``error`` and ``warning`` function attributes can be used to specify a +custom diagnostic to be emitted when a call to such a function is not +eliminated via optimizations. This can be used to create compile time +assertions that depend on optimizations, while providing diagnostics +pointing to precise locations of the call site in the source. + +.. code-block:: c++ + + __attribute__((warning("oh no"))) void dontcall(); + void foo() { + if (someCompileTimeAssertionThatsTrue) + dontcall(); // Warning + + dontcall(); // Warning + + if (someCompileTimeAssertionThatsFalse) + dontcall(); // No Warning + sizeof(dontcall()); // No Warning + } + }]; +} diff --git a/contrib/llvm-project/clang/include/clang/Basic/Builtins.def b/contrib/llvm-project/clang/include/clang/Basic/Builtins.def index 0e3898537bcf..b05777889e79 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/Builtins.def +++ b/contrib/llvm-project/clang/include/clang/Basic/Builtins.def @@ -80,9 +80,7 @@ // builtin even if type doesn't match signature, and don't warn if we // can't be sure the type is right // F -> this is a libc/libm function with a '__builtin_' prefix added. -// f -> this is a libc/libm function without the '__builtin_' prefix. It can -// be followed by ':headername:' to state which header this function -// comes from. +// f -> this is a libc/libm function without the '__builtin_' prefix. // h -> this function requires a specific header or an explicit declaration. // i -> this is a runtime library implemented function without the // '__builtin_' prefix. It will be implemented in compiler-rt or libgcc. @@ -645,6 +643,12 @@ BUILTIN(__builtin_alloca, "v*z" , "Fn") BUILTIN(__builtin_alloca_with_align, "v*zIz", "Fn") 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_reduce_max, "v.", "nct") +BUILTIN(__builtin_reduce_min, "v.", "nct") + BUILTIN(__builtin_matrix_transpose, "v.", "nFt") BUILTIN(__builtin_matrix_column_major_load, "v.", "nFt") BUILTIN(__builtin_matrix_column_major_store, "v.", "nFt") @@ -794,6 +798,7 @@ ATOMIC_BUILTIN(__c11_atomic_fetch_sub, "v.", "t") ATOMIC_BUILTIN(__c11_atomic_fetch_and, "v.", "t") ATOMIC_BUILTIN(__c11_atomic_fetch_or, "v.", "t") ATOMIC_BUILTIN(__c11_atomic_fetch_xor, "v.", "t") +ATOMIC_BUILTIN(__c11_atomic_fetch_nand, "v.", "t") ATOMIC_BUILTIN(__c11_atomic_fetch_max, "v.", "t") ATOMIC_BUILTIN(__c11_atomic_fetch_min, "v.", "t") BUILTIN(__c11_atomic_thread_fence, "vi", "n") diff --git a/contrib/llvm-project/clang/include/clang/Basic/BuiltinsAMDGPU.def b/contrib/llvm-project/clang/include/clang/Basic/BuiltinsAMDGPU.def index 3570431d952c..2e1d3c7ccbff 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/BuiltinsAMDGPU.def +++ b/contrib/llvm-project/clang/include/clang/Basic/BuiltinsAMDGPU.def @@ -196,6 +196,19 @@ TARGET_BUILTIN(__builtin_amdgcn_perm, "UiUiUiUi", "nc", "gfx8-insts") TARGET_BUILTIN(__builtin_amdgcn_fmed3h, "hhhh", "nc", "gfx9-insts") +TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fadd_f64, "dd*1d", "t", "gfx90a-insts") +TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fadd_f32, "ff*1f", "t", "gfx90a-insts") +TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fadd_v2f16, "V2hV2h*1V2h", "t", "gfx90a-insts") +TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fmin_f64, "dd*1d", "t", "gfx90a-insts") +TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fmax_f64, "dd*1d", "t", "gfx90a-insts") + +TARGET_BUILTIN(__builtin_amdgcn_flat_atomic_fadd_f64, "dd*0d", "t", "gfx90a-insts") +TARGET_BUILTIN(__builtin_amdgcn_flat_atomic_fmin_f64, "dd*0d", "t", "gfx90a-insts") +TARGET_BUILTIN(__builtin_amdgcn_flat_atomic_fmax_f64, "dd*0d", "t", "gfx90a-insts") + +TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_f64, "dd*3d", "t", "gfx90a-insts") +TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_f32, "ff*3f", "t", "gfx8-insts") + //===----------------------------------------------------------------------===// // Deep learning builtins. //===----------------------------------------------------------------------===// diff --git a/contrib/llvm-project/clang/include/clang/Basic/BuiltinsNVPTX.def b/contrib/llvm-project/clang/include/clang/Basic/BuiltinsNVPTX.def index 3c96900136a4..025fef05c8e0 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/BuiltinsNVPTX.def +++ b/contrib/llvm-project/clang/include/clang/Basic/BuiltinsNVPTX.def @@ -39,7 +39,13 @@ #pragma push_macro("PTX70") #pragma push_macro("PTX71") #pragma push_macro("PTX72") -#define PTX72 "ptx72" +#pragma push_macro("PTX73") +#pragma push_macro("PTX74") +#pragma push_macro("PTX75") +#define PTX75 "ptx75" +#define PTX74 "ptx74|" PTX75 +#define PTX73 "ptx73|" PTX74 +#define PTX72 "ptx72|" PTX73 #define PTX71 "ptx71|" PTX72 #define PTX70 "ptx70|" PTX71 #define PTX65 "ptx65|" PTX70 @@ -683,6 +689,12 @@ BUILTIN(__nvvm_ldg_f2, "E2fE2fC*", "") BUILTIN(__nvvm_ldg_f4, "E4fE4fC*", "") BUILTIN(__nvvm_ldg_d2, "E2dE2dC*", "") +// Address space predicates. +BUILTIN(__nvvm_isspacep_const, "bvC*", "nc") +BUILTIN(__nvvm_isspacep_global, "bvC*", "nc") +BUILTIN(__nvvm_isspacep_local, "bvC*", "nc") +BUILTIN(__nvvm_isspacep_shared, "bvC*", "nc") + // Builtins to support WMMA instructions on sm_70 TARGET_BUILTIN(__hmma_m16n16k16_ld_a, "vi*iC*UiIi", "", AND(SM_70,PTX60)) TARGET_BUILTIN(__hmma_m16n16k16_ld_b, "vi*iC*UiIi", "", AND(SM_70,PTX60)) @@ -815,3 +827,6 @@ TARGET_BUILTIN(__nvvm_cp_async_wait_all, "v", "", AND(SM_80,PTX70)) #pragma pop_macro("PTX70") #pragma pop_macro("PTX71") #pragma pop_macro("PTX72") +#pragma pop_macro("PTX73") +#pragma pop_macro("PTX74") +#pragma pop_macro("PTX75") diff --git a/contrib/llvm-project/clang/include/clang/Basic/BuiltinsPPC.def b/contrib/llvm-project/clang/include/clang/Basic/BuiltinsPPC.def index dfe97af300f4..cd6b2df10e52 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/BuiltinsPPC.def +++ b/contrib/llvm-project/clang/include/clang/Basic/BuiltinsPPC.def @@ -74,8 +74,8 @@ BUILTIN(__builtin_ppc_fetch_and_swap, "UiUiD*Ui", "") BUILTIN(__builtin_ppc_fetch_and_swaplp, "ULiULiD*ULi", "") BUILTIN(__builtin_ppc_ldarx, "LiLiD*", "") BUILTIN(__builtin_ppc_lwarx, "iiD*", "") -BUILTIN(__builtin_ppc_lharx, "isD*", "") -BUILTIN(__builtin_ppc_lbarx, "UiUcD*", "") +BUILTIN(__builtin_ppc_lharx, "ssD*", "") +BUILTIN(__builtin_ppc_lbarx, "ccD*", "") BUILTIN(__builtin_ppc_stdcx, "iLiD*Li", "") BUILTIN(__builtin_ppc_stwcx, "iiD*i", "") BUILTIN(__builtin_ppc_sthcx, "isD*s", "") @@ -96,6 +96,13 @@ BUILTIN(__builtin_ppc_swdiv_nochk, "ddd", "") BUILTIN(__builtin_ppc_swdivs_nochk, "fff", "") BUILTIN(__builtin_ppc_alignx, "vIivC*", "nc") BUILTIN(__builtin_ppc_rdlam, "UWiUWiUWiUWIi", "nc") +BUILTIN(__builtin_ppc_compare_exp_uo, "idd", "") +BUILTIN(__builtin_ppc_compare_exp_lt, "idd", "") +BUILTIN(__builtin_ppc_compare_exp_gt, "idd", "") +BUILTIN(__builtin_ppc_compare_exp_eq, "idd", "") +BUILTIN(__builtin_ppc_test_data_class, "idIi", "t") +BUILTIN(__builtin_ppc_swdiv, "ddd", "") +BUILTIN(__builtin_ppc_swdivs, "fff", "") // Compare BUILTIN(__builtin_ppc_cmpeqb, "LLiLLiLLi", "") BUILTIN(__builtin_ppc_cmprb, "iCIiii", "") @@ -110,11 +117,11 @@ BUILTIN(__builtin_ppc_maddhd, "LLiLLiLLiLLi", "") BUILTIN(__builtin_ppc_maddhdu, "ULLiULLiULLiULLi", "") BUILTIN(__builtin_ppc_maddld, "LLiLLiLLiLLi", "") // Rotate -BUILTIN(__builtin_ppc_rlwnm, "UiUiIUiIUi", "") +BUILTIN(__builtin_ppc_rlwnm, "UiUiUiIUi", "") BUILTIN(__builtin_ppc_rlwimi, "UiUiUiIUiIUi", "") BUILTIN(__builtin_ppc_rldimi, "ULLiULLiULLiIUiIULLi", "") // load -BUILTIN(__builtin_ppc_load2r, "UiUs*", "") +BUILTIN(__builtin_ppc_load2r, "UsUs*", "") BUILTIN(__builtin_ppc_load4r, "UiUi*", "") BUILTIN(__builtin_ppc_load8r, "ULLiULLi*", "") // store @@ -144,6 +151,7 @@ BUILTIN(__builtin_ppc_mfspr, "ULiIi", "") BUILTIN(__builtin_ppc_mtmsr, "vUi", "") BUILTIN(__builtin_ppc_mtspr, "vIiULi", "") BUILTIN(__builtin_ppc_stfiw, "viC*d", "") +BUILTIN(__builtin_ppc_addex, "LLiLLiLLiCIi", "") BUILTIN(__builtin_ppc_get_timebase, "ULLi", "n") @@ -391,6 +399,7 @@ BUILTIN(__builtin_altivec_vcmpgtfp_p, "iiV4fV4f", "") BUILTIN(__builtin_altivec_vgbbd, "V16UcV16Uc", "") BUILTIN(__builtin_altivec_vbpermq, "V2ULLiV16UcV16Uc", "") +BUILTIN(__builtin_altivec_vbpermd, "V2ULLiV2ULLiV16Uc", "") // P8 Crypto built-ins. BUILTIN(__builtin_altivec_crypto_vsbox, "V2ULLiV2ULLi", "") @@ -771,6 +780,10 @@ BUILTIN(__builtin_cfuged, "ULLiULLiULLi", "") BUILTIN(__builtin_cntlzdm, "ULLiULLiULLi", "") BUILTIN(__builtin_cnttzdm, "ULLiULLiULLi", "") +// Double-double (un)pack +BUILTIN(__builtin_unpack_longdouble, "dLdIi", "") +BUILTIN(__builtin_pack_longdouble, "Lddd", "") + // Generate random number BUILTIN(__builtin_darn, "LLi", "") BUILTIN(__builtin_darn_raw, "LLi", "") @@ -812,18 +825,20 @@ BUILTIN(__builtin_dcbf, "vvC*", "") // its given accumulator. // Provided builtins with _mma_ prefix for compatibility. -CUSTOM_BUILTIN(mma_lxvp, vsx_lxvp, "W256SLLiW256C*", false) -CUSTOM_BUILTIN(mma_stxvp, vsx_stxvp, "vW256SLLiW256C*", false) +CUSTOM_BUILTIN(mma_lxvp, vsx_lxvp, "W256SLiW256C*", false) +CUSTOM_BUILTIN(mma_stxvp, vsx_stxvp, "vW256SLiW256C*", false) CUSTOM_BUILTIN(mma_assemble_pair, vsx_assemble_pair, "vW256*VV", false) CUSTOM_BUILTIN(mma_disassemble_pair, vsx_disassemble_pair, "vv*W256*", false) +CUSTOM_BUILTIN(vsx_build_pair, vsx_assemble_pair, "vW256*VV", false) +CUSTOM_BUILTIN(mma_build_acc, mma_assemble_acc, "vW512*VVVV", false) // UNALIASED_CUSTOM_BUILTIN macro is used for built-ins that have // the same name as that of the intrinsic they generate, i.e. the // ID and INTR are the same. // This avoids repeating the ID and INTR in the macro expression. -UNALIASED_CUSTOM_BUILTIN(vsx_lxvp, "W256SLLiW256C*", false) -UNALIASED_CUSTOM_BUILTIN(vsx_stxvp, "vW256SLLiW256C*", false) +UNALIASED_CUSTOM_BUILTIN(vsx_lxvp, "W256SLiW256C*", false) +UNALIASED_CUSTOM_BUILTIN(vsx_stxvp, "vW256SLiW256C*", false) UNALIASED_CUSTOM_BUILTIN(vsx_assemble_pair, "vW256*VV", false) UNALIASED_CUSTOM_BUILTIN(vsx_disassemble_pair, "vv*W256*", false) diff --git a/contrib/llvm-project/clang/include/clang/Basic/BuiltinsRISCV.def b/contrib/llvm-project/clang/include/clang/Basic/BuiltinsRISCV.def index b2b4950f92bd..06560415e686 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/BuiltinsRISCV.def +++ b/contrib/llvm-project/clang/include/clang/Basic/BuiltinsRISCV.def @@ -15,8 +15,6 @@ # define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS) #endif -#include "clang/Basic/riscv_vector_builtins.inc" - // Zbb extension TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "experimental-zbb") TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "experimental-zbb,64bit") diff --git a/contrib/llvm-project/clang/include/clang/Basic/BuiltinsRISCVVector.def b/contrib/llvm-project/clang/include/clang/Basic/BuiltinsRISCVVector.def new file mode 100644 index 000000000000..008cb939a30b --- /dev/null +++ b/contrib/llvm-project/clang/include/clang/Basic/BuiltinsRISCVVector.def @@ -0,0 +1,21 @@ +//==- BuiltinsRISCVVector.def - RISC-V Vector Builtin Database ---*- C++ -*-==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines the RISC-V-specific builtin function database. Users of +// this file must define the BUILTIN macro to make use of this information. +// +//===----------------------------------------------------------------------===// + +#if defined(BUILTIN) && !defined(TARGET_BUILTIN) +# define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS) +#endif + +#include "clang/Basic/riscv_vector_builtins.inc" + +#undef BUILTIN +#undef TARGET_BUILTIN diff --git a/contrib/llvm-project/clang/include/clang/Basic/BuiltinsWebAssembly.def b/contrib/llvm-project/clang/include/clang/Basic/BuiltinsWebAssembly.def index 04ec45aa3b74..057d968e9bca 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/BuiltinsWebAssembly.def +++ b/contrib/llvm-project/clang/include/clang/Basic/BuiltinsWebAssembly.def @@ -119,18 +119,22 @@ TARGET_BUILTIN(__builtin_wasm_all_true_i16x8, "iV8s", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_all_true_i32x4, "iV4i", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_all_true_i64x2, "iV2LLi", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_bitmask_i8x16, "iV16Sc", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_bitmask_i16x8, "iV8s", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_bitmask_i32x4, "iV4i", "nc", "simd128") -TARGET_BUILTIN(__builtin_wasm_bitmask_i64x2, "iV2LLi", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_bitmask_i8x16, "UiV16Sc", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_bitmask_i16x8, "UiV8s", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_bitmask_i32x4, "UiV4i", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_bitmask_i64x2, "UiV2LLi", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_abs_f32x4, "V4fV4f", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_abs_f64x2, "V2dV2d", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_min_f32x4, "V4fV4fV4f", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_max_f32x4, "V4fV4fV4f", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_pmin_f32x4, "V4fV4fV4f", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_pmax_f32x4, "V4fV4fV4f", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_min_f64x2, "V2dV2dV2d", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_max_f64x2, "V2dV2dV2d", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_pmin_f64x2, "V2dV2dV2d", "nc", "simd128") +TARGET_BUILTIN(__builtin_wasm_pmax_f64x2, "V2dV2dV2d", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_ceil_f32x4, "V4fV4f", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_floor_f32x4, "V4fV4f", "nc", "simd128") @@ -157,5 +161,28 @@ TARGET_BUILTIN(__builtin_wasm_narrow_u_i16x8_i32x4, "V8UsV4iV4i", "nc", "simd128 TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_s_f64x2_i32x4, "V4iV2d", "nc", "simd128") TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_u_f64x2_i32x4, "V4UiV2d", "nc", "simd128") +// Relaxed SIMD builtins (experimental) +TARGET_BUILTIN(__builtin_wasm_fma_f32x4, "V4fV4fV4fV4f", "nc", "relaxed-simd") +TARGET_BUILTIN(__builtin_wasm_fms_f32x4, "V4fV4fV4fV4f", "nc", "relaxed-simd") +TARGET_BUILTIN(__builtin_wasm_fma_f64x2, "V2dV2dV2dV2d", "nc", "relaxed-simd") +TARGET_BUILTIN(__builtin_wasm_fms_f64x2, "V2dV2dV2dV2d", "nc", "relaxed-simd") + +TARGET_BUILTIN(__builtin_wasm_laneselect_i8x16, "V16ScV16ScV16ScV16Sc", "nc", "relaxed-simd") +TARGET_BUILTIN(__builtin_wasm_laneselect_i16x8, "V8sV8sV8sV8s", "nc", "relaxed-simd") +TARGET_BUILTIN(__builtin_wasm_laneselect_i32x4, "V4iV4iV4iV4i", "nc", "relaxed-simd") +TARGET_BUILTIN(__builtin_wasm_laneselect_i64x2, "V2LLiV2LLiV2LLiV2LLi", "nc", "relaxed-simd") + +TARGET_BUILTIN(__builtin_wasm_relaxed_swizzle_i8x16, "V16ScV16ScV16Sc", "nc", "relaxed-simd") + +TARGET_BUILTIN(__builtin_wasm_relaxed_min_f32x4, "V4fV4fV4f", "nc", "relaxed-simd") +TARGET_BUILTIN(__builtin_wasm_relaxed_max_f32x4, "V4fV4fV4f", "nc", "relaxed-simd") +TARGET_BUILTIN(__builtin_wasm_relaxed_min_f64x2, "V2dV2dV2d", "nc", "relaxed-simd") +TARGET_BUILTIN(__builtin_wasm_relaxed_max_f64x2, "V2dV2dV2d", "nc", "relaxed-simd") + +TARGET_BUILTIN(__builtin_wasm_relaxed_trunc_s_i32x4_f32x4, "V4iV4f", "nc", "relaxed-simd") +TARGET_BUILTIN(__builtin_wasm_relaxed_trunc_u_i32x4_f32x4, "V4UiV4f", "nc", "relaxed-simd") +TARGET_BUILTIN(__builtin_wasm_relaxed_trunc_zero_s_i32x4_f64x2, "V4iV2d", "nc", "relaxed-simd") +TARGET_BUILTIN(__builtin_wasm_relaxed_trunc_zero_u_i32x4_f64x2, "V4UiV2d", "nc", "relaxed-simd") + #undef BUILTIN #undef TARGET_BUILTIN diff --git a/contrib/llvm-project/clang/include/clang/Basic/BuiltinsX86.def b/contrib/llvm-project/clang/include/clang/Basic/BuiltinsX86.def index 18e541fe9cb5..bc6208be4560 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/BuiltinsX86.def +++ b/contrib/llvm-project/clang/include/clang/Basic/BuiltinsX86.def @@ -421,9 +421,9 @@ TARGET_BUILTIN(__builtin_ia32_pcmpestrio128, "iV16ciV16ciIc","ncV:128:", "sse4.2 TARGET_BUILTIN(__builtin_ia32_pcmpestris128, "iV16ciV16ciIc","ncV:128:", "sse4.2") TARGET_BUILTIN(__builtin_ia32_pcmpestriz128, "iV16ciV16ciIc","ncV:128:", "sse4.2") -TARGET_BUILTIN(__builtin_ia32_crc32qi, "UiUiUc", "nc", "sse4.2") -TARGET_BUILTIN(__builtin_ia32_crc32hi, "UiUiUs", "nc", "sse4.2") -TARGET_BUILTIN(__builtin_ia32_crc32si, "UiUiUi", "nc", "sse4.2") +TARGET_BUILTIN(__builtin_ia32_crc32qi, "UiUiUc", "nc", "crc32") +TARGET_BUILTIN(__builtin_ia32_crc32hi, "UiUiUs", "nc", "crc32") +TARGET_BUILTIN(__builtin_ia32_crc32si, "UiUiUi", "nc", "crc32") // SSE4a TARGET_BUILTIN(__builtin_ia32_extrqi, "V2OiV2OiIcIc", "ncV:128:", "sse4a") @@ -1849,6 +1849,203 @@ TARGET_BUILTIN(__builtin_ia32_vp2intersect_d_512, "vV16iV16iUs*Us*", "nV:512:", TARGET_BUILTIN(__builtin_ia32_vp2intersect_d_256, "vV8iV8iUc*Uc*", "nV:256:", "avx512vp2intersect,avx512vl") TARGET_BUILTIN(__builtin_ia32_vp2intersect_d_128, "vV4iV4iUc*Uc*", "nV:128:", "avx512vp2intersect,avx512vl") +// AVX512 fp16 intrinsics +TARGET_BUILTIN(__builtin_ia32_vcomish, "iV8xV8xIiIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_addph512, "V32xV32xV32xIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_subph512, "V32xV32xV32xIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_mulph512, "V32xV32xV32xIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_divph512, "V32xV32xV32xIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_maxph512, "V32xV32xV32xIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_minph512, "V32xV32xV32xIi", "ncV:512:", "avx512fp16") + +TARGET_BUILTIN(__builtin_ia32_minph256, "V16xV16xV16x", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_minph128, "V8xV8xV8x", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_maxph256, "V16xV16xV16x", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_maxph128, "V8xV8xV8x", "ncV:128:", "avx512fp16,avx512vl") + +TARGET_BUILTIN(__builtin_ia32_addsh_round_mask, "V8xV8xV8xV8xUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_divsh_round_mask, "V8xV8xV8xV8xUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_mulsh_round_mask, "V8xV8xV8xV8xUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_subsh_round_mask, "V8xV8xV8xV8xUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_maxsh_round_mask, "V8xV8xV8xV8xUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_minsh_round_mask, "V8xV8xV8xV8xUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_cmpph512_mask, "UiV32xV32xIiUiIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_cmpph256_mask, "UsV16xV16xIiUs", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_cmpph128_mask, "UcV8xV8xIiUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_cmpsh_mask, "UcV8xV8xIiUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_loadsh128_mask, "V8xV8x*V8xUc", "nV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_storesh128_mask, "vV8x*V8xUc", "nV:128:", "avx512fp16") + +TARGET_BUILTIN(__builtin_ia32_rcpph128_mask, "V8xV8xV8xUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_rcpph256_mask, "V16xV16xV16xUs", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_rcpph512_mask, "V32xV32xV32xUi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_rsqrtph128_mask, "V8xV8xV8xUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_rsqrtph256_mask, "V16xV16xV16xUs", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_rsqrtph512_mask, "V32xV32xV32xUi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_getmantph128_mask, "V8xV8xIiV8xUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_getmantph256_mask, "V16xV16xIiV16xUs", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_getmantph512_mask, "V32xV32xIiV32xUiIi", "ncV:512:", "avx512fp16") + +TARGET_BUILTIN(__builtin_ia32_getexpph128_mask, "V8xV8xV8xUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_getexpph256_mask, "V16xV16xV16xUs", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_getexpph512_mask, "V32xV32xV32xUiIi", "ncV:512:", "avx512fp16") + +TARGET_BUILTIN(__builtin_ia32_scalefph128_mask, "V8xV8xV8xV8xUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_scalefph256_mask, "V16xV16xV16xV16xUs", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_scalefph512_mask, "V32xV32xV32xV32xUiIi", "ncV:512:", "avx512fp16") + +TARGET_BUILTIN(__builtin_ia32_rndscaleph_128_mask, "V8xV8xIiV8xUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_rndscaleph_256_mask, "V16xV16xIiV16xUs", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_rndscaleph_mask, "V32xV32xIiV32xUiIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_reduceph128_mask, "V8xV8xIiV8xUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_reduceph256_mask, "V16xV16xIiV16xUs", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_reduceph512_mask, "V32xV32xIiV32xUiIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_rcpsh_mask, "V8xV8xV8xV8xUc", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_rsqrtsh_mask, "V8xV8xV8xV8xUc", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_getmantsh_round_mask, "V8xV8xV8xIiV8xUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_getexpsh128_round_mask, "V8xV8xV8xV8xUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_scalefsh_round_mask, "V8xV8xV8xV8xUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_rndscalesh_round_mask, "V8xV8xV8xV8xUcIiIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_reducesh_mask, "V8xV8xV8xV8xUcIiIi", "ncV:128:", "avx512fp16") + +TARGET_BUILTIN(__builtin_ia32_sqrtph, "V8xV8x", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_sqrtph256, "V16xV16x", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_sqrtph512, "V32xV32xIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_sqrtsh_round_mask, "V8xV8xV8xV8xUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_fpclassph128_mask, "UcV8xIiUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_fpclassph256_mask, "UsV16xIiUs", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_fpclassph512_mask, "UiV32xIiUi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_fpclasssh_mask, "UcV8xIiUc", "ncV:128:", "avx512fp16") + +TARGET_BUILTIN(__builtin_ia32_vcvtpd2ph128_mask, "V8xV2dV8xUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtpd2ph256_mask, "V8xV4dV8xUc", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtpd2ph512_mask, "V8xV8dV8xUcIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtph2pd128_mask, "V2dV8xV2dUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtph2pd256_mask, "V4dV8xV4dUc", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtph2pd512_mask, "V8dV8xV8dUcIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtsh2ss_round_mask, "V4fV4fV8xV4fUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtss2sh_round_mask, "V8xV8xV4fV8xUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtsd2sh_round_mask, "V8xV8xV2dV8xUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtsh2sd_round_mask, "V2dV2dV8xV2dUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtph2w128_mask, "V8sV8xV8sUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtph2w256_mask, "V16sV16xV16sUs", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtph2w512_mask, "V32sV32xV32sUiIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvttph2w128_mask, "V8sV8xV8sUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvttph2w256_mask, "V16sV16xV16sUs", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvttph2w512_mask, "V32sV32xV32sUiIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtw2ph128_mask, "V8xV8sV8xUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtw2ph256_mask, "V16xV16sV16xUs", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtw2ph512_mask, "V32xV32sV32xUiIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtph2uw128_mask, "V8UsV8xV8UsUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtph2uw256_mask, "V16UsV16xV16UsUs", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtph2uw512_mask, "V32UsV32xV32UsUiIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvttph2uw128_mask, "V8UsV8xV8UsUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvttph2uw256_mask, "V16UsV16xV16UsUs", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvttph2uw512_mask, "V32UsV32xV32UsUiIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtuw2ph128_mask, "V8xV8UsV8xUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtuw2ph256_mask, "V16xV16UsV16xUs", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtuw2ph512_mask, "V32xV32UsV32xUiIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtph2dq128_mask, "V4iV8xV4iUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtph2dq256_mask, "V8iV8xV8iUc", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtph2dq512_mask, "V16iV16xV16iUsIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtph2udq128_mask, "V4UiV8xV4UiUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtph2udq256_mask, "V8UiV8xV8UiUc", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtph2udq512_mask, "V16UiV16xV16UiUsIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtdq2ph128_mask, "V8xV4iV8xUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtdq2ph256_mask, "V8xV8iV8xUc", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtdq2ph512_mask, "V16xV16iV16xUsIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtudq2ph128_mask, "V8xV4UiV8xUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtudq2ph256_mask, "V8xV8UiV8xUc", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtudq2ph512_mask, "V16xV16UiV16xUsIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvttph2dq128_mask, "V4iV8xV4iUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvttph2dq256_mask, "V8iV8xV8iUc", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvttph2dq512_mask, "V16iV16xV16iUsIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvttph2udq128_mask, "V4UiV8xV4UiUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvttph2udq256_mask, "V8UiV8xV8UiUc", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvttph2udq512_mask, "V16UiV16xV16UiUsIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtqq2ph128_mask, "V8xV2OiV8xUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtqq2ph256_mask, "V8xV4OiV8xUc", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtqq2ph512_mask, "V8xV8OiV8xUcIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtph2qq128_mask, "V2OiV8xV2OiUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtph2qq256_mask, "V4OiV8xV4OiUc", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtph2qq512_mask, "V8OiV8xV8OiUcIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtuqq2ph128_mask, "V8xV2UOiV8xUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtuqq2ph256_mask, "V8xV4UOiV8xUc", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtuqq2ph512_mask, "V8xV8UOiV8xUcIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtph2uqq128_mask, "V2UOiV8xV2UOiUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtph2uqq256_mask, "V4UOiV8xV4UOiUc", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtph2uqq512_mask, "V8UOiV8xV8UOiUcIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvttph2qq128_mask, "V2OiV8xV2OiUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvttph2qq256_mask, "V4OiV8xV4OiUc", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvttph2qq512_mask, "V8OiV8xV8OiUcIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvttph2uqq128_mask, "V2UOiV8xV2UOiUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvttph2uqq256_mask, "V4UOiV8xV4UOiUc", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvttph2uqq512_mask, "V8UOiV8xV8UOiUcIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtsh2si32, "iV8xIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtsh2usi32, "UiV8xIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtusi2sh, "V8xV8xUiIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtsi2sh, "V8xV8xiIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvttsh2si32, "iV8xIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvttsh2usi32, "UiV8xIi", "ncV:128:", "avx512fp16") + +TARGET_BUILTIN(__builtin_ia32_vcvtph2psx128_mask, "V4fV8xV4fUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtph2psx256_mask, "V8fV8xV8fUc", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtph2psx512_mask, "V16fV16xV16fUsIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtps2phx128_mask, "V8xV4fV8xUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtps2phx256_mask, "V8xV8fV8xUc", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vcvtps2phx512_mask, "V16xV16fV16xUsIi", "ncV:512:", "avx512fp16") + +TARGET_BUILTIN(__builtin_ia32_vfmaddph, "V8xV8xV8xV8x", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vfmaddph256, "V16xV16xV16xV16x", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vfmaddph512_mask, "V32xV32xV32xV32xUiIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfmaddph512_mask3, "V32xV32xV32xV32xUiIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfmaddph512_maskz, "V32xV32xV32xV32xUiIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfmaddsubph, "V8xV8xV8xV8x", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vfmaddsubph256, "V16xV16xV16xV16x", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vfmaddsubph512_mask, "V32xV32xV32xV32xUiIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfmaddsubph512_maskz, "V32xV32xV32xV32xUiIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfmaddsubph512_mask3, "V32xV32xV32xV32xUiIi", "ncV:512:", "avx512fp16") + +TARGET_BUILTIN(__builtin_ia32_vfmsubaddph512_mask3, "V32xV32xV32xV32xUiIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfmsubph512_mask3, "V32xV32xV32xV32xUiIi", "ncV:512:", "avx512fp16") + +TARGET_BUILTIN(__builtin_ia32_vfmaddsh3_mask, "V8xV8xV8xV8xUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfmaddsh3_maskz, "V8xV8xV8xV8xUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfmaddsh3_mask3, "V8xV8xV8xV8xUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfmsubsh3_mask3, "V8xV8xV8xV8xUcIi", "ncV:128:", "avx512fp16") + +TARGET_BUILTIN(__builtin_ia32_vfmaddcph128_mask, "V4fV4fV4fV4fUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vfmaddcph128_maskz, "V4fV4fV4fV4fUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vfmaddcph256_mask, "V8fV8fV8fV8fUc", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vfmaddcph256_maskz, "V8fV8fV8fV8fUc", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vfmaddcph512_mask, "V16fV16fV16fV16fUsIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfmaddcph512_maskz, "V16fV16fV16fV16fUsIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfmaddcph512_mask3, "V16fV16fV16fV16fUsIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfcmaddcph128_mask, "V4fV4fV4fV4fUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vfcmaddcph128_maskz, "V4fV4fV4fV4fUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vfcmaddcph256_mask, "V8fV8fV8fV8fUc", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vfcmaddcph256_maskz, "V8fV8fV8fV8fUc", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vfcmaddcph512_mask, "V16fV16fV16fV16fUsIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfcmaddcph512_maskz, "V16fV16fV16fV16fUsIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfcmaddcph512_mask3, "V16fV16fV16fV16fUsIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfmaddcsh_mask, "V4fV4fV4fV4fUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfmaddcsh_maskz, "V4fV4fV4fV4fUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfcmaddcsh_mask, "V4fV4fV4fV4fUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfcmaddcsh_maskz, "V4fV4fV4fV4fUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfmaddcsh_round_mask, "V4fV4fV4fV4fUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfmaddcsh_round_mask3, "V4fV4fV4fV4fUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfcmaddcsh_round_mask, "V4fV4fV4fV4fUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfcmaddcsh_round_mask3, "V4fV4fV4fV4fUcIi", "ncV:128:", "avx512fp16") + +TARGET_BUILTIN(__builtin_ia32_vfmulcsh_mask, "V4fV4fV4fV4fUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfcmulcsh_mask, "V4fV4fV4fV4fUcIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfmulcph128_mask, "V4fV4fV4fV4fUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vfmulcph256_mask, "V8fV8fV8fV8fUc", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vfmulcph512_mask, "V16fV16fV16fV16fUsIi", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vfcmulcph128_mask, "V4fV4fV4fV4fUc", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vfcmulcph256_mask, "V8fV8fV8fV8fUc", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_vfcmulcph512_mask, "V16fV16fV16fV16fUsIi", "ncV:512:", "avx512fp16") + // generic select intrinsics TARGET_BUILTIN(__builtin_ia32_selectb_128, "V16cUsV16cV16c", "ncV:128:", "avx512bw,avx512vl") TARGET_BUILTIN(__builtin_ia32_selectb_256, "V32cUiV32cV32c", "ncV:256:", "avx512bw,avx512vl") @@ -1859,6 +2056,9 @@ TARGET_BUILTIN(__builtin_ia32_selectw_512, "V32sUiV32sV32s", "ncV:512:", "avx512 TARGET_BUILTIN(__builtin_ia32_selectd_128, "V4iUcV4iV4i", "ncV:128:", "avx512vl") TARGET_BUILTIN(__builtin_ia32_selectd_256, "V8iUcV8iV8i", "ncV:256:", "avx512vl") TARGET_BUILTIN(__builtin_ia32_selectd_512, "V16iUsV16iV16i", "ncV:512:", "avx512f") +TARGET_BUILTIN(__builtin_ia32_selectph_128, "V8xUcV8xV8x", "ncV:128:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_selectph_256, "V16xUsV16xV16x", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_selectph_512, "V32xUiV32xV32x", "ncV:512:", "avx512fp16") TARGET_BUILTIN(__builtin_ia32_selectq_128, "V2OiUcV2OiV2Oi", "ncV:128:", "avx512vl") TARGET_BUILTIN(__builtin_ia32_selectq_256, "V4OiUcV4OiV4Oi", "ncV:256:", "avx512vl") TARGET_BUILTIN(__builtin_ia32_selectq_512, "V8OiUcV8OiV8Oi", "ncV:512:", "avx512f") @@ -1868,6 +2068,7 @@ TARGET_BUILTIN(__builtin_ia32_selectps_512, "V16fUsV16fV16f", "ncV:512:", "avx51 TARGET_BUILTIN(__builtin_ia32_selectpd_128, "V2dUcV2dV2d", "ncV:128:", "avx512vl") TARGET_BUILTIN(__builtin_ia32_selectpd_256, "V4dUcV4dV4d", "ncV:256:", "avx512vl") TARGET_BUILTIN(__builtin_ia32_selectpd_512, "V8dUcV8dV8d", "ncV:512:", "avx512f") +TARGET_BUILTIN(__builtin_ia32_selectsh_128, "V8xUcV8xV8x", "ncV:128:", "avx512fp16") TARGET_BUILTIN(__builtin_ia32_selectss_128, "V4fUcV4fV4f", "ncV:128:", "avx512f") TARGET_BUILTIN(__builtin_ia32_selectsd_128, "V2dUcV2dV2d", "ncV:128:", "avx512f") @@ -1878,12 +2079,24 @@ TARGET_BUILTIN(__builtin_ia32_reduce_and_d512, "iV16i", "ncV:512:", "avx512f") TARGET_BUILTIN(__builtin_ia32_reduce_and_q512, "OiV8Oi", "ncV:512:", "avx512f") TARGET_BUILTIN(__builtin_ia32_reduce_fadd_pd512, "ddV8d", "ncV:512:", "avx512f") TARGET_BUILTIN(__builtin_ia32_reduce_fadd_ps512, "ffV16f", "ncV:512:", "avx512f") +TARGET_BUILTIN(__builtin_ia32_reduce_fadd_ph512, "xxV32x", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_reduce_fadd_ph256, "xxV16x", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_reduce_fadd_ph128, "xxV8x", "ncV:128:", "avx512fp16,avx512vl") TARGET_BUILTIN(__builtin_ia32_reduce_fmax_pd512, "dV8d", "ncV:512:", "avx512f") TARGET_BUILTIN(__builtin_ia32_reduce_fmax_ps512, "fV16f", "ncV:512:", "avx512f") +TARGET_BUILTIN(__builtin_ia32_reduce_fmax_ph512, "xV32x", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_reduce_fmax_ph256, "xV16x", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_reduce_fmax_ph128, "xV8x", "ncV:128:", "avx512fp16,avx512vl") TARGET_BUILTIN(__builtin_ia32_reduce_fmin_pd512, "dV8d", "ncV:512:", "avx512f") TARGET_BUILTIN(__builtin_ia32_reduce_fmin_ps512, "fV16f", "ncV:512:", "avx512f") +TARGET_BUILTIN(__builtin_ia32_reduce_fmin_ph512, "xV32x", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_reduce_fmin_ph256, "xV16x", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_reduce_fmin_ph128, "xV8x", "ncV:128:", "avx512fp16,avx512vl") TARGET_BUILTIN(__builtin_ia32_reduce_fmul_pd512, "ddV8d", "ncV:512:", "avx512f") TARGET_BUILTIN(__builtin_ia32_reduce_fmul_ps512, "ffV16f", "ncV:512:", "avx512f") +TARGET_BUILTIN(__builtin_ia32_reduce_fmul_ph512, "xxV32x", "ncV:512:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_reduce_fmul_ph256, "xxV16x", "ncV:256:", "avx512fp16,avx512vl") +TARGET_BUILTIN(__builtin_ia32_reduce_fmul_ph128, "xxV8x", "ncV:128:", "avx512fp16,avx512vl") TARGET_BUILTIN(__builtin_ia32_reduce_mul_d512, "iV16i", "ncV:512:", "avx512f") TARGET_BUILTIN(__builtin_ia32_reduce_mul_q512, "OiV8Oi", "ncV:512:", "avx512f") TARGET_BUILTIN(__builtin_ia32_reduce_or_d512, "iV16i", "ncV:512:", "avx512f") diff --git a/contrib/llvm-project/clang/include/clang/Basic/BuiltinsX86_64.def b/contrib/llvm-project/clang/include/clang/Basic/BuiltinsX86_64.def index ce2b1decdf6c..c3b9703a9cc6 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/BuiltinsX86_64.def +++ b/contrib/llvm-project/clang/include/clang/Basic/BuiltinsX86_64.def @@ -44,7 +44,7 @@ TARGET_BUILTIN(__builtin_ia32_cvttsd2si64, "OiV2d", "ncV:128:", "sse2") TARGET_BUILTIN(__builtin_ia32_movnti64, "vOi*Oi", "n", "sse2") TARGET_BUILTIN(__builtin_ia32_vec_ext_v2di, "OiV2OiIi", "ncV:128:", "sse2") TARGET_BUILTIN(__builtin_ia32_vec_set_v2di, "V2OiV2OiOiIi", "ncV:128:", "sse4.1") -TARGET_BUILTIN(__builtin_ia32_crc32di, "UOiUOiUOi", "nc", "sse4.2") +TARGET_BUILTIN(__builtin_ia32_crc32di, "UOiUOiUOi", "nc", "crc32") TARGET_BUILTIN(__builtin_ia32_vec_ext_v4di, "OiV4OiIi", "ncV:256:", "avx") TARGET_BUILTIN(__builtin_ia32_vec_set_v4di, "V4OiV4OiOiIi", "ncV:256:", "avx") TARGET_BUILTIN(__builtin_ia32_rdfsbase32, "Ui", "n", "fsgsbase") @@ -92,6 +92,12 @@ TARGET_BUILTIN(__builtin_ia32_cvtsi2sd64, "V2dV2dOiIi", "ncV:128:", "avx512f") TARGET_BUILTIN(__builtin_ia32_cvtsi2ss64, "V4fV4fOiIi", "ncV:128:", "avx512f") TARGET_BUILTIN(__builtin_ia32_cvtusi2sd64, "V2dV2dUOiIi", "ncV:128:", "avx512f") TARGET_BUILTIN(__builtin_ia32_cvtusi2ss64, "V4fV4fUOiIi", "ncV:128:", "avx512f") +TARGET_BUILTIN(__builtin_ia32_vcvtsh2si64, "OiV8xIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtsh2usi64, "UOiV8xIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtusi642sh, "V8xV8xUOiIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvtsi642sh, "V8xV8xOiIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvttsh2si64, "OiV8xIi", "ncV:128:", "avx512fp16") +TARGET_BUILTIN(__builtin_ia32_vcvttsh2usi64, "UOiV8xIi", "ncV:128:", "avx512fp16") TARGET_BUILTIN(__builtin_ia32_directstore_u64, "vULi*ULi", "n", "movdiri") // UINTR diff --git a/contrib/llvm-project/clang/include/clang/Basic/CLWarnings.h b/contrib/llvm-project/clang/include/clang/Basic/CLWarnings.h new file mode 100644 index 000000000000..e3351f430c43 --- /dev/null +++ b/contrib/llvm-project/clang/include/clang/Basic/CLWarnings.h @@ -0,0 +1,26 @@ +//===--- CLWarnings.h - Maps some cl.exe warning ids -----------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_BASIC_CLWARNINGS_H +#define LLVM_CLANG_BASIC_CLWARNINGS_H + +#include "llvm/ADT/Optional.h" + +namespace clang { + +namespace diag { +enum class Group; +} + +/// For cl.exe warning IDs that cleany map to clang diagnostic groups, +/// returns the corresponding group. Else, returns an empty Optional. +llvm::Optional<diag::Group> diagGroupFromCLWarningID(unsigned); + +} // end namespace clang + +#endif // LLVM_CLANG_BASIC_CLWARNINGS_H diff --git a/contrib/llvm-project/clang/include/clang/Basic/CharInfo.h b/contrib/llvm-project/clang/include/clang/Basic/CharInfo.h index 8577475fab06..c751b6a005e2 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/CharInfo.h +++ b/contrib/llvm-project/clang/include/clang/Basic/CharInfo.h @@ -43,10 +43,15 @@ LLVM_READNONE inline bool isASCII(char c) { return static_cast<unsigned char>(c) <= 127; } +LLVM_READNONE inline bool isASCII(unsigned char c) { return c <= 127; } + +/// Returns true if this is an ASCII character. +LLVM_READNONE inline bool isASCII(uint32_t c) { return c <= 127; } + /// Returns true if this is a valid first character of a C identifier, /// which is [a-zA-Z_]. -LLVM_READONLY inline bool isIdentifierHead(unsigned char c, - bool AllowDollar = false) { +LLVM_READONLY inline bool isAsciiIdentifierStart(unsigned char c, + bool AllowDollar = false) { using namespace charinfo; if (InfoTable[c] & (CHAR_UPPER|CHAR_LOWER|CHAR_UNDER)) return true; @@ -55,8 +60,8 @@ LLVM_READONLY inline bool isIdentifierHead(unsigned char c, /// Returns true if this is a body character of a C identifier, /// which is [a-zA-Z0-9_]. -LLVM_READONLY inline bool isIdentifierBody(unsigned char c, - bool AllowDollar = false) { +LLVM_READONLY inline bool isAsciiIdentifierContinue(unsigned char c, + bool AllowDollar = false) { using namespace charinfo; if (InfoTable[c] & (CHAR_UPPER|CHAR_LOWER|CHAR_DIGIT|CHAR_UNDER)) return true; @@ -181,13 +186,13 @@ LLVM_READONLY inline char toUppercase(char c) { /// /// Note that this is a very simple check; it does not accept UCNs as valid /// identifier characters. -LLVM_READONLY inline bool isValidIdentifier(StringRef S, - bool AllowDollar = false) { - if (S.empty() || !isIdentifierHead(S[0], AllowDollar)) +LLVM_READONLY inline bool isValidAsciiIdentifier(StringRef S, + bool AllowDollar = false) { + if (S.empty() || !isAsciiIdentifierStart(S[0], AllowDollar)) return false; for (StringRef::iterator I = S.begin(), E = S.end(); I != E; ++I) - if (!isIdentifierBody(*I, AllowDollar)) + if (!isAsciiIdentifierContinue(*I, AllowDollar)) return false; return true; diff --git a/contrib/llvm-project/clang/include/clang/Basic/CodeGenOptions.def b/contrib/llvm-project/clang/include/clang/Basic/CodeGenOptions.def index e3202cf88756..94b3003a9c33 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/CodeGenOptions.def +++ b/contrib/llvm-project/clang/include/clang/Basic/CodeGenOptions.def @@ -54,6 +54,7 @@ CODEGENOPT(UniqueBasicBlockSectionNames, 1, 1) ///< Set for -funique-basic-block CODEGENOPT(EnableAIXExtendedAltivecABI, 1, 0) ///< Set for -mabi=vec-extabi. Enables the extended Altivec ABI on AIX. ENUM_CODEGENOPT(FramePointer, FramePointerKind, 2, FramePointerKind::None) /// frame-pointer: all,non-leaf,none +CODEGENOPT(ClearASTBeforeBackend , 1, 0) ///< Free the AST before running backend code generation. Only works with -disable-free. CODEGENOPT(DisableFree , 1, 0) ///< Don't free memory. CODEGENOPT(DiscardValueNames , 1, 0) ///< Discard Value Names from the IR (LLVMContext flag) CODEGENOPT(DisableLLVMPasses , 1, 0) ///< Don't run any LLVM IR passes to get @@ -91,6 +92,8 @@ CODEGENOPT(EmulatedTLS , 1, 0) ///< Set by default or -f[no-]emulated-tls. CODEGENOPT(ExplicitEmulatedTLS , 1, 0) ///< Set if -f[no-]emulated-tls is used. /// Embed Bitcode mode (off/all/bitcode/marker). ENUM_CODEGENOPT(EmbedBitcode, EmbedBitcodeKind, 2, Embed_Off) +/// Inline asm dialect, -masm=(att|intel) +ENUM_CODEGENOPT(InlineAsmDialect, InlineAsmDialectKind, 1, IAD_ATT) CODEGENOPT(ForbidGuardVariables , 1, 0) ///< Issue errors if C++ guard variables ///< are required. CODEGENOPT(FunctionSections , 1, 0) ///< Set when -ffunction-sections is enabled. @@ -188,6 +191,7 @@ CODEGENOPT(NoZeroInitializedInBSS , 1, 0) ///< -fno-zero-initialized-in-bss. ENUM_CODEGENOPT(ObjCDispatchMethod, ObjCDispatchMethodKind, 2, Legacy) /// Replace certain message sends with calls to ObjC runtime entrypoints CODEGENOPT(ObjCConvertMessagesToRuntimeCalls , 1, 1) +CODEGENOPT(ObjCAvoidHeapifyLocalBlocks, 1, 0) VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< The -O[0-3] option specified. VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) is specified. @@ -259,6 +263,8 @@ CODEGENOPT(SanitizeCoverageInlineBoolFlag, 1, 0) ///< Use inline bool flag. CODEGENOPT(SanitizeCoveragePCTable, 1, 0) ///< Create a PC Table. CODEGENOPT(SanitizeCoverageNoPrune, 1, 0) ///< Disable coverage pruning. CODEGENOPT(SanitizeCoverageStackDepth, 1, 0) ///< Enable max stack depth tracing +CODEGENOPT(SanitizeCoverageTraceLoads, 1, 0) ///< Enable tracing of loads. +CODEGENOPT(SanitizeCoverageTraceStores, 1, 0) ///< Enable tracing of stores. CODEGENOPT(SanitizeStats , 1, 0) ///< Collect statistics for sanitizers. CODEGENOPT(SimplifyLibCalls , 1, 1) ///< Set when -fbuiltin is enabled. CODEGENOPT(SoftFloat , 1, 0) ///< -soft-float. @@ -274,7 +280,7 @@ VALUE_CODEGENOPT(TimeTraceGranularity, 32, 500) ///< Minimum time granularity (i CODEGENOPT(UnrollLoops , 1, 0) ///< Control whether loops are unrolled. CODEGENOPT(RerollLoops , 1, 0) ///< Control whether loops are rerolled. CODEGENOPT(NoUseJumpTables , 1, 0) ///< Set when -fno-jump-tables is enabled. -CODEGENOPT(UnwindTables , 1, 0) ///< Emit unwind tables. +VALUE_CODEGENOPT(UnwindTables, 2, 0) ///< Unwind tables (1) or asynchronous unwind tables (2) CODEGENOPT(VectorizeLoop , 1, 0) ///< Run loop vectorizer. CODEGENOPT(VectorizeSLP , 1, 0) ///< Run SLP vectorizer. CODEGENOPT(ProfileSampleAccurate, 1, 0) ///< Sample profile is accurate. @@ -293,6 +299,8 @@ CODEGENOPT(StackRealignment , 1, 0) ///< Control whether to force stack ///< realignment. CODEGENOPT(UseInitArray , 1, 0) ///< Control whether to use .init_array or ///< .ctors. +VALUE_CODEGENOPT(LoopAlignment , 32, 0) ///< Overrides default loop + ///< alignment, if not 0. VALUE_CODEGENOPT(StackAlignment , 32, 0) ///< Overrides default stack ///< alignment, if not 0. VALUE_CODEGENOPT(StackProbeSize , 32, 4096) ///< Overrides default stack @@ -317,6 +325,12 @@ CODEGENOPT(DebugFwdTemplateParams, 1, 0) ///< Whether to emit complete ///< template parameter descriptions in ///< forward declarations (versus just ///< including them in the name). +ENUM_CODEGENOPT(DebugSimpleTemplateNames, codegenoptions::DebugTemplateNamesKind, 2, codegenoptions::DebugTemplateNamesKind::Full) ///< Whether to emit template parameters + ///< in the textual names of template + ///< specializations. + ///< Implies DebugFwdTemplateNames to + ///< allow decorated names to be + ///< reconstructed when needed. CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize use-lists. CODEGENOPT(WholeProgramVTables, 1, 0) ///< Whether to apply whole-program @@ -437,6 +451,14 @@ CODEGENOPT(AAPCSBitfieldWidth, 1, 1) /// propagate signaling NaN inputs per IEEE 754-2008 (AMDGPU Only) CODEGENOPT(EmitIEEENaNCompliantInsts, 1, 1) +// Whether to emit Swift Async function extended frame information: auto, +// never, always. +ENUM_CODEGENOPT(SwiftAsyncFramePointer, SwiftAsyncFramePointerKind, 2, + SwiftAsyncFramePointerKind::Always) + +/// Whether to skip RAX setup when passing variable arguments (x86 only). +CODEGENOPT(SkipRaxSetup, 1, 0) + #undef CODEGENOPT #undef ENUM_CODEGENOPT #undef VALUE_CODEGENOPT diff --git a/contrib/llvm-project/clang/include/clang/Basic/CodeGenOptions.h b/contrib/llvm-project/clang/include/clang/Basic/CodeGenOptions.h index 617c255641ef..664e4998b8de 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/CodeGenOptions.h +++ b/contrib/llvm-project/clang/include/clang/Basic/CodeGenOptions.h @@ -97,6 +97,11 @@ public: Embed_Marker // Embed a marker as a placeholder for bitcode. }; + enum InlineAsmDialectKind { + IAD_ATT, + IAD_Intel, + }; + // This field stores one of the allowed values for the option // -fbasic-block-sections=. The allowed values with this option are: // {"labels", "all", "list=<file>", "none"}. @@ -125,6 +130,13 @@ public: All, // Keep all frame pointers. }; + enum class SwiftAsyncFramePointerKind { + Auto, // Choose Swift async extended frame info based on deployment target. + Always, // Unconditionally emit Swift async extended frame info. + Never, // Don't emit Swift async extended frame info. + Default = Always, + }; + enum FiniteLoopsKind { Language, // Not specified, use language standard. Always, // All loops are assumed to be finite. @@ -456,7 +468,8 @@ public: // Check if any one of SanitizeCoverage* is enabled. bool hasSanitizeCoverage() const { return SanitizeCoverageType || SanitizeCoverageIndirectCalls || - SanitizeCoverageTraceCmp; + SanitizeCoverageTraceCmp || SanitizeCoverageTraceLoads || + SanitizeCoverageTraceStores; } }; diff --git a/contrib/llvm-project/clang/include/clang/Basic/Cuda.h b/contrib/llvm-project/clang/include/clang/Basic/Cuda.h index aa12724cbf0c..8c08ab3f5d74 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/Cuda.h +++ b/contrib/llvm-project/clang/include/clang/Basic/Cuda.h @@ -31,8 +31,13 @@ enum class CudaVersion { CUDA_110, CUDA_111, CUDA_112, - LATEST = CUDA_112, - LATEST_SUPPORTED = CUDA_101, + CUDA_113, + CUDA_114, + CUDA_115, + FULLY_SUPPORTED = CUDA_115, + PARTIALLY_SUPPORTED = + CUDA_115, // Partially supported. Proceed with a warning. + NEW = 10000, // Too new. Issue a warning, but allow using it. }; const char *CudaVersionToString(CudaVersion V); // Input is "Major.Minor" diff --git a/contrib/llvm-project/clang/include/clang/Basic/DebugInfoOptions.h b/contrib/llvm-project/clang/include/clang/Basic/DebugInfoOptions.h index c1259d7797db..a99a2b5903d7 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/DebugInfoOptions.h +++ b/contrib/llvm-project/clang/include/clang/Basic/DebugInfoOptions.h @@ -54,6 +54,12 @@ enum DebugInfoKind { UnusedTypeInfo, }; +enum class DebugTemplateNamesKind { + Full, + Simple, + Mangled +}; + } // end namespace codegenoptions } // end namespace clang diff --git a/contrib/llvm-project/clang/include/clang/Basic/Diagnostic.h b/contrib/llvm-project/clang/include/clang/Basic/Diagnostic.h index 3b915fb15a89..e5577e74fa63 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/Diagnostic.h +++ b/contrib/llvm-project/clang/include/clang/Basic/Diagnostic.h @@ -164,9 +164,9 @@ struct DiagnosticStorage { /// The values for the various substitution positions. /// /// This is used when the argument is not an std::string. The specific value - /// is mangled into an intptr_t and the interpretation depends on exactly + /// is mangled into an uint64_t and the interpretation depends on exactly /// what sort of argument kind it is. - intptr_t DiagArgumentsVal[MaxArguments]; + uint64_t DiagArgumentsVal[MaxArguments]; /// The values for the various substitution positions that have /// string arguments. @@ -807,6 +807,9 @@ public: bool setSeverityForGroup(diag::Flavor Flavor, StringRef Group, diag::Severity Map, SourceLocation Loc = SourceLocation()); + bool setSeverityForGroup(diag::Flavor Flavor, diag::Group Group, + diag::Severity Map, + SourceLocation Loc = SourceLocation()); /// Set the warning-as-error flag for the given diagnostic group. /// @@ -1176,7 +1179,7 @@ public: DiagStorage = nullptr; } - void AddTaggedVal(intptr_t V, DiagnosticsEngine::ArgumentKind Kind) const { + void AddTaggedVal(uint64_t V, DiagnosticsEngine::ArgumentKind Kind) const { if (!DiagStorage) DiagStorage = getStorage(); @@ -1399,6 +1402,12 @@ inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB, return DB; } +inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB, + int64_t I) { + DB.AddTaggedVal(I, DiagnosticsEngine::ak_sint); + return DB; +} + // We use enable_if here to prevent that this overload is selected for // pointers or other arguments that are implicitly convertible to bool. template <typename T> @@ -1416,6 +1425,12 @@ inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB, } inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB, + uint64_t I) { + DB.AddTaggedVal(I, DiagnosticsEngine::ak_uint); + return DB; +} + +inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB, tok::TokenKind I) { DB.AddTaggedVal(static_cast<unsigned>(I), DiagnosticsEngine::ak_tokenkind); return DB; @@ -1577,18 +1592,18 @@ public: /// Return the specified signed integer argument. /// \pre getArgKind(Idx) == DiagnosticsEngine::ak_sint - int getArgSInt(unsigned Idx) const { + int64_t getArgSInt(unsigned Idx) const { assert(getArgKind(Idx) == DiagnosticsEngine::ak_sint && "invalid argument accessor!"); - return (int)DiagObj->DiagStorage.DiagArgumentsVal[Idx]; + return (int64_t)DiagObj->DiagStorage.DiagArgumentsVal[Idx]; } /// Return the specified unsigned integer argument. /// \pre getArgKind(Idx) == DiagnosticsEngine::ak_uint - unsigned getArgUInt(unsigned Idx) const { + uint64_t getArgUInt(unsigned Idx) const { assert(getArgKind(Idx) == DiagnosticsEngine::ak_uint && "invalid argument accessor!"); - return (unsigned)DiagObj->DiagStorage.DiagArgumentsVal[Idx]; + return DiagObj->DiagStorage.DiagArgumentsVal[Idx]; } /// Return the specified IdentifierInfo argument. @@ -1602,7 +1617,7 @@ public: /// Return the specified non-string argument in an opaque form. /// \pre getArgKind(Idx) != DiagnosticsEngine::ak_std_string - intptr_t getRawArg(unsigned Idx) const { + uint64_t getRawArg(unsigned Idx) const { assert(getArgKind(Idx) != DiagnosticsEngine::ak_std_string && "invalid argument accessor!"); return DiagObj->DiagStorage.DiagArgumentsVal[Idx]; diff --git a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticASTKinds.td b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticASTKinds.td index 496d86ee2fe7..d788c8517914 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticASTKinds.td +++ b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticASTKinds.td @@ -567,8 +567,8 @@ def remark_sanitize_address_insert_extra_padding_accepted : Remark< def remark_sanitize_address_insert_extra_padding_rejected : Remark< "-fsanitize-address-field-padding ignored for %0 because it " "%select{is not C++|is packed|is a union|is trivially copyable|" - "has trivial destructor|is standard layout|is in a blacklisted file|" - "is blacklisted}1">, ShowInSystemHeader, + "has trivial destructor|is standard layout|is in a ignorelisted file|" + "is ignorelisted}1">, ShowInSystemHeader, InGroup<SanitizeAddressRemarks>; def warn_npot_ms_struct : Warning< diff --git a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticCategories.h b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticCategories.h index 0decf15080a0..2bbdeb31a7b7 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticCategories.h +++ b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticCategories.h @@ -19,6 +19,13 @@ namespace clang { #undef GET_CATEGORY_TABLE DiagCat_NUM_CATEGORIES }; + + enum class Group { +#define DIAG_ENTRY(GroupName, FlagNameOffset, Members, SubGroups) GroupName, +#include "clang/Basic/DiagnosticGroups.inc" +#undef CATEGORY +#undef DIAG_ENTRY + }; } // end namespace diag } // end namespace clang diff --git a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticCommonKinds.td b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticCommonKinds.td index 4dff3379ed35..fe4ac5ed6cb0 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticCommonKinds.td +++ b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticCommonKinds.td @@ -149,8 +149,8 @@ def err_nullability_conflicting : Error< // OpenCL Section 6.8.g def err_opencl_unknown_type_specifier : Error< - "%select{OpenCL C|C++ for OpenCL}0 version %1 does not support the " - "'%2' %select{type qualifier|storage class specifier}3">; + "%0 does not support the '%1' " + "%select{type qualifier|storage class specifier}2">; def warn_unknown_attribute_ignored : Warning< "unknown attribute %0 ignored">, InGroup<UnknownAttributes>; @@ -298,6 +298,8 @@ def err_target_unsupported_unaligned : Error< "the %0 sub-architecture does not support unaligned accesses">; def err_target_unsupported_execute_only : Error< "execute only is not supported for the %0 sub-architecture">; +def err_target_unsupported_tp_hard : Error< + "hardware TLS register is not supported for the %0 sub-architecture">; def err_target_unsupported_mcmse : Error< "-mcmse is not supported for %0">; def err_opt_not_valid_with_opt : Error< @@ -306,6 +308,8 @@ def err_opt_not_valid_without_opt : Error< "option '%0' cannot be specified without '%1'">; def err_opt_not_valid_on_target : Error< "option '%0' cannot be specified on this target">; +def err_invalid_feature_combination : Error< + "invalid feature combination: %0">; // Source manager def err_cannot_open_file : Error<"cannot open file '%0': %1">, DefaultFatal; diff --git a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticDriverKinds.td b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticDriverKinds.td index fc3704303a95..ff8c36910e13 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -16,6 +16,8 @@ def err_drv_unsupported_opt_with_suggestion : Error< "unsupported option '%0'; did you mean '%1'?">; def err_drv_unsupported_opt_for_target : Error< "unsupported option '%0' for target '%1'">; +def err_drv_unsupported_opt_for_language_mode : Error< + "unsupported option '%0' for language mode '%1'">; def err_drv_unsupported_option_argument : Error< "unsupported argument '%1' to option '%0'">; def err_drv_unknown_stdin_type : Error< @@ -29,6 +31,9 @@ def err_drv_invalid_riscv_arch_name : Error< "invalid arch name '%0', %1">; def err_drv_invalid_riscv_ext_arch_name : Error< "invalid arch name '%0', %1 '%2'">; +def warn_drv_invalid_arch_name_with_suggestion : Warning< + "ignoring invalid /arch: argument '%0'; for %select{64|32}1-bit expected one of %2">, + InGroup<UnusedCommandLineArgument>; def warn_drv_avr_mcu_not_specified : Warning< "no target microcontroller specified on command line, cannot " "link standard libraries, please pass -mmcu=<mcu name>">, @@ -52,38 +57,57 @@ def warn_drv_avr_stdlib_not_linked: Warning< "standard library not linked and so no interrupt vector table or " "compiler runtime routines will be linked">, InGroup<AVRRtlibLinkingQuirks>; -def err_drv_cuda_bad_gpu_arch : Error<"Unsupported CUDA gpu architecture: %0">; +def err_drv_cuda_bad_gpu_arch : Error<"unsupported CUDA gpu architecture: %0">; def err_drv_no_cuda_installation : Error< - "cannot find CUDA installation. Provide its path via --cuda-path, or pass " - "-nocudainc to build without CUDA includes.">; + "cannot find CUDA installation; provide its path via '--cuda-path', or pass " + "'-nocudainc' to build without CUDA includes">; def err_drv_no_cuda_libdevice : Error< - "cannot find libdevice for %0. Provide path to different CUDA installation " - "via --cuda-path, or pass -nocudalib to build without linking with libdevice.">; + "cannot find libdevice for %0; provide path to different CUDA installation " + "via '--cuda-path', or pass '-nocudalib' to build without linking with " + "libdevice">; def err_drv_no_rocm_device_lib : Error< - "cannot find ROCm device library%select{| for %1}0. Provide its path via --rocm-path or " - "--rocm-device-lib-path, or pass -nogpulib to build without ROCm device library.">; + "cannot find ROCm device library%select{| for %1}0; provide its path via " + "'--rocm-path' or '--rocm-device-lib-path', or pass '-nogpulib' to build " + "without ROCm device library">; 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.">; + "cannot find HIP runtime; provide its path via '--rocm-path', or pass " + "'-nogpuinc' to build without HIP runtime">; def err_drv_undetermined_amdgpu_arch : Error< - "Cannot determine AMDGPU architecture: %0. Consider passing it via --march.">; + "cannot determine AMDGPU architecture: %0; consider passing it via " + "'--march'">; def err_drv_cuda_version_unsupported : Error< "GPU arch %0 is supported by CUDA versions between %1 and %2 (inclusive), " - "but installation at %3 is %4. Use --cuda-path to specify a different CUDA " - "install, pass a different GPU arch with --cuda-gpu-arch, or pass " - "--no-cuda-version-check.">; -def warn_drv_unknown_cuda_version: Warning< - "Unknown CUDA version. %0 Assuming the latest supported version %1">, + "but installation at %3 is %4; use '--cuda-path' to specify a different CUDA " + "install, pass a different GPU arch with '--cuda-gpu-arch', or pass " + "'--no-cuda-version-check'">; +def warn_drv_new_cuda_version: Warning< + "CUDA version%0 is newer than the latest%select{| partially}1 supported version %2">, + InGroup<CudaUnknownVersion>; +def warn_drv_partially_supported_cuda_version: Warning< + "CUDA version %0 is only partially supported">, InGroup<CudaUnknownVersion>; -def err_drv_cuda_host_arch : Error<"unsupported architecture '%0' for host compilation.">; -def err_drv_mix_cuda_hip : Error<"Mixed Cuda and HIP compilation is not supported.">; -def err_drv_bad_target_id : Error<"Invalid target ID: %0 (A target ID is a processor name " - "followed by an optional list of predefined features post-fixed by a plus or minus sign deliminated " - "by colon, e.g. 'gfx908:sramecc+:xnack-')">; -def err_drv_bad_offload_arch_combo : Error<"Invalid offload arch combinations: %0 and %1 (For a specific " - "processor, a feature should either exist in all offload archs, or not exist in any offload archs)">; +def err_drv_cuda_host_arch : Error< + "unsupported architecture '%0' for host compilation">; +def err_drv_mix_cuda_hip : Error< + "mixed CUDA and HIP compilation is not supported">; +def err_drv_bad_target_id : Error< + "invalid target ID '%0'; format is a processor name followed by an optional " + "colon-delimited list of features followed by an enable/disable sign (e.g., " + "'gfx908:sramecc+:xnack-')">; +def err_drv_bad_offload_arch_combo : Error< + "invalid offload arch combinations: '%0' and '%1' (for a specific processor, " + "a feature should either exist in all offload archs, or not exist in any " + "offload archs)">; +def warn_drv_unsupported_option_for_offload_arch_req_feature : Warning< + "ignoring '%0' option as it is not currently supported for " + "offload arch '%1'. Use it with an offload arch containing '%2' instead">, + InGroup<OptionIgnored>; +def warn_drv_unsupported_option_for_target : Warning< + "ignoring '%0' option as it is not currently supported for target '%1'">, + 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< @@ -129,6 +153,8 @@ def err_drv_invalid_Xopenmp_target_with_args : Error< "invalid -Xopenmp-target argument: '%0', options requiring arguments are unsupported">; def err_drv_argument_only_allowed_with : Error< "invalid argument '%0' only allowed with '%1'">; +def err_drv_minws_unsupported_input_type : Error< + "'-fminimize-whitespace' invalid for input of type %0">; def err_drv_amdgpu_ieee_without_no_honor_nans : Error< "invalid argument '-mno-amdgpu-ieee' only allowed with relaxed NaN handling">; def err_drv_argument_not_allowed_with : Error< @@ -169,8 +195,8 @@ def err_drv_invalid_argument_to_option : Error< "invalid argument '%0' to -%1">; def err_drv_malformed_sanitizer_ignorelist : Error< "malformed sanitizer ignorelist: '%0'">; -def err_drv_malformed_sanitizer_coverage_whitelist : Error< - "malformed sanitizer coverage whitelist: '%0'">; +def err_drv_malformed_sanitizer_coverage_allowlist : Error< + "malformed sanitizer coverage allowlist: '%0'">; def err_drv_malformed_sanitizer_coverage_ignorelist : Error< "malformed sanitizer coverage ignorelist: '%0'">; def err_drv_duplicate_config : Error< @@ -193,7 +219,7 @@ def err_target_unsupported_arch def err_cpu_unsupported_isa : Error<"CPU '%0' does not support '%1' execution mode">; def err_arch_unsupported_isa - : Error<"Architecture '%0' does not support '%1' execution mode">; + : Error<"architecture '%0' does not support '%1' execution mode">; def err_drv_I_dash_not_supported : Error< "'%0' not supported, please use -iquote instead">; @@ -218,6 +244,7 @@ def err_drv_invalid_value : Error<"invalid value '%1' in '%0'">; def err_drv_invalid_int_value : Error<"invalid integral value '%1' in '%0'">; def err_drv_invalid_value_with_suggestion : Error< "invalid value '%1' in '%0', expected one of: %2">; +def err_drv_alignment_not_power_of_two : Error<"alignment is not a power of 2 in '%0'">; def err_drv_invalid_remap_file : Error< "invalid option '%0' not of the form <from-file>;<to-file>">; def err_drv_invalid_gcc_output_type : Error< @@ -233,6 +260,7 @@ def warn_invalid_ios_deployment_target : Warning< DefaultError; def err_invalid_macos_32bit_deployment_target : Error< "32-bit targets are not supported when building for Mac Catalyst">; +def err_drv_invalid_os_in_arg : Error<"invalid OS value '%0' in '%1'">; def err_drv_conflicting_deployment_targets : Error< "conflicting deployment targets, both '%0' and '%1' are present in environment">; def err_arc_unsupported_on_runtime : Error< @@ -260,20 +288,26 @@ def err_drv_optimization_remark_format : Error< "unknown remark serializer format: '%0'">; def err_drv_no_neon_modifier : Error<"[no]neon is not accepted as modifier, please use [no]simd instead">; def err_drv_invalid_omp_target : Error<"OpenMP target is invalid: '%0'">; +def err_drv_debug_no_new_runtime : Error<"OpenMP target device debugging enabled with incompatible runtime">; def err_drv_incompatible_omp_arch : Error<"OpenMP target architecture '%0' pointer size is incompatible with host '%1'">; def err_drv_omp_host_ir_file_not_found : Error< - "The provided host compiler IR file '%0' is required to generate code for OpenMP target regions but cannot be found.">; + "provided host compiler IR file '%0' is required to generate code for OpenMP " + "target regions but cannot be found">; def err_drv_omp_host_target_not_supported : Error< - "The target '%0' is not a supported OpenMP host target.">; + "target '%0' is not a supported OpenMP host target">; def err_drv_expecting_fopenmp_with_fopenmp_targets : Error< - "The option -fopenmp-targets must be used in conjunction with a -fopenmp option compatible with offloading, please use -fopenmp=libomp or -fopenmp=libiomp5.">; + "'-fopenmp-targets' must be used in conjunction with a '-fopenmp' option " + "compatible with offloading; e.g., '-fopenmp=libomp' or '-fopenmp=libiomp5'">; def err_drv_omp_offload_target_missingbcruntime : Error< - "No library '%0' found in the default clang lib directory or in LIBRARY_PATH. Please use --libomptarget-%1-bc-path to specify %1 bitcode library.">; -def err_drv_omp_offload_target_bcruntime_not_found : Error<"Bitcode library '%0' does not exist.">; -def err_drv_omp_offload_target_cuda_version_not_support : Error<"NVPTX target requires CUDA 9.2 or above. CUDA %0 is detected.">; + "no library '%0' found in the default clang lib directory or in LIBRARY_PATH" + "; use '--libomptarget-%1-bc-path' to specify %1 bitcode library">; +def err_drv_omp_offload_target_bcruntime_not_found : Error< + "bitcode library '%0' does not exist">; +def err_drv_omp_offload_target_cuda_version_not_support : Error< + "NVPTX target requires CUDA 9.2 or above; CUDA %0 detected">; def warn_drv_omp_offload_target_duplicate : Warning< - "The OpenMP offloading target '%0' is similar to target '%1' already specified - will be ignored.">, - InGroup<OpenMPTarget>; + "OpenMP offloading target '%0' is similar to target '%1' already specified; " + "will be ignored">, InGroup<OpenMPTarget>; def err_drv_unsupported_embed_bitcode : Error<"%0 is not supported with -fembed-bitcode">; def err_drv_bitcode_unsupported_on_toolchain : Error< @@ -300,7 +334,8 @@ def warn_drv_unsupported_debug_info_opt_for_target : Warning< "debug information option '%0' is not supported for target '%1'">, InGroup<UnsupportedTargetOpt>; def warn_drv_dwarf_version_limited_by_target : Warning< - "debug information option '%0' is not supported. It needs DWARF-%2 but target '%1' only provides DWARF-%3.">, + "debug information option '%0' is not supported; requires DWARF-%2 but " + "target '%1' only provides DWARF-%3">, InGroup<UnsupportedTargetOpt>; def warn_c_kext : Warning< "ignoring -fapple-kext which is valid for C++ and Objective-C++ only">; @@ -367,7 +402,7 @@ def err_sls_hardening_arm_not_supported : Error< def note_drv_command_failed_diag_msg : Note< "diagnostic msg: %0">; def note_drv_t_option_is_global : Note< - "The last /TC or /TP option takes precedence over earlier instances">; + "the last '/TC' or '/TP' option takes precedence over earlier instances">; def note_drv_address_sanitizer_debug_runtime : Note< "AddressSanitizer doesn't support linking with debug runtime libraries yet">; def note_drv_use_standard : Note<"use '%0'" @@ -407,7 +442,8 @@ def err_test_module_file_extension_format : Error< def warn_slash_u_filename : Warning<"'/U%0' treated as the '/U' option">, InGroup<DiagGroup<"slash-u-filename">>; -def note_use_dashdash : Note<"Use '--' to treat subsequent arguments as filenames">; +def note_use_dashdash : Note< + "use '--' to treat subsequent arguments as filenames">; def err_drv_ropi_rwpi_incompatible_with_pic : Error< "embedded and GOT-based position independence are incompatible">; @@ -476,14 +512,14 @@ def warn_drv_ps4_sdk_dir : Warning< def err_drv_unsupported_linker : Error<"unsupported value '%0' for -linker option">; def err_drv_defsym_invalid_format : Error<"defsym must be of the form: sym=value: %0">; -def err_drv_defsym_invalid_symval : Error<"Value is not an integer: %0">; +def err_drv_defsym_invalid_symval : Error<"value is not an integer: %0">; def warn_drv_msvc_not_found : Warning< "unable to find a Visual Studio installation; " "try running Clang from a developer command prompt">, InGroup<DiagGroup<"msvc-not-found">>; def warn_drv_fuse_ld_path : Warning< - "'-fuse-ld=' taking a path is deprecated. Use '--ld-path=' instead">, + "'-fuse-ld=' taking a path is deprecated; use '--ld-path=' instead">, InGroup<FUseLdPath>, DefaultIgnore; def warn_drv_fine_grained_bitfield_accesses_ignored : Warning< @@ -503,11 +539,11 @@ def warn_drv_global_isel_incomplete_opt : Warning< InGroup<GlobalISel>; def warn_drv_moutline_unsupported_opt : Warning< - "The '%0' architecture does not support -moutline; flag ignored">, + "'%0' does not support '-moutline'; flag ignored">, InGroup<OptionIgnored>; def warn_drv_moutline_atomics_unsupported_opt : Warning< - "The '%0' architecture does not support -moutline-atomics; flag ignored">, + "'%0' does not support '-moutline-atomics'; flag ignored">, InGroup<OptionIgnored>; def warn_drv_darwin_sdk_invalid_settings : Warning< @@ -515,25 +551,28 @@ def warn_drv_darwin_sdk_invalid_settings : Warning< InGroup<DiagGroup<"darwin-sdk-settings">>; def err_drv_trivial_auto_var_init_zero_disabled : Error< - "-ftrivial-auto-var-init=zero hasn't been enabled. Enable it at your own peril for benchmarking purpose only with " - "-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang">; + "'-ftrivial-auto-var-init=zero' hasn't been enabled; enable it at your own " + "peril for benchmarking purpose only with " + "'-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang'">; def err_drv_trivial_auto_var_init_stop_after_missing_dependency : Error< - "-ftrivial-auto-var-init-stop-after=* is used without -ftrivial-auto-var-init=zero or -ftrivial-auto-var-init=pattern.">; + "'-ftrivial-auto-var-init-stop-after=*' is used without " + "'-ftrivial-auto-var-init=zero' or '-ftrivial-auto-var-init=pattern'">; def err_drv_trivial_auto_var_init_stop_after_invalid_value : Error< - "-ftrivial-auto-var-init-stop-after=* only accepts positive integers.">; + "'-ftrivial-auto-var-init-stop-after=*' only accepts positive integers">; -def warn_drv_msp430_hwmult_unsupported : Warning<"the given MCU does not " - "support hardware multiply, but -mhwmult is set to %0.">, - InGroup<InvalidCommandLineArgument>; -def warn_drv_msp430_hwmult_mismatch : Warning<"the given MCU supports %0 " - "hardware multiply, but -mhwmult is set to %1.">, +def warn_drv_msp430_hwmult_unsupported : Warning< + "the given MCU does not support hardware multiply, but '-mhwmult' is set to " + "%0">, InGroup<InvalidCommandLineArgument>; +def warn_drv_msp430_hwmult_mismatch : Warning< + "the given MCU supports %0 hardware multiply, but '-mhwmult' is set to %1">, InGroup<InvalidCommandLineArgument>; -def warn_drv_msp430_hwmult_no_device : Warning<"no MCU device specified, but " - "'-mhwmult' is set to 'auto', assuming no hardware multiply. Use -mmcu to " - "specify a MSP430 device, or -mhwmult to set hardware multiply type " - "explicitly.">, InGroup<InvalidCommandLineArgument>; +def warn_drv_msp430_hwmult_no_device : Warning< + "no MCU device specified, but '-mhwmult' is set to 'auto', assuming no " + "hardware multiply; use '-mmcu' to specify an MSP430 device, or '-mhwmult' " + "to set the hardware multiply type explicitly">, + InGroup<InvalidCommandLineArgument>; def warn_drv_libstdcxx_not_found : Warning< "include path for libstdc++ headers not found; pass '-stdlib=libc++' on the " @@ -542,17 +581,26 @@ def warn_drv_libstdcxx_not_found : Warning< def err_drv_cannot_mix_options : Error<"cannot specify '%1' along with '%0'">; -def err_drv_invalid_object_mode : Error<"OBJECT_MODE setting %0 is not recognized and is not a valid setting.">; +def err_drv_invalid_object_mode : Error< + "OBJECT_MODE setting %0 is not recognized and is not a valid setting">; def err_aix_unsupported_tls_model : Error<"TLS model '%0' is not yet supported on AIX">; -def err_invalid_cxx_abi : Error<"Invalid C++ ABI name '%0'">; +def err_invalid_cxx_abi : Error<"invalid C++ ABI name '%0'">; def err_unsupported_cxx_abi : Error<"C++ ABI '%0' is not supported on target triple '%1'">; -def note_cc1_round_trip_original : Note<"Original arguments in round-trip: %0">; -def note_cc1_round_trip_generated : Note<"Generated arguments #%0 in round-trip: %1">; -def remark_cc1_round_trip_generated : Remark<"Generated arguments #%0 in round-trip: %1">, InGroup<RoundTripCC1Args>; -def err_cc1_round_trip_fail_then_ok : Error<"Original arguments parse failed, then succeeded in round-trip">; -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 note_cc1_round_trip_original : Note<"original arguments in round-trip: %0">; +def note_cc1_round_trip_generated : Note< + "generated arguments #%0 in round-trip: %1">; +def remark_cc1_round_trip_generated : Remark< + "generated arguments #%0 in round-trip: %1">, InGroup<RoundTripCC1Args>; +def err_cc1_round_trip_fail_then_ok : Error< + "original arguments parse failed, then succeeded in round-trip">; +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_drv_ssp_missing_offset_argument : Error< + "'%0' is used without '-mstack-protector-guard-offset', and there is no default">; } diff --git a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticFrontendKinds.td b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticFrontendKinds.td index 0f4ccec38550..eacb7e4de0ea 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticFrontendKinds.td @@ -22,10 +22,11 @@ def note_fe_inline_asm_here : Note<"instantiated into assembly here">; def err_fe_source_mgr : Error<"%0">, CatSourceMgr; def warn_fe_source_mgr : Warning<"%0">, CatSourceMgr, InGroup<BackendSourceMgr>; def note_fe_source_mgr : Note<"%0">, CatSourceMgr; -def err_fe_cannot_link_module : Error<"cannot link module '%0': %1">, - DefaultFatal; +def err_fe_linking_module : Error<"cannot link module '%0': %1">, DefaultFatal; +def warn_fe_linking_module : Warning<"linking module '%0': %1">, InGroup<LinkerWarnings>; +def note_fe_linking_module : Note<"linking module '%0': %1">; -def warn_fe_frame_larger_than : Warning<"stack frame size (%0) exceeds limit (%1) in %q2">, +def warn_fe_frame_larger_than : Warning<"stack frame size (%0) exceeds limit (%1) in '%2'">, BackendInfo, InGroup<BackendFrameLargerThan>; def warn_fe_backend_frame_larger_than: Warning<"%0">, BackendInfo, InGroup<BackendFrameLargerThan>; @@ -72,6 +73,12 @@ def note_fe_backend_invalid_loc : Note<"could " def err_fe_backend_unsupported : Error<"%0">, BackendInfo; def warn_fe_backend_unsupported : Warning<"%0">, BackendInfo; +def err_fe_backend_error_attr : + Error<"call to %0 declared with 'error' attribute: %1">, BackendInfo; +def warn_fe_backend_warning_attr : + Warning<"call to %0 declared with 'warning' attribute: %1">, BackendInfo, + InGroup<BackendWarningAttributes>; + def err_fe_invalid_code_complete_file : Error< "cannot locate code-completion file %0">, DefaultFatal; def err_fe_dependency_file_requires_MT : Error< @@ -229,6 +236,8 @@ def remark_module_build : Remark<"building module '%0' as '%1'">, InGroup<ModuleBuild>; def remark_module_build_done : Remark<"finished building module '%0'">, InGroup<ModuleBuild>; +def remark_module_lock : Remark<"locking '%0' to build module '%1'">, + InGroup<ModuleLock>; def err_modules_embed_file_not_found : Error<"file '%0' specified by '-fmodules-embed-file=' not found">, DefaultFatal; @@ -245,7 +254,7 @@ def err_invalid_vfs_overlay : Error< "invalid virtual filesystem overlay file '%0'">, DefaultFatal; def warn_option_invalid_ocl_version : Warning< - "OpenCL version %0 does not support the option '%1'">, InGroup<Deprecated>; + "%0 does not support the option '%1'">, InGroup<Deprecated>; def err_builtin_needs_feature : Error<"%0 needs target feature %1">; def err_function_needs_feature : Error< diff --git a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticGroups.td b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticGroups.td index 4b4928a7a00e..85d373845c81 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticGroups.td +++ b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticGroups.td @@ -54,7 +54,9 @@ def CompoundTokenSplit : DiagGroup<"compound-token-split", CompoundTokenSplitBySpace]>; def CoroutineMissingUnhandledException : DiagGroup<"coroutine-missing-unhandled-exception">; -def Coroutine : DiagGroup<"coroutine", [CoroutineMissingUnhandledException]>; +def DeprecatedExperimentalCoroutine : + DiagGroup<"deprecated-experimental-coroutine">; +def Coroutine : DiagGroup<"coroutine", [CoroutineMissingUnhandledException, DeprecatedExperimentalCoroutine]>; def ObjCBoolConstantConversion : DiagGroup<"objc-bool-constant-conversion">; def ConstantConversion : DiagGroup<"constant-conversion", [BitFieldConstantConversion, @@ -64,6 +66,8 @@ def StringConversion : DiagGroup<"string-conversion">; def SignConversion : DiagGroup<"sign-conversion">; def PointerBoolConversion : DiagGroup<"pointer-bool-conversion">; def UndefinedBoolConversion : DiagGroup<"undefined-bool-conversion">; +def BitwiseInsteadOfLogical : DiagGroup<"bitwise-instead-of-logical">; +def BoolOperation : DiagGroup<"bool-operation", [BitwiseInsteadOfLogical]>; def BoolConversion : DiagGroup<"bool-conversion", [PointerBoolConversion, UndefinedBoolConversion]>; def IntConversion : DiagGroup<"int-conversion">; @@ -184,6 +188,7 @@ def DeprecatedThisCapture : DiagGroup<"deprecated-this-capture">; def DeprecatedVolatile : DiagGroup<"deprecated-volatile">; def DeprecatedWritableStr : DiagGroup<"deprecated-writable-strings", [CXX11CompatDeprecatedWritableStr]>; +def DeprecatedPragma : DiagGroup<"deprecated-pragma">; // FIXME: Why is DeprecatedImplementations not in this group? def Deprecated : DiagGroup<"deprecated", [DeprecatedAnonEnumEnumConversion, DeprecatedArrayCompare, @@ -198,6 +203,7 @@ def Deprecated : DiagGroup<"deprecated", [DeprecatedAnonEnumEnumConversion, DeprecatedEnumEnumConversion, DeprecatedEnumFloatConversion, DeprecatedIncrementBool, + DeprecatedPragma, DeprecatedRegister, DeprecatedThisCapture, DeprecatedVolatile, @@ -393,6 +399,7 @@ def Dangling : DiagGroup<"dangling", [DanglingField, DanglingGsl, ReturnStackAddress]>; def DistributedObjectModifiers : DiagGroup<"distributed-object-modifiers">; +def DllexportExplicitInstantiationDecl : DiagGroup<"dllexport-explicit-instantiation-decl">; def ExcessInitializers : DiagGroup<"excess-initializers">; def ExpansionToDefined : DiagGroup<"expansion-to-defined">; def FlagEnum : DiagGroup<"flag-enum">; @@ -400,7 +407,8 @@ def IncrementBool : DiagGroup<"increment-bool", [DeprecatedIncrementBool]>; def InfiniteRecursion : DiagGroup<"infinite-recursion">; def PureVirtualCallFromCtorDtor: DiagGroup<"call-to-pure-virtual-from-ctor-dtor">; def GNUImaginaryConstant : DiagGroup<"gnu-imaginary-constant">; -def IgnoredQualifiers : DiagGroup<"ignored-qualifiers">; +def IgnoredReferenceQualifiers : DiagGroup<"ignored-reference-qualifiers">; +def IgnoredQualifiers : DiagGroup<"ignored-qualifiers", [IgnoredReferenceQualifiers]>; def : DiagGroup<"import">; def GNUIncludeNext : DiagGroup<"gnu-include-next">; def IncompatibleMSStruct : DiagGroup<"incompatible-ms-struct">; @@ -462,6 +470,7 @@ def MismatchedParameterTypes : DiagGroup<"mismatched-parameter-types">; def MismatchedReturnTypes : DiagGroup<"mismatched-return-types">; def MismatchedTags : DiagGroup<"mismatched-tags">; def MissingFieldInitializers : DiagGroup<"missing-field-initializers">; +def ModuleLock : DiagGroup<"module-lock">; def ModuleBuild : DiagGroup<"module-build">; def ModuleImport : DiagGroup<"module-import">; def ModuleConflict : DiagGroup<"module-conflict">; @@ -642,6 +651,8 @@ def AmbiguousMacro : DiagGroup<"ambiguous-macro">; def KeywordAsMacro : DiagGroup<"keyword-macro">; def ReservedIdAsMacro : DiagGroup<"reserved-macro-identifier">; def ReservedIdAsMacroAlias : DiagGroup<"reserved-id-macro", [ReservedIdAsMacro]>; +def RestrictExpansionMacro : DiagGroup<"restrict-expansion">; +def FinalMacro : DiagGroup<"final-macro">; // Just silence warnings about -Wstrict-aliasing for now. def : DiagGroup<"strict-aliasing=0">; @@ -742,6 +753,7 @@ def UnusedLocalTypedef : DiagGroup<"unused-local-typedef">; def UnusedPropertyIvar : DiagGroup<"unused-property-ivar">; def UnusedGetterReturnValue : DiagGroup<"unused-getter-return-value">; def UsedButMarkedUnused : DiagGroup<"used-but-marked-unused">; +def UsedSearchPath : DiagGroup<"search-path-usage">; def UserDefinedLiterals : DiagGroup<"user-defined-literals">; def UserDefinedWarnings : DiagGroup<"user-defined-warnings">; def ReorderCtor : DiagGroup<"reorder-ctor">; @@ -816,8 +828,10 @@ def ReservedIdentifier : DiagGroup<"reserved-identifier", // under separate flags. // def UnreachableCodeLoopIncrement : DiagGroup<"unreachable-code-loop-increment">; +def UnreachableCodeFallthrough : DiagGroup<"unreachable-code-fallthrough">; def UnreachableCode : DiagGroup<"unreachable-code", - [UnreachableCodeLoopIncrement]>; + [UnreachableCodeLoopIncrement, + UnreachableCodeFallthrough]>; def UnreachableCodeBreak : DiagGroup<"unreachable-code-break">; def UnreachableCodeReturn : DiagGroup<"unreachable-code-return">; def UnreachableCodeAggressive : DiagGroup<"unreachable-code-aggressive", @@ -940,6 +954,7 @@ def Extra : DiagGroup<"extra", [ ]>; def Most : DiagGroup<"most", [ + BoolOperation, CharSubscript, Comment, DeleteNonVirtualDtor, @@ -1185,6 +1200,9 @@ def ASM : DiagGroup<"asm", [ ASMOperandWidths ]>; +// Linker warnings. +def LinkerWarnings : DiagGroup<"linker-warnings">; + // OpenMP warnings. def SourceUsesOpenMP : DiagGroup<"source-uses-openmp">; def OpenMPClauses : DiagGroup<"openmp-clauses">; @@ -1210,6 +1228,7 @@ def BackendOptimizationRemark : DiagGroup<"pass">; def BackendOptimizationRemarkMissed : DiagGroup<"pass-missed">; def BackendOptimizationRemarkAnalysis : DiagGroup<"pass-analysis">; def BackendOptimizationFailure : DiagGroup<"pass-failed">; +def BackendWarningAttributes : DiagGroup<"attribute-warning">; // Instrumentation based profiling warnings. def ProfileInstrMissing : DiagGroup<"profile-instr-missing">; @@ -1247,8 +1266,9 @@ def OptionIgnored : DiagGroup<"option-ignored">; def UnknownArgument : DiagGroup<"unknown-argument">; // A warning group for warnings about code that clang accepts when -// compiling OpenCL C/C++ but which is not compatible with the SPIR spec. +// compiling OpenCL C/C++ but which is not compatible with the SPIR(-V) spec. def SpirCompat : DiagGroup<"spir-compat">; +def : DiagGroup<"spirv-compat", [SpirCompat]>; // Alias. // Warning for the GlobalISel options. def GlobalISel : DiagGroup<"global-isel">; @@ -1303,3 +1323,11 @@ def WebAssemblyExceptionSpec : DiagGroup<"wasm-exception-spec">; def RTTI : DiagGroup<"rtti">; def OpenCLCoreFeaturesDiagGroup : DiagGroup<"pedantic-core-features">; + +// Warnings and extensions to make preprocessor macro usage pedantic. +def PedanticMacros : DiagGroup<"pedantic-macros", + [DeprecatedPragma, + MacroRedefined, + BuiltinMacroRedefined, + RestrictExpansionMacro, + FinalMacro]>; diff --git a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticIDs.h b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticIDs.h index 288504def5eb..aef86516707c 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticIDs.h +++ b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticIDs.h @@ -25,6 +25,8 @@ namespace clang { // Import the diagnostic enums themselves. namespace diag { + enum class Group; + // Size of each of the diagnostic categories. enum { DIAG_SIZE_COMMON = 300, @@ -224,6 +226,10 @@ public: /// static bool isBuiltinExtensionDiag(unsigned DiagID, bool &EnabledByDefault); + /// Given a group ID, returns the flag that toggles the group. + /// For example, for Group::DeprecatedDeclarations, returns + /// "deprecated-declarations". + static StringRef getWarningOptionForGroup(diag::Group); /// Return the lowest-level warning option that enables the specified /// diagnostic. diff --git a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticLexKinds.td b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticLexKinds.td index bdf5d263fa92..a4436208799f 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticLexKinds.td +++ b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticLexKinds.td @@ -113,8 +113,10 @@ def warn_four_char_character_literal : Warning< // Unicode and UCNs def err_invalid_utf8 : Error< "source file is not valid UTF-8">; -def err_non_ascii : Error< - "non-ASCII characters are not allowed outside of literals and identifiers">; +def err_character_not_allowed : Error< + "unexpected character <U+%0>">; +def err_character_not_allowed_identifier : Error< + "character <U+%0> not allowed %select{in|at the start of}1 an identifier">; def ext_unicode_whitespace : ExtWarn< "treating Unicode character as whitespace">, InGroup<DiagGroup<"unicode-whitespace">>; @@ -125,6 +127,15 @@ def warn_utf8_symbol_zero_width : Warning< "identifier contains Unicode character <U+%0> that is invisible in " "some environments">, InGroup<DiagGroup<"unicode-zero-width">>; +def ext_delimited_escape_sequence : Extension< + "delimited escape sequences are a Clang extension">, + InGroup<DiagGroup<"delimited-escape-sequence-extension">>; +def err_delimited_escape_empty : Error< + "delimited escape sequence cannot be empty">; +def err_delimited_escape_missing_brace: Error< + "expected '{' after '\\%0' escape sequence">; +def err_delimited_escape_invalid : Error< + "invalid digit '%0' in escape sequence">; def err_hex_escape_no_digits : Error< "\\%0 used with no following hex digits">; def warn_ucn_escape_no_digits : Warning< @@ -132,6 +143,12 @@ def warn_ucn_escape_no_digits : Warning< "treating as '\\' followed by identifier">, InGroup<Unicode>; def err_ucn_escape_incomplete : Error< "incomplete universal character name">; +def warn_delimited_ucn_incomplete : Warning< + "incomplete delimited universal character name; " + "treating as '\\' 'u' '{' identifier">, InGroup<Unicode>; +def warn_delimited_ucn_empty : Warning< + "empty delimited universal character name; " + "treating as '\\' 'u' '{' '}'">, InGroup<Unicode>; def warn_ucn_escape_incomplete : Warning< "incomplete universal character name; " "treating as '\\' followed by identifier">, InGroup<Unicode>; @@ -150,9 +167,6 @@ def warn_c99_compat_unicode_id : Warning< "%select{using this character in an identifier|starting an identifier with " "this character}0 is incompatible with C99">, InGroup<C99Compat>, DefaultIgnore; -def warn_cxx98_compat_unicode_id : Warning< - "using this character in an identifier is incompatible with C++98">, - InGroup<CXX98Compat>, DefaultIgnore; def warn_cxx98_compat_literal_ucn_escape_basic_scs : Warning< "specifying character '%0' with a universal character name " @@ -184,12 +198,10 @@ def warn_c2x_compat_digit_separator : Warning< InGroup<CPre2xCompat>, DefaultIgnore; def err_digit_separator_not_between_digits : Error< "digit separator cannot appear at %select{start|end}0 of digit sequence">; -def warn_extraneous_char_constant : Warning< - "extraneous characters in character constant ignored">; def warn_char_constant_too_large : Warning< "character constant too long for its type">; -def err_multichar_utf_character_literal : Error< - "Unicode character literals may not contain multiple characters">; +def err_multichar_character_literal : Error< + "%select{wide|Unicode}0 character literals may not contain multiple characters">; def err_exponent_has_no_digits : Error<"exponent has no digits">; def err_hex_constant_requires : Error< "hexadecimal floating %select{constant|literal}0 requires " @@ -257,7 +269,9 @@ def err_bad_character_encoding : Error< def warn_bad_character_encoding : ExtWarn< "illegal character encoding in character literal">, InGroup<InvalidSourceEncoding>; -def err_lexing_string : Error<"failure when lexing a string">; +def err_lexing_string : Error<"failure when lexing a string literal">; +def err_lexing_char : Error<"failure when lexing a character literal">; +def err_lexing_numeric : Error<"failure when lexing a numeric literal">; def err_placeholder_in_source : Error<"editor placeholder in source file">; //===----------------------------------------------------------------------===// @@ -400,6 +414,10 @@ def ext_embedded_directive : Extension< def ext_missing_varargs_arg : Extension< "must specify at least one argument for '...' parameter of variadic macro">, InGroup<GNUZeroVariadicMacroArguments>; +def warn_cxx17_compat_missing_varargs_arg : Warning< + "passing no argument for the '...' parameter of a variadic macro is " + "incompatible with C++ standards before C++20">, + InGroup<CXXPre20Compat>, DefaultIgnore; def ext_empty_fnmacro_arg : Extension< "empty macro arguments are a C99 feature">, InGroup<C99>; def warn_cxx98_compat_empty_fnmacro_arg : Warning< @@ -430,6 +448,9 @@ def warn_pp_hdrstop_filename_ignored : Warning< "#pragma hdrstop filename not supported, " "/Fp can be used to specify precompiled header filename">, InGroup<ClangClPch>; +def remark_pp_search_path_usage : Remark< + "search path used: '%0'">, + InGroup<UsedSearchPath>; def err_pp_file_not_found_angled_include_not_fatal : Error< "'%0' file not found with <angled> %select{include|import}1; " "use \"quotes\" instead">; @@ -526,6 +547,27 @@ def warn_pragma_warning_expected_number : ExtWarn<"#pragma warning expected a warning number">, InGroup<UnknownPragmas>; +// - #pragma deprecated(...) +def warn_pragma_deprecated_macro_use : + ExtWarn<"macro %0 has been marked as deprecated%select{|: %2}1">, + InGroup<DeprecatedPragma>; + +// - #pragma clang restrict_expansion(...) +def warn_pragma_restrict_expansion_macro_use : + ExtWarn<"macro %0 has been marked as unsafe for use in headers" + "%select{|: %2}1">, + InGroup<RestrictExpansionMacro>; + +// - Note for macro annotations. +def note_pp_macro_annotation : + Note<"macro marked '%select{deprecated|restrict_expansion|final}0' here">; + +// - #pragma clang final(...) +def warn_pragma_final_macro : + ExtWarn<"macro %0 has been marked as final and should not be " + "%select{undefined|redefined}1">, + InGroup<FinalMacro>, ShowInSystemHeader; + // - #pragma execution_character_set(...) def warn_pragma_exec_charset_expected : ExtWarn<"#pragma execution_character_set expected '%0'">, diff --git a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticParseKinds.td b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticParseKinds.td index 7e4b0841e06b..1bc2e8b0c7ef 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -549,6 +549,12 @@ def err_expected_init_in_condition_lparen : Error< "variable declaration in condition cannot have a parenthesized initializer">; def err_extraneous_rparen_in_condition : Error< "extraneous ')' after condition, expected a statement">; +def ext_alias_in_init_statement : ExtWarn< + "alias declaration in this context is a C++2b extension">, + InGroup<CXX2b>; +def warn_cxx20_alias_in_init_statement : Warning< + "alias declaration in this context is incompatible with C++ standards before C++2b">, + DefaultIgnore, InGroup<CXXPre2bCompat>; def warn_dangling_else : Warning< "add explicit braces to avoid dangling else">, InGroup<DanglingElse>; @@ -626,6 +632,13 @@ def ext_constexpr_if : ExtWarn< def warn_cxx14_compat_constexpr_if : Warning< "constexpr if is incompatible with C++ standards before C++17">, DefaultIgnore, InGroup<CXXPre17Compat>; +def ext_consteval_if : ExtWarn< + "consteval if is a C++2b extension">, + InGroup<CXX2b>; +def warn_cxx20_compat_consteval_if : Warning< + "consteval if is incompatible with C++ standards before C++2b">, + InGroup<CXXPre2bCompat>, DefaultIgnore; + def ext_init_statement : ExtWarn< "'%select{if|switch}0' initialization statements are a C++17 extension">, InGroup<CXX17>; @@ -742,8 +755,9 @@ def err_unknown_template_name : Error< "unknown template name %0">; def err_expected_comma_greater : Error< "expected ',' or '>' in template-parameter-list">; -def err_class_on_template_template_param : Error< - "template template parameter requires 'class' after the parameter list">; +def err_class_on_template_template_param + : Error<"template template parameter requires 'class'%select{| or " + "'typename'}0 after the parameter list">; def ext_template_template_param_typename : ExtWarn< "template template parameter using 'typename' is a C++17 extension">, InGroup<CXX17>; @@ -806,10 +820,10 @@ def err_requires_expr_expected_type_constraint : Error< def err_requires_expr_simple_requirement_noexcept : Error< "'noexcept' can only be used in a compound requirement (with '{' '}' around " "the expression)">; -def warn_requires_expr_in_simple_requirement : Warning< - "this requires expression will only be checked for syntactic validity; did " +def err_requires_expr_in_simple_requirement : Error< + "requires expression in requirement body; did " "you intend to place it in a nested requirement? (add another 'requires' " - "before the expression)">, InGroup<DiagGroup<"requires-expression">>; + "before the expression)">; def err_missing_dependent_template_keyword : Error< "use 'template' keyword to treat '%0' as a dependent template name">; @@ -944,6 +958,9 @@ def err_duplicate_class_virt_specifier : Error< def err_duplicate_virt_specifier : Error< "class member already marked '%0'">; +def err_virt_specifier_outside_class : Error< + "'%0' specifier is not allowed outside a class definition">; + def err_expected_parameter_pack : Error< "expected the name of a parameter pack">; def err_paren_sizeof_parameter_pack : Error< @@ -1102,6 +1119,9 @@ def warn_pragma_expected_integer : Warning< def warn_pragma_ms_struct : Warning< "incorrect use of '#pragma ms_struct on|off' - ignored">, InGroup<IgnoredPragmas>; +def warn_pragma_ms_fenv_access : Warning< + "incorrect use of '#pragma fenv_access (on|off)' - ignored">, + InGroup<IgnoredPragmas>; def warn_pragma_extra_tokens_at_eol : Warning< "extra tokens at end of '#pragma %0' - ignored">, InGroup<IgnoredPragmas>; @@ -1167,9 +1187,6 @@ def ext_stdc_pragma_ignored : ExtWarn<"unknown pragma in STDC namespace">, // The C standard 7.6.1p2 says "The [FENV_ACCESS] pragma shall occur either // outside external declarations or preceding all explicit declarations and // statements inside a compound statement. -def err_pragma_stdc_fenv_access_scope : Error< - "'#pragma STDC FENV_ACCESS' can only appear at file scope or at the start of" - " a compound statement">; def warn_stdc_fenv_round_not_supported : Warning<"pragma STDC FENV_ROUND is not supported">, InGroup<UnknownPragmas>; @@ -1303,8 +1320,8 @@ def err_omp_decl_in_declare_simd_variant : Error< def err_omp_unknown_map_type : Error< "incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'">; def err_omp_unknown_map_type_modifier : Error< - "incorrect map type modifier, expected 'always', 'close', " - "%select{or 'mapper'|'mapper', or 'present'}0">; + "incorrect map type modifier, expected one of: 'always', 'close', 'mapper'" + "%select{|, 'present'}0%select{|, 'ompx_hold'}1">; def err_omp_map_type_missing : Error< "missing map type">; def err_omp_map_type_modifier_missing : Error< @@ -1342,8 +1359,11 @@ def err_omp_mapper_illegal_identifier : Error< "illegal OpenMP user-defined mapper identifier">; def err_omp_mapper_expected_declarator : Error< "expected declarator on 'omp declare mapper' directive">; +def err_omp_unexpected_append_op : Error< + "unexpected operation specified in 'append_args' clause, expected 'interop'">; def err_omp_declare_variant_wrong_clause : Error< - "expected '%0' clause on 'omp declare variant' directive">; + "expected %select{'match'|'match', 'adjust_args', or 'append_args'}0 clause " + "on 'omp declare variant' directive">; def err_omp_declare_variant_duplicate_nested_trait : Error< "nested OpenMP context selector contains duplicated trait '%0'" " in selector '%1' and set '%2' with different score">; @@ -1436,6 +1456,9 @@ def warn_omp51_compat_attributes : Warning< "specifying OpenMP directives with [[]] is incompatible with OpenMP " "standards before OpenMP 5.1">, InGroup<OpenMPPre51Compat>, DefaultIgnore; +def err_omp_expected_colon : Error<"missing ':' in %0">; +def err_omp_expected_context_selector + : Error<"expected valid context selector in %0">; // Pragma loop support. def err_pragma_loop_missing_argument : Error< @@ -1472,7 +1495,7 @@ def warn_pragma_unroll_cuda_value_in_parens : Warning< InGroup<CudaCompat>; def warn_cuda_attr_lambda_position : Warning< - "nvcc does not allow '__%0__' to appear after '()' in lambdas">, + "nvcc does not allow '__%0__' to appear after the parameter list in lambdas">, InGroup<CudaCompat>; def warn_pragma_force_cuda_host_device_bad_arg : Warning< "incorrect use of #pragma clang force_cuda_host_device begin|end">, diff --git a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticSemaKinds.td b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticSemaKinds.td index c57b8eca7deb..dc67f86f25ca 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -66,6 +66,7 @@ def warn_infinite_recursive_function : Warning< def warn_comma_operator : Warning<"possible misuse of comma operator here">, InGroup<DiagGroup<"comma">>, DefaultIgnore; def note_cast_to_void : Note<"cast expression to void to silence warning">; +def note_cast_operand_to_int : Note<"cast one or both operands to int to silence this warning">; // Constant expressions def err_expr_not_ice : Error< @@ -82,11 +83,11 @@ def err_typecheck_converted_constant_expression_indirect : Error< "bind reference to a temporary">; def err_expr_not_cce : Error< "%select{case value|enumerator value|non-type template argument|" - "array size|explicit specifier argument}0 " + "array size|explicit specifier argument|noexcept specifier argument}0 " "is not a constant expression">; def ext_cce_narrowing : ExtWarn< "%select{case value|enumerator value|non-type template argument|" - "array size|explicit specifier argument}0 " + "array size|explicit specifier argument|noexcept specifier argument}0 " "%select{cannot be narrowed from type %2 to %3|" "evaluates to %2, which cannot be narrowed to type %3}1">, InGroup<CXX11Narrowing>, DefaultError, SFINAEFailure; @@ -267,10 +268,12 @@ def err_invalid_vector_double_decl_spec : Error < def err_invalid_vector_bool_int128_decl_spec : Error < "use of '__int128' with '__vector bool' requires VSX support enabled (on " "POWER10 or later)">; +def err_invalid_vector_int128_decl_spec : Error< + "use of '__int128' with '__vector' requires extended Altivec support" + " (available on POWER8 or later)">; def err_invalid_vector_long_long_decl_spec : Error < - "use of 'long long' with '__vector bool' requires VSX support (available on " - "POWER7 or later) or extended Altivec support (available on POWER8 or later) " - "to be enabled">; + "use of 'long long' with '__vector' requires VSX support (available on " + "POWER7 or later) to be enabled">; def err_invalid_vector_long_double_decl_spec : Error< "cannot use 'long double' with '__vector'">; def warn_vector_long_decl_spec_combination : Warning< @@ -388,6 +391,7 @@ def warn_reserved_extern_symbol: Warning< "identifier %0 is reserved because %select{" "<ERROR>|" // ReservedIdentifierStatus::NotReserved "it starts with '_' at global scope|" + "it starts with '_' and has C language linkage|" "it starts with '__'|" "it starts with '_' followed by a capital letter|" "it contains '__'}1">, @@ -682,6 +686,9 @@ def warn_unreachable_return : Warning< def warn_unreachable_loop_increment : Warning< "loop will run at most once (loop increment never executed)">, InGroup<UnreachableCodeLoopIncrement>, DefaultIgnore; +def warn_unreachable_fallthrough_attr : Warning< + "fallthrough annotation in unreachable code">, + InGroup<UnreachableCodeFallthrough>, DefaultIgnore; def note_unreachable_silence : Note< "silence by adding parentheses to mark code as explicitly dead">; @@ -816,11 +823,20 @@ def warn_fortify_source_size_mismatch : Warning< "'%0' size argument is too large; destination buffer has size %1," " but size argument is %2">, InGroup<FortifySource>; +def warn_fortify_strlen_overflow: Warning< + "'%0' will always overflow; destination buffer has size %1," + " but the source string has length %2 (including NUL byte)">, + InGroup<FortifySource>; + def warn_fortify_source_format_overflow : Warning< "'%0' will always overflow; destination buffer has size %1," " but format string expands to at least %2">, InGroup<FortifySource>; +def warn_fortify_scanf_overflow : Warning< + "'%0' may overflow; destination buffer in argument %1 has size " + "%2, but the corresponding specifier may require size %3">, + InGroup<FortifySource>; /// main() // static main() is not an error in C, just in C++. @@ -908,6 +924,9 @@ def warn_pragma_options_align_reset_failed : Warning< InGroup<IgnoredPragmas>; def err_pragma_options_align_mac68k_target_unsupported : Error< "mac68k alignment pragma is not supported on this target">; +def warn_pragma_align_not_xl_compatible : Warning< + "#pragma align(packed) may not be compatible with objects generated with AIX XL C/C++">, + InGroup<AIXCompat>; def warn_pragma_pack_invalid_alignment : Warning< "expected #pragma pack parameter to be '1', '2', '4', '8', or '16'">, InGroup<IgnoredPragmas>; @@ -933,7 +952,8 @@ def warn_pragma_pack_pop_identifier_and_alignment : Warning< def warn_pragma_pop_failed : Warning<"#pragma %0(pop, ...) failed: %1">, InGroup<IgnoredPragmas>; def err_pragma_fc_pp_scope : Error< - "'#pragma float_control push/pop' can only appear at file scope or namespace scope">; + "'#pragma float_control push/pop' can only appear at file or namespace scope " + "or within a language linkage specification">; def err_pragma_fc_noprecise_requires_nofenv : Error< "'#pragma float_control(precise, off)' is illegal when fenv_access is enabled">; def err_pragma_fc_except_requires_precise : Error< @@ -1493,6 +1513,10 @@ def err_static_assert_failed : Error<"static_assert failed%select{ %1|}0">; def err_static_assert_requirement_failed : Error< "static_assert failed due to requirement '%0'%select{ %2|}1">; +def warn_consteval_if_always_true : Warning< + "consteval if is always true in an %select{unevaluated|immediate}0 context">, + InGroup<DiagGroup<"redundant-consteval-if">>; + def ext_inline_variable : ExtWarn< "inline variables are a C++17 extension">, InGroup<CXX17>; def warn_cxx14_compat_inline_variable : Warning< @@ -1624,8 +1648,7 @@ def warn_weak_vtable : Warning< "emitted in every translation unit">, InGroup<DiagGroup<"weak-vtables">>, DefaultIgnore; def warn_weak_template_vtable : Warning< - "explicit template instantiation %0 will emit a vtable in every " - "translation unit">, + "this warning is no longer in use and will be removed in the next release">, InGroup<DiagGroup<"weak-template-vtables">>, DefaultIgnore; def ext_using_undefined_std : ExtWarn< @@ -2953,7 +2976,7 @@ def err_attribute_requires_positive_integer : Error< "%0 attribute requires a %select{positive|non-negative}1 " "integral compile time constant expression">; def err_attribute_requires_opencl_version : Error< - "%0 attribute requires OpenCL version %1%select{| or above}2">; + "attribute %0 is supported in the OpenCL version %1%select{| onwards}2">; def err_invalid_branch_protection_spec : Error< "invalid or misplaced branch protection specification '%0'">; def warn_unsupported_target_attribute @@ -2980,6 +3003,8 @@ def err_alignas_mismatch : Error< "redeclaration has different alignment requirement (%1 vs %0)">; def err_alignas_underaligned : Error< "requested alignment is less than minimum alignment of %1 for type %0">; +def warn_aligned_attr_underaligned : Warning<err_alignas_underaligned.Text>, + InGroup<IgnoredAttributes>; def err_attribute_sizeless_type : Error< "%0 attribute cannot be applied to sizeless type %1">; def err_attribute_argument_n_type : Error< @@ -3256,7 +3281,8 @@ def warn_assume_aligned_too_great InGroup<DiagGroup<"builtin-assume-aligned-alignment">>; def warn_not_xl_compatible : Warning<"requesting an alignment of 16 bytes or greater for struct" - " members is not binary compatible with AIX XL 16.1 and older">, + " members is not binary compatible with IBM XL C/C++ for AIX" + " 16.1.0 and older">, InGroup<AIXCompat>; def warn_redeclaration_without_attribute_prev_attribute_ignored : Warning< "%q0 redeclared without %1 attribute: previous %1 ignored">, @@ -3298,11 +3324,11 @@ def warn_attribute_has_no_effect_on_infinite_loop : Warning< InGroup<IgnoredAttributes>; def note_attribute_has_no_effect_on_infinite_loop_here : Note< "annotating the infinite loop here">; -def warn_attribute_has_no_effect_on_if_constexpr : Warning< - "attribute %0 has no effect when annotating an 'if constexpr' statement">, +def warn_attribute_has_no_effect_on_compile_time_if : Warning< + "attribute %0 has no effect when annotating an 'if %select{constexpr|consteval}1' statement">, InGroup<IgnoredAttributes>; -def note_attribute_has_no_effect_on_if_constexpr_here : Note< - "annotating the 'if constexpr' statement here">; +def note_attribute_has_no_effect_on_compile_time_if_here : Note< + "annotating the 'if %select{constexpr|consteval}0' statement here">; def err_decl_attribute_invalid_on_stmt : Error< "%0 attribute cannot be applied to a statement">; def err_stmt_attribute_invalid_on_decl : Error< @@ -3382,7 +3408,7 @@ def warn_attribute_dllimport_static_field_definition : Warning< InGroup<DiagGroup<"dllimport-static-field-def">>; def warn_attribute_dllexport_explicit_instantiation_decl : Warning< "explicit instantiation declaration should not be 'dllexport'">, - InGroup<DiagGroup<"dllexport-explicit-instantiation-decl">>; + InGroup<DllexportExplicitInstantiationDecl>; def warn_attribute_dllexport_explicit_instantiation_def : Warning< "'dllexport' attribute ignored on explicit instantiation definition">, InGroup<IgnoredAttributes>; @@ -3532,6 +3558,9 @@ def warn_availability_swift_unavailable_deprecated_only : Warning< InGroup<Availability>; def note_protocol_method : Note< "protocol method is here">; +def warn_availability_fuchsia_unavailable_minor : Warning< + "Fuchsia API Level prohibits specifying a minor or sub-minor version">, + InGroup<Availability>; def warn_unguarded_availability : Warning<"%0 is only available on %1 %2 or newer">, @@ -4472,7 +4501,8 @@ def note_ovl_candidate_bad_conv_incomplete : Note< "; remove &}7">; def note_ovl_candidate_bad_list_argument : Note< "candidate %sub{select_ovl_candidate_kind}0,1,2 not viable: " - "cannot convert initializer list argument to %4">; + "%select{cannot convert initializer list|too few initializers in list" + "|too many initializers in list}7 argument to %4">; def note_ovl_candidate_bad_overload : Note< "candidate %sub{select_ovl_candidate_kind}0,1,2 not viable: " "no overload of %4 matching %3 for %ordinal5 argument">; @@ -5563,8 +5593,8 @@ def warn_undefined_inline : Warning<"inline function %q0 is not defined">, def err_undefined_inline_var : Error<"inline variable %q0 is not defined">; def note_used_here : Note<"used here">; -def err_internal_linkage_redeclaration : Error< - "'internal_linkage' attribute does not appear on the first declaration of %0">; +def err_attribute_missing_on_first_decl : Error< + "%0 attribute does not appear on the first declaration">; def warn_internal_linkage_local_storage : Warning< "'internal_linkage' attribute on a non-static local variable is ignored">, InGroup<IgnoredAttributes>; @@ -5727,7 +5757,7 @@ def warn_typecheck_function_qualifiers_unspecified : Warning< "'%0' qualifier on function type %1 has unspecified behavior">; def warn_typecheck_reference_qualifiers : Warning< "'%0' qualifier on reference type %1 has no effect">, - InGroup<IgnoredQualifiers>; + InGroup<IgnoredReferenceQualifiers>; def err_typecheck_invalid_restrict_not_pointer : Error< "restrict requires a pointer or reference (%0 is invalid)">; def err_typecheck_invalid_restrict_not_pointer_noarg : Error< @@ -5926,6 +5956,8 @@ def note_protected_by_vla_type_alias : Note< "jump bypasses initialization of VLA type alias">; def note_protected_by_constexpr_if : Note< "jump enters controlled statement of constexpr if">; +def note_protected_by_consteval_if : Note< + "jump enters controlled statement of consteval if">; def note_protected_by_if_available : Note< "jump enters controlled statement of if available">; def note_protected_by_vla : Note< @@ -6397,11 +6429,6 @@ def warn_gnu_null_ptr_arith : Warning< def warn_pointer_sub_null_ptr : Warning< "performing pointer subtraction with a null pointer %select{has|may have}0 undefined behavior">, InGroup<NullPointerSubtraction>, DefaultIgnore; -def err_kernel_invalidates_sycl_unique_stable_name - : Error<"kernel instantiation changes the result of an evaluated " - "'__builtin_sycl_unique_stable_name'">; -def note_sycl_unique_stable_name_evaluated_here - : Note<"'__builtin_sycl_unique_stable_name' evaluated here">; def warn_floatingpoint_eq : Warning< "comparing floating point with == or != is unsafe">, @@ -6770,7 +6797,7 @@ def warn_taking_address_of_packed_member : Warning< "taking address of packed member %0 of class or structure %q1 may result in an unaligned pointer value">, InGroup<DiagGroup<"address-of-packed-member">>; def warn_param_mismatched_alignment : Warning< - "passing %0-byte aligned argument to %1-byte aligned parameter %2 of %3 may result in an unaligned pointer access">, + "passing %0-byte aligned argument to %1-byte aligned parameter %2%select{| of %4}3 may result in an unaligned pointer access">, InGroup<DiagGroup<"align-mismatch">>; def err_objc_object_assignment : Error< @@ -7413,10 +7440,13 @@ def note_member_declared_here : Note< "member %0 declared here">; def note_member_first_declared_here : Note< "member %0 first declared here">; +def warn_bitwise_instead_of_logical : Warning< + "use of bitwise '%0' with boolean operands">, + InGroup<BitwiseInsteadOfLogical>, DefaultIgnore; def warn_bitwise_negation_bool : Warning< "bitwise negation of a boolean expression%select{;| always evaluates to 'true';}0 " "did you mean logical negation?">, - InGroup<DiagGroup<"bool-operation">>; + InGroup<BoolOperation>, DefaultIgnore; def err_decrement_bool : Error<"cannot decrement expression of type bool">; def warn_increment_bool : Warning< "incrementing expression of type bool is deprecated and " @@ -7490,7 +7520,8 @@ def note_throw_in_function : Note<"function declared non-throwing here">; def err_seh_try_outside_functions : Error< "cannot use SEH '__try' in blocks, captured regions, or Obj-C method decls">; def err_mixing_cxx_try_seh_try : Error< - "cannot use C++ 'try' in the same function as SEH '__try'">; + "cannot use %select{C++ 'try'|Objective-C '@try'}0 " + "in the same function as SEH '__try'">; def err_seh_try_unsupported : Error< "SEH '__try' is not supported on this target">; def note_conflicting_try_here : Note< @@ -8380,8 +8411,10 @@ def err_ref_bad_target_global_initializer : Error< "function %1 in global initializer">; def err_capture_bad_target : Error< "capture host variable %0 by reference in device or host device lambda function">; -def err_capture_bad_target_this_ptr : Error< - "capture host side class data member by this pointer in device or host device lambda function">; +def warn_maybe_capture_bad_target_this_ptr : Warning< + "capture host side class data member by this pointer in device or host device lambda function " + "may result in invalid memory access if this pointer is not accessible on device side">, + InGroup<DiagGroup<"gpu-maybe-wrong-side">>; def warn_kern_is_method : Extension< "kernel function %0 is a member function; this may not be accepted by nvcc">, InGroup<CudaCompat>; @@ -8551,6 +8584,9 @@ def err_typecheck_choose_expr_requires_constant : Error< "'__builtin_choose_expr' requires a constant expression">; def warn_unused_expr : Warning<"expression result unused">, InGroup<UnusedValue>; +def warn_unused_comma_left_operand : Warning< + "left operand of comma operator has no effect">, + InGroup<UnusedValue>; def warn_unused_voidptr : Warning< "expression result unused; should this cast be to 'void'?">, InGroup<UnusedValue>; @@ -9142,14 +9178,18 @@ def note_defaulted_comparison_calls_deleted : Note< "defaulted %0 is implicitly deleted because it would invoke a deleted " "comparison function%select{| for member %2| for base class %2}1">; def note_defaulted_comparison_no_viable_function : Note< - "defaulted %0 is implicitly deleted because there is no viable three-way " - "comparison function for%select{| member| base class}1 %2">; + "defaulted %0 is implicitly deleted because there is no viable " + "%select{three-way comparison function|'operator=='}1 for " + "%select{|member |base class }2%3">; def note_defaulted_comparison_no_viable_function_synthesized : Note< "three-way comparison cannot be synthesized because there is no viable " "function for %select{'=='|'<'}0 comparison">; def note_defaulted_comparison_not_rewritten_callee : Note< "defaulted %0 is implicitly deleted because this non-rewritten comparison " "function would be the best match for the comparison">; +def note_defaulted_comparison_not_rewritten_conversion : Note< + "defaulted %0 is implicitly deleted because a builtin comparison function " + "using this conversion would be the best match for the comparison">; def note_defaulted_comparison_cannot_deduce : Note< "return type of defaulted 'operator<=>' cannot be deduced because " "return type %2 of three-way comparison for %select{|member|base class}0 %1 " @@ -9570,9 +9610,6 @@ def err_fallthrough_attr_outside_switch : Error< "fallthrough annotation is outside switch statement">; def err_fallthrough_attr_invalid_placement : Error< "fallthrough annotation does not directly precede switch label">; -def warn_fallthrough_attr_unreachable : Warning< - "fallthrough annotation in unreachable code">, - InGroup<ImplicitFallthrough>, DefaultIgnore; def warn_unreachable_default : Warning< "default label in switch which covers all enumeration values">, @@ -9668,10 +9705,6 @@ def warn_falloff_noreturn_function : Warning< InGroup<InvalidNoreturn>; def err_noreturn_block_has_return_expr : Error< "block declared 'noreturn' should not return">; -def err_noreturn_missing_on_first_decl : Error< - "function declared '[[noreturn]]' after its first declaration">; -def note_noreturn_missing_first_decl : Note< - "declaration missing '[[noreturn]]' attribute is here">; def err_carries_dependency_missing_on_first_decl : Error< "%select{function|parameter}0 declared '[[carries_dependency]]' " "after its first declaration">; @@ -9729,6 +9762,9 @@ def err_argument_invalid_range : Error< def warn_argument_invalid_range : Warning< "argument value %0 is outside the valid range [%1, %2]">, DefaultError, InGroup<DiagGroup<"argument-outside-range">>; +def warn_argument_undefined_behaviour : Warning< + "argument value %0 will result in undefined behaviour">, + InGroup<DiagGroup<"argument-undefined-behaviour">>; def err_argument_not_multiple : Error< "argument should be a multiple of %0">; def err_argument_not_power_of_2 : Error< @@ -9769,8 +9805,14 @@ def err_mips_builtin_requires_msa : Error< "this builtin requires 'msa' ASE, please use -mmsa">; 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_abi : Error< + "this builtin requires ABI -mabi=%0">; def err_ppc_invalid_use_mma_type : Error< "invalid use of PPC MMA type">; +def err_ppc_invalid_test_data_class_type : Error< + "expected a 'float' or 'double' for the first argument">; def err_x86_builtin_invalid_rounding : Error< "invalid rounding argument">; def err_x86_builtin_invalid_scale : Error< @@ -10091,8 +10133,7 @@ def err_opencl_type_can_only_be_used_as_function_parameter : Error < def err_opencl_type_not_found : Error< "%0 type %1 not found; include the base header with -finclude-default-header">; def warn_opencl_attr_deprecated_ignored : Warning < - "%0 attribute is deprecated and ignored in OpenCL version %1">, - InGroup<IgnoredAttributes>; + "%0 attribute is deprecated and ignored in %1">, InGroup<IgnoredAttributes>; def err_opencl_variadic_function : Error< "invalid prototype, variadic arguments are not allowed in OpenCL">; def err_opencl_requires_extension : Error< @@ -10157,7 +10198,7 @@ def err_opencl_builtin_expected_type : Error< // OpenCL v3.0 s6.3.7 - Vector Components def ext_opencl_ext_vector_type_rgba_selector: ExtWarn< - "vector component name '%0' is an OpenCL C version 3.0 feature">, + "vector component name '%0' is a feature from OpenCL version 3.0 onwards">, InGroup<OpenCLUnsupportedRGBA>; def err_openclcxx_placement_new : Error< @@ -10528,6 +10569,8 @@ def err_omp_map_shared_storage : Error< "variable already marked as mapped in current construct">; def err_omp_invalid_map_type_for_directive : Error< "%select{map type '%1' is not allowed|map type must be specified}0 for '#pragma omp %2'">; +def err_omp_invalid_map_type_modifier_for_directive : Error< + "map type modifier '%0' is not allowed for '#pragma omp %1'">; def err_omp_no_clause_for_directive : Error< "expected at least one %0 clause for '#pragma omp %1'">; def err_omp_threadprivate_in_clause : Error< @@ -10556,6 +10599,8 @@ def err_omp_depend_sink_unexpected_expr : Error< "unexpected expression: number of expressions is larger than the number of associated loops">; def err_omp_depend_sink_expected_plus_minus : Error< "expected '+' or '-' operation">; +def err_omp_taskwait_depend_mutexinoutset_not_allowed : Error< + "'mutexinoutset' modifier not allowed in 'depend' clause on 'taskwait' directive">; def err_omp_depend_sink_source_not_allowed : Error< "'depend(%select{source|sink:vec}0)' clause%select{|s}0 cannot be mixed with 'depend(%select{sink:vec|source}0)' clause%select{s|}0">; def err_omp_depend_zero_length_array_section_not_allowed : Error< @@ -10677,9 +10722,9 @@ def err_omp_invariant_or_linear_dependency : Error< "expected loop invariant expression or '<invariant1> * %0 + <invariant2>' kind of expression">; def err_omp_wrong_dependency_iterator_type : Error< "expected an integer or a pointer type of the outer loop counter '%0' for non-rectangular nests">; -def err_device_unsupported_type - : Error<"%0 requires %select{|%2 bit size}1 %3 type support, but device " - "'%4' does not support it">; +def err_target_unsupported_type + : Error<"%0 requires %select{|%2 bit size}1 %3 %select{|return }4type support," + " but target '%5' does not support it">; def err_omp_lambda_capture_in_declare_target_not_to : Error< "variable captured in declare target region must appear in a to clause">; def err_omp_device_type_mismatch : Error< @@ -10714,9 +10759,14 @@ def err_omp_declare_variant_diff : Error< "function with '#pragma omp declare variant' has a different %select{calling convention" "|return type|constexpr specification|inline specification|storage class|" "linkage}0">; +def err_omp_declare_variant_prototype_required : Error< + "function with '#pragma omp declare variant' must have a prototype when " + "'append_args' is used">; +def err_omp_interop_type_not_found : Error< + "'omp_interop_t' must be defined when 'append_args' clause is used; include <omp.h>">; def err_omp_declare_variant_incompat_types : Error< - "variant in '#pragma omp declare variant' with type %0 is incompatible with type %1" - >; + "variant in '#pragma omp declare variant' with type %0 is incompatible with" + " type %1%select{| with appended arguments}2">; def warn_omp_declare_variant_marked_as_declare_variant : Warning< "variant function in '#pragma omp declare variant' is itself marked as '#pragma omp declare variant'" >, InGroup<SourceUsesOpenMP>; @@ -10762,6 +10812,9 @@ def note_omp_protected_structured_block : Note<"jump bypasses OpenMP structured block">; def note_omp_exits_structured_block : Note<"jump exits scope of OpenMP structured block">; +def err_omp_lastprivate_loop_var_non_loop_iteration : Error< + "only loop iteration variables are allowed in 'lastprivate' clause in " + "'omp loop' directives">; def err_omp_interop_variable_expected : Error< "expected%select{| non-const}0 variable of type 'omp_interop_t'">; def err_omp_interop_variable_wrong_type : Error< @@ -10779,6 +10832,14 @@ def err_omp_dispatch_statement_call def err_omp_unroll_full_variable_trip_count : Error< "loop to be fully unrolled must have a constant trip count">; def note_omp_directive_here : Note<"'%0' directive found here">; +def err_omp_instantiation_not_supported + : Error<"instantiation of '%0' not supported yet">; +def err_omp_adjust_arg_multiple_clauses : Error< + "'adjust_arg' argument %0 used in multiple clauses">; +def err_omp_clause_requires_dispatch_construct : Error< + "'%0' clause requires 'dispatch' context selector">; +def err_omp_append_args_with_varargs : Error< + "'append_args' is not allowed with varargs functions">; } // end of OpenMP category let CategoryName = "Related Result Type Issue" in { @@ -10949,19 +11010,29 @@ def err_coroutine_invalid_func_context : Error< "|a function with a deduced return type|a varargs function" "|a consteval function}0">; def err_implied_coroutine_type_not_found : Error< - "%0 type was not found; include <experimental/coroutine> before defining " - "a coroutine">; + "%0 type was not found; include <coroutine> before defining " + "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.">, + 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_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()">; def err_malformed_std_nothrow : Error< "std::nothrow must be a valid variable declaration">; def err_malformed_std_coroutine_handle : Error< - "std::experimental::coroutine_handle must be a class template">; + "std::coroutine_handle isn't a class template">; def err_coroutine_handle_missing_member : Error< - "std::experimental::coroutine_handle missing a member named '%0'">; + "std::coroutine_handle must have a member named '%0'">; def err_malformed_std_coroutine_traits : Error< - "'std::experimental::coroutine_traits' must be a class template">; + "std::coroutine_traits isn't a class template">; def err_implied_std_coroutine_traits_promise_type_not_found : Error< "this function cannot be a coroutine: %q0 has no member named 'promise_type'">; def err_implied_std_coroutine_traits_promise_type_not_class : Error< @@ -11191,8 +11262,8 @@ def err_multiversion_mismatched_attrs "%0 %select{is missing|has different arguments}1">; def err_multiversion_diff : Error< "multiversioned function declaration has a different %select{calling convention" - "|return type|constexpr specification|inline specification|storage class|" - "linkage}0">; + "|return type|constexpr specification|inline specification|linkage|" + "language linkage}0">; def err_multiversion_doesnt_support : Error< "attribute '%select{target|cpu_specific|cpu_dispatch}0' multiversioned functions do not " "yet support %select{function templates|virtual functions|" @@ -11257,6 +11328,12 @@ def err_builtin_launder_invalid_arg : Error< "%select{non-pointer|function pointer|void pointer}0 argument to " "'__builtin_launder' is not allowed">; +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)">; + def err_builtin_matrix_disabled: Error< "matrix types extension is disabled. Pass -fenable-matrix to enable it">; def err_matrix_index_not_integer: Error< @@ -11269,11 +11346,8 @@ def err_matrix_separate_incomplete_index: Error< "matrix row and column subscripts cannot be separated by any expression">; def err_matrix_subscript_comma: Error< "comma expressions are not allowed as indices in matrix subscript expressions">; -def err_builtin_matrix_arg: Error<"1st argument must be a matrix">; def err_builtin_matrix_scalar_unsigned_arg: Error< "%0 argument must be a constant unsigned integer expression">; -def err_builtin_matrix_pointer_arg: Error< - "%ordinal0 argument must be a pointer to a valid matrix element type">; def err_builtin_matrix_pointer_arg_mismatch: Error< "the pointee of the 2nd argument must match the element type of the 1st argument (%0 != %1)">; def err_builtin_matrix_store_to_const: Error< diff --git a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticSerializationKinds.td b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticSerializationKinds.td index bf3221be004d..f15a935d2af1 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticSerializationKinds.td +++ b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticSerializationKinds.td @@ -20,7 +20,7 @@ def err_fe_pch_malformed_block : Error< def err_fe_ast_file_modified : Error< "file '%0' has been modified since the " "%select{precompiled header|module file|AST file}1 '%2' was built" - ": %select{size|mtime|content}3 changed">, + ": %select{size|mtime|content}3 changed%select{| (was %5, now %6)}4">, DefaultFatal; def err_fe_pch_file_overridden : Error< "file '%0' from the precompiled header has been overridden">; diff --git a/contrib/llvm-project/clang/include/clang/Basic/IdentifierTable.h b/contrib/llvm-project/clang/include/clang/Basic/IdentifierTable.h index f2379c7ddfbd..19c967efcc42 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/IdentifierTable.h +++ b/contrib/llvm-project/clang/include/clang/Basic/IdentifierTable.h @@ -43,11 +43,28 @@ class SourceLocation; enum class ReservedIdentifierStatus { NotReserved = 0, StartsWithUnderscoreAtGlobalScope, + StartsWithUnderscoreAndIsExternC, StartsWithDoubleUnderscore, StartsWithUnderscoreFollowedByCapitalLetter, ContainsDoubleUnderscore, }; +/// Determine whether an identifier is reserved for use as a name at global +/// scope. Such identifiers might be implementation-specific global functions +/// or variables. +inline bool isReservedAtGlobalScope(ReservedIdentifierStatus Status) { + return Status != ReservedIdentifierStatus::NotReserved; +} + +/// Determine whether an identifier is reserved in all contexts. Such +/// identifiers might be implementation-specific keywords or macros, for +/// example. +inline bool isReservedInAllContexts(ReservedIdentifierStatus Status) { + return Status != ReservedIdentifierStatus::NotReserved && + Status != ReservedIdentifierStatus::StartsWithUnderscoreAtGlobalScope && + Status != ReservedIdentifierStatus::StartsWithUnderscoreAndIsExternC; +} + /// A simple pair of identifier info and location. using IdentifierLocPair = std::pair<IdentifierInfo *, SourceLocation>; @@ -121,7 +138,16 @@ class alignas(IdentifierInfoAlignment) IdentifierInfo { // True if this is a mangled OpenMP variant name. unsigned IsMangledOpenMPVariantName : 1; - // 28 bits left in a 64-bit word. + // True if this is a deprecated macro. + unsigned IsDeprecatedMacro : 1; + + // True if this macro is unsafe in headers. + unsigned IsRestrictExpansion : 1; + + // True if this macro is final. + unsigned IsFinal : 1; + + // 22 bits left in a 64-bit word. // Managed by the language front-end. void *FETokenInfo = nullptr; @@ -134,7 +160,8 @@ class alignas(IdentifierInfoAlignment) IdentifierInfo { IsPoisoned(false), IsCPPOperatorKeyword(false), NeedsHandleIdentifier(false), IsFromAST(false), ChangedAfterLoad(false), FEChangedAfterLoad(false), RevertedTokenID(false), OutOfDate(false), - IsModulesImport(false), IsMangledOpenMPVariantName(false) {} + IsModulesImport(false), IsMangledOpenMPVariantName(false), + IsDeprecatedMacro(false), IsRestrictExpansion(false), IsFinal(false) {} public: IdentifierInfo(const IdentifierInfo &) = delete; @@ -182,6 +209,14 @@ public: NeedsHandleIdentifier = true; HadMacro = true; } else { + // If this is a final macro, make the deprecation and header unsafe bits + // stick around after the undefinition so they apply to any redefinitions. + if (!IsFinal) { + // Because calling the setters of these calls recomputes, just set them + // manually to avoid recomputing a bunch of times. + IsDeprecatedMacro = false; + IsRestrictExpansion = false; + } RecomputeNeedsHandleIdentifier(); } } @@ -192,6 +227,34 @@ public: return HadMacro; } + bool isDeprecatedMacro() const { return IsDeprecatedMacro; } + + void setIsDeprecatedMacro(bool Val) { + if (IsDeprecatedMacro == Val) + return; + IsDeprecatedMacro = Val; + if (Val) + NeedsHandleIdentifier = true; + else + RecomputeNeedsHandleIdentifier(); + } + + bool isRestrictExpansion() const { return IsRestrictExpansion; } + + void setIsRestrictExpansion(bool Val) { + if (IsRestrictExpansion == Val) + return; + IsRestrictExpansion = Val; + if (Val) + NeedsHandleIdentifier = true; + else + RecomputeNeedsHandleIdentifier(); + } + + bool isFinal() const { return IsFinal; } + + void setIsFinal(bool Val) { IsFinal = Val; } + /// If this is a source-language token (e.g. 'for'), this API /// can be used to cause the lexer to map identifiers to source-language /// tokens. diff --git a/contrib/llvm-project/clang/include/clang/Basic/JsonSupport.h b/contrib/llvm-project/clang/include/clang/Basic/JsonSupport.h index 8b02e440df44..2ccb08e4bdaa 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/JsonSupport.h +++ b/contrib/llvm-project/clang/include/clang/Basic/JsonSupport.h @@ -12,6 +12,7 @@ #include "clang/Basic/LLVM.h" #include "clang/Basic/SourceManager.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" #include <iterator> @@ -70,7 +71,7 @@ inline std::string JsonFormat(StringRef RawSR, bool AddQuotes) { } // Remove new-lines. - Str.erase(std::remove(Str.begin(), Str.end(), '\n'), Str.end()); + llvm::erase_value(Str, '\n'); if (!AddQuotes) return Str; @@ -98,18 +99,19 @@ inline void printSourceLocationAsJson(raw_ostream &Out, SourceLocation Loc, if (AddBraces) Out << "{ "; std::string filename(PLoc.getFilename()); -#ifdef _WIN32 - // Remove forbidden Windows path characters - auto RemoveIt = - std::remove_if(filename.begin(), filename.end(), [](auto Char) { - static const char ForbiddenChars[] = "<>*?\"|"; - return std::find(std::begin(ForbiddenChars), std::end(ForbiddenChars), - Char) != std::end(ForbiddenChars); - }); - filename.erase(RemoveIt, filename.end()); - // Handle windows-specific path delimiters. - std::replace(filename.begin(), filename.end(), '\\', '/'); -#endif + if (is_style_windows(llvm::sys::path::Style::native)) { + // Remove forbidden Windows path characters + auto RemoveIt = + std::remove_if(filename.begin(), filename.end(), [](auto Char) { + static const char ForbiddenChars[] = "<>*?\"|"; + return std::find(std::begin(ForbiddenChars), + std::end(ForbiddenChars), + Char) != std::end(ForbiddenChars); + }); + filename.erase(RemoveIt, filename.end()); + // Handle windows-specific path delimiters. + std::replace(filename.begin(), filename.end(), '\\', '/'); + } Out << "\"line\": " << PLoc.getLine() << ", \"column\": " << PLoc.getColumn() << ", \"file\": \"" << filename << "\""; diff --git a/contrib/llvm-project/clang/include/clang/Basic/LangOptions.def b/contrib/llvm-project/clang/include/clang/Basic/LangOptions.def index 74deba6ef7fb..4651f4fff6aa 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/LangOptions.def +++ b/contrib/llvm-project/clang/include/clang/Basic/LangOptions.def @@ -231,6 +231,7 @@ LANGOPT(HalfArgsAndReturns, 1, 0, "half args and returns") LANGOPT(CUDA , 1, 0, "CUDA") LANGOPT(HIP , 1, 0, "HIP") LANGOPT(OpenMP , 32, 0, "OpenMP support and version of OpenMP (31, 40 or 45)") +LANGOPT(OpenMPExtensions , 1, 1, "Enable all Clang extensions for OpenMP directives and clauses") LANGOPT(OpenMPSimd , 1, 0, "Use SIMD only OpenMP support.") LANGOPT(OpenMPUseTLS , 1, 0, "Use TLS for threadprivates or runtime calls") LANGOPT(OpenMPIsDevice , 1, 0, "Generate code only for OpenMP target device") @@ -241,7 +242,10 @@ LANGOPT(OpenMPCUDANumSMs , 32, 0, "Number of SMs for CUDA devices.") LANGOPT(OpenMPCUDABlocksPerSM , 32, 0, "Number of blocks per SM for CUDA devices.") LANGOPT(OpenMPCUDAReductionBufNum , 32, 1024, "Number of the reduction records in the intermediate reduction buffer used for the teams reductions.") LANGOPT(OpenMPTargetNewRuntime , 1, 0, "Use the new bitcode library for OpenMP offloading") +LANGOPT(OpenMPTargetDebug , 32, 0, "Enable debugging in the OpenMP offloading device RTL") LANGOPT(OpenMPOptimisticCollapse , 1, 0, "Use at most 32 bits to represent the collapsed loop nest counter.") +LANGOPT(OpenMPThreadSubscription , 1, 0, "Assume work-shared loops do not have more iterations than participating threads.") +LANGOPT(OpenMPTeamSubscription , 1, 0, "Assume distributed loops do not have more iterations than participating teams.") LANGOPT(RenderScript , 1, 0, "RenderScript") LANGOPT(CUDAIsDevice , 1, 0, "compiling for CUDA device") @@ -280,6 +284,7 @@ BENIGN_LANGOPT(VisibilityInlinesHiddenStaticLocalVar, 1, 0, "hidden visibility for static local variables in inline C++ " "methods when -fvisibility-inlines hidden is enabled") LANGOPT(GlobalAllocationFunctionVisibilityHidden , 1, 0, "hidden visibility for global operator new and delete declaration") +LANGOPT(NewInfallible , 1, 0, "Treats throwing global C++ operator new as always returning valid memory (annotates with __attribute__((returns_nonnull)) and throw()). This is detectable in source.") BENIGN_LANGOPT(ParseUnknownAnytype, 1, 0, "__unknown_anytype") BENIGN_LANGOPT(DebuggerSupport , 1, 0, "debugger support") BENIGN_LANGOPT(DebuggerCastResultToId, 1, 0, "for 'po' in the debugger, cast the result to id if it is of unknown type") @@ -397,6 +402,7 @@ ENUM_LANGOPT(ClangABICompat, ClangABI, 4, ClangABI::Latest, "with") COMPATIBLE_VALUE_LANGOPT(FunctionAlignment, 5, 0, "Default alignment for functions") +COMPATIBLE_VALUE_LANGOPT(LoopAlignment, 32, 0, "Default alignment for loops") LANGOPT(FixedPoint, 1, 0, "fixed point types") LANGOPT(PaddingOnUnsignedFixedPoint, 1, 0, @@ -419,12 +425,15 @@ LANGOPT(SpeculativeLoadHardening, 1, 0, "Speculative load hardening enabled") LANGOPT(RelativeCXXABIVTables, 1, 0, "Use an ABI-incompatible v-table layout that uses relative references") -LANGOPT(ArmSveVectorBits, 32, 0, "SVE vector size in bits") +LANGOPT(VScaleMin, 32, 0, "Minimum vscale value") +LANGOPT(VScaleMax, 32, 0, "Maximum vscale value") -ENUM_LANGOPT(ExtendIntArgs, ExtendArgsKind, 1, ExtendArgsKind::ExtendTo32, +ENUM_LANGOPT(ExtendIntArgs, ExtendArgsKind, 1, ExtendArgsKind::ExtendTo32, "Controls how scalar integer arguments are extended in calls " "to unprototyped and varargs functions") +VALUE_LANGOPT(FuchsiaAPILevel, 32, 0, "Fuchsia API level") + #undef LANGOPT #undef COMPATIBLE_LANGOPT #undef BENIGN_LANGOPT diff --git a/contrib/llvm-project/clang/include/clang/Basic/LangOptions.h b/contrib/llvm-project/clang/include/clang/Basic/LangOptions.h index b60b94a1ba08..35b33c2e0971 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/LangOptions.h +++ b/contrib/llvm-project/clang/include/clang/Basic/LangOptions.h @@ -431,6 +431,13 @@ public: /// Return the OpenCL C or C++ version as a VersionTuple. VersionTuple getOpenCLVersionTuple() const; + /// Return the OpenCL version that kernel language is compatible with + unsigned getOpenCLCompatibleVersion() const; + + /// Return the OpenCL C or C++ for OpenCL language name and version + /// as a string. + std::string getOpenCLVersionString() const; + /// Check if return address signing is enabled. bool hasSignReturnAddress() const { return getSignReturnAddressScope() != SignReturnAddressScopeKind::None; diff --git a/contrib/llvm-project/clang/include/clang/Basic/LangStandards.def b/contrib/llvm-project/clang/include/clang/Basic/LangStandards.def index 2cfeb68e56d6..6056cfd65bbb 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/LangStandards.def +++ b/contrib/llvm-project/clang/include/clang/Basic/LangStandards.def @@ -180,8 +180,15 @@ LANGSTANDARD(opencl20, "cl2.0", LANGSTANDARD(opencl30, "cl3.0", OpenCL, "OpenCL 3.0", LineComment | C99 | Digraphs | HexFloat | OpenCL) -LANGSTANDARD(openclcpp, "clc++", - OpenCL, "C++ for OpenCL", + +LANGSTANDARD(openclcpp10, "clc++1.0", + OpenCL, "C++ for OpenCL 1.0", + LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus17 | + Digraphs | HexFloat | OpenCL) +LANGSTANDARD_ALIAS(openclcpp10, "clc++") + +LANGSTANDARD(openclcpp2021, "clc++2021", + OpenCL, "C++ for OpenCL 2021", LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus17 | Digraphs | HexFloat | OpenCL) @@ -190,7 +197,9 @@ LANGSTANDARD_ALIAS_DEPR(opencl11, "CL1.1") LANGSTANDARD_ALIAS_DEPR(opencl12, "CL1.2") LANGSTANDARD_ALIAS_DEPR(opencl20, "CL2.0") LANGSTANDARD_ALIAS_DEPR(opencl30, "CL3.0") -LANGSTANDARD_ALIAS_DEPR(openclcpp, "CLC++") +LANGSTANDARD_ALIAS_DEPR(openclcpp10, "CLC++") +LANGSTANDARD_ALIAS_DEPR(openclcpp10, "CLC++1.0") +LANGSTANDARD_ALIAS_DEPR(openclcpp2021, "CLC++2021") // CUDA LANGSTANDARD(cuda, "cuda", CUDA, "NVIDIA CUDA(tm)", diff --git a/contrib/llvm-project/clang/include/clang/Basic/MSP430Target.def b/contrib/llvm-project/clang/include/clang/Basic/MSP430Target.def index a1e192c19261..7a10be1d54c8 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/MSP430Target.def +++ b/contrib/llvm-project/clang/include/clang/Basic/MSP430Target.def @@ -238,8 +238,7 @@ MSP430_MCU_FEAT("msp430f4793", "32bit") MSP430_MCU_FEAT("msp430f4784", "32bit") MSP430_MCU_FEAT("msp430f4794", "32bit") -// Generic MSUs -MSP430_MCU("msp430") +// Generic MCUs MSP430_MCU("msp430i2xxgeneric") #undef MSP430_MCU diff --git a/contrib/llvm-project/clang/include/clang/Basic/ObjCRuntime.h b/contrib/llvm-project/clang/include/clang/Basic/ObjCRuntime.h index 26403bfa98c9..30a5fde40754 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/ObjCRuntime.h +++ b/contrib/llvm-project/clang/include/clang/Basic/ObjCRuntime.h @@ -18,6 +18,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/HashBuilder.h" #include "llvm/Support/VersionTuple.h" #include <string> @@ -480,6 +481,12 @@ public: friend llvm::hash_code hash_value(const ObjCRuntime &OCR) { return llvm::hash_combine(OCR.getKind(), OCR.getVersion()); } + + template <typename HasherT, llvm::support::endianness Endianness> + friend void addHash(llvm::HashBuilderImpl<HasherT, Endianness> &HBuilder, + const ObjCRuntime &OCR) { + HBuilder.add(OCR.getKind(), OCR.getVersion()); + } }; raw_ostream &operator<<(raw_ostream &out, const ObjCRuntime &value); diff --git a/contrib/llvm-project/clang/include/clang/Basic/OpenCLOptions.h b/contrib/llvm-project/clang/include/clang/Basic/OpenCLOptions.h index 1a035626fade..d6cb1a210519 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/OpenCLOptions.h +++ b/contrib/llvm-project/clang/include/clang/Basic/OpenCLOptions.h @@ -58,7 +58,7 @@ static inline OpenCLVersionID encodeOpenCLVersion(unsigned OpenCLVersion) { // mask. static inline bool isOpenCLVersionContainedInMask(const LangOptions &LO, unsigned Mask) { - auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion; + auto CLVer = LO.getOpenCLCompatibleVersion(); OpenCLVersionID Code = encodeOpenCLVersion(CLVer); return Mask & Code; } @@ -79,8 +79,8 @@ public: // the __opencl_c_program_scope_global_variables feature is supported // C++ for OpenCL inherits rule from OpenCL C v2.0. bool areProgramScopeVariablesSupported(const LangOptions &Opts) const { - return Opts.OpenCLCPlusPlus || Opts.OpenCLVersion == 200 || - (Opts.OpenCLVersion == 300 && + return Opts.getOpenCLCompatibleVersion() == 200 || + (Opts.getOpenCLCompatibleVersion() == 300 && isSupported("__opencl_c_program_scope_global_variables", Opts)); } @@ -115,8 +115,7 @@ public: // Is option available in OpenCL version \p LO. bool isAvailableIn(const LangOptions &LO) const { // In C++ mode all extensions should work at least as in v2.0. - auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion; - return CLVer >= Avail; + return LO.getOpenCLCompatibleVersion() >= Avail; } // Is core option in OpenCL version \p LO. diff --git a/contrib/llvm-project/clang/include/clang/Basic/OpenMPKinds.def b/contrib/llvm-project/clang/include/clang/Basic/OpenMPKinds.def index 9f9c32da4aa0..80ebda917945 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/OpenMPKinds.def +++ b/contrib/llvm-project/clang/include/clang/Basic/OpenMPKinds.def @@ -59,6 +59,12 @@ #ifndef OPENMP_REDUCTION_MODIFIER #define OPENMP_REDUCTION_MODIFIER(Name) #endif +#ifndef OPENMP_ADJUST_ARGS_KIND +#define OPENMP_ADJUST_ARGS_KIND(Name) +#endif +#ifndef OPENMP_BIND_KIND +#define OPENMP_BIND_KIND(Name) +#endif // Static attributes for 'schedule' clause. OPENMP_SCHEDULE_KIND(static) @@ -123,6 +129,8 @@ OPENMP_MAP_MODIFIER_KIND(always) OPENMP_MAP_MODIFIER_KIND(close) OPENMP_MAP_MODIFIER_KIND(mapper) OPENMP_MAP_MODIFIER_KIND(present) +// This is an OpenMP extension for the sake of OpenACC support. +OPENMP_MAP_MODIFIER_KIND(ompx_hold) // Modifiers for 'to' or 'from' clause. OPENMP_MOTION_MODIFIER_KIND(mapper) @@ -147,6 +155,17 @@ OPENMP_REDUCTION_MODIFIER(default) OPENMP_REDUCTION_MODIFIER(inscan) OPENMP_REDUCTION_MODIFIER(task) +// Adjust-op kinds for the 'adjust_args' clause. +OPENMP_ADJUST_ARGS_KIND(nothing) +OPENMP_ADJUST_ARGS_KIND(need_device_ptr) + +// Binding kinds for the 'bind' clause. +OPENMP_BIND_KIND(teams) +OPENMP_BIND_KIND(parallel) +OPENMP_BIND_KIND(thread) + +#undef OPENMP_BIND_KIND +#undef OPENMP_ADJUST_ARGS_KIND #undef OPENMP_REDUCTION_MODIFIER #undef OPENMP_DEVICE_MODIFIER #undef OPENMP_ORDER_KIND diff --git a/contrib/llvm-project/clang/include/clang/Basic/OpenMPKinds.h b/contrib/llvm-project/clang/include/clang/Basic/OpenMPKinds.h index c7a2591de26c..e95a717f268d 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/OpenMPKinds.h +++ b/contrib/llvm-project/clang/include/clang/Basic/OpenMPKinds.h @@ -14,6 +14,7 @@ #ifndef LLVM_CLANG_BASIC_OPENMPKINDS_H #define LLVM_CLANG_BASIC_OPENMPKINDS_H +#include "clang/Basic/LangOptions.h" #include "llvm/ADT/StringRef.h" #include "llvm/Frontend/OpenMP/OMPConstants.h" @@ -166,8 +167,22 @@ enum OpenMPReductionClauseModifier { OMPC_REDUCTION_unknown, }; +/// OpenMP adjust-op kinds for 'adjust_args' clause. +enum OpenMPAdjustArgsOpKind { +#define OPENMP_ADJUST_ARGS_KIND(Name) OMPC_ADJUST_ARGS_##Name, +#include "clang/Basic/OpenMPKinds.def" + OMPC_ADJUST_ARGS_unknown, +}; + +/// OpenMP bindings for the 'bind' clause. +enum OpenMPBindClauseKind { +#define OPENMP_BIND_KIND(Name) OMPC_BIND_##Name, +#include "clang/Basic/OpenMPKinds.def" + OMPC_BIND_unknown +}; + unsigned getOpenMPSimpleClauseType(OpenMPClauseKind Kind, llvm::StringRef Str, - unsigned OpenMPVersion); + const LangOptions &LangOpts); const char *getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type); /// Checks if the specified directive is a directive with an associated @@ -245,6 +260,13 @@ bool isOpenMPDistributeDirective(OpenMPDirectiveKind DKind); /// otherwise - false. bool isOpenMPNestingDistributeDirective(OpenMPDirectiveKind DKind); +/// Checks if the specified directive constitutes a 'loop' directive in the +/// outermost nest. For example, 'omp teams loop' or 'omp loop'. +/// \param DKind Specified directive. +/// \return true - the directive has loop on the outermost nest. +/// otherwise - false. +bool isOpenMPGenericLoopDirective(OpenMPDirectiveKind DKind); + /// Checks if the specified clause is one of private clauses like /// 'private', 'firstprivate', 'reduction' etc.. /// \param Kind Clause kind. diff --git a/contrib/llvm-project/clang/include/clang/Basic/Sanitizers.h b/contrib/llvm-project/clang/include/clang/Basic/Sanitizers.h index b12a3b7821d7..db53010645ae 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/Sanitizers.h +++ b/contrib/llvm-project/clang/include/clang/Basic/Sanitizers.h @@ -16,6 +16,7 @@ #include "clang/Basic/LLVM.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/HashBuilder.h" #include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h" #include <cassert> #include <cstdint> @@ -72,6 +73,12 @@ public: llvm::hash_code hash_value() const; + template <typename HasherT, llvm::support::endianness Endianness> + friend void addHash(llvm::HashBuilderImpl<HasherT, Endianness> &HBuilder, + const SanitizerMask &SM) { + HBuilder.addRange(&SM.maskLoToHigh[0], &SM.maskLoToHigh[kNumElem]); + } + constexpr explicit operator bool() const { return maskLoToHigh[0] || maskLoToHigh[1]; } diff --git a/contrib/llvm-project/clang/include/clang/Basic/SourceLocation.h b/contrib/llvm-project/clang/include/clang/Basic/SourceLocation.h index 540de23b9f55..543245a811db 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/SourceLocation.h +++ b/contrib/llvm-project/clang/include/clang/Basic/SourceLocation.h @@ -23,8 +23,6 @@ namespace llvm { -template <typename T> struct DenseMapInfo; - class FoldingSetNodeID; template <typename T> struct FoldingSetTrait; @@ -363,6 +361,10 @@ class FileEntry; /// A SourceLocation and its associated SourceManager. /// /// This is useful for argument passing to functions that expect both objects. +/// +/// This class does not guarantee the presence of either the SourceManager or +/// a valid SourceLocation. Clients should use `isValid()` and `hasManager()` +/// before calling the member functions. class FullSourceLoc : public SourceLocation { const SourceManager *SrcMgr = nullptr; @@ -373,13 +375,10 @@ public: explicit FullSourceLoc(SourceLocation Loc, const SourceManager &SM) : SourceLocation(Loc), SrcMgr(&SM) {} - bool hasManager() const { - bool hasSrcMgr = SrcMgr != nullptr; - assert(hasSrcMgr == isValid() && "FullSourceLoc has location but no manager"); - return hasSrcMgr; - } + /// Checks whether the SourceManager is present. + bool hasManager() const { return SrcMgr != nullptr; } - /// \pre This FullSourceLoc has an associated SourceManager. + /// \pre hasManager() const SourceManager &getManager() const { assert(SrcMgr && "SourceManager is NULL."); return *SrcMgr; @@ -466,7 +465,7 @@ namespace llvm { /// Define DenseMapInfo so that FileID's can be used as keys in DenseMap and /// DenseSets. template <> - struct DenseMapInfo<clang::FileID> { + struct DenseMapInfo<clang::FileID, void> { static clang::FileID getEmptyKey() { return {}; } @@ -487,7 +486,7 @@ namespace llvm { /// Define DenseMapInfo so that SourceLocation's can be used as keys in /// DenseMap and DenseSet. This trait class is eqivalent to /// DenseMapInfo<unsigned> which uses SourceLocation::ID is used as a key. - template <> struct DenseMapInfo<clang::SourceLocation> { + template <> struct DenseMapInfo<clang::SourceLocation, void> { static clang::SourceLocation getEmptyKey() { constexpr clang::SourceLocation::UIntTy Zero = 0; return clang::SourceLocation::getFromRawEncoding(~Zero); diff --git a/contrib/llvm-project/clang/include/clang/Basic/Specifiers.h b/contrib/llvm-project/clang/include/clang/Basic/Specifiers.h index 1c38b411e083..66cdba3f912e 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/Specifiers.h +++ b/contrib/llvm-project/clang/include/clang/Basic/Specifiers.h @@ -31,6 +31,15 @@ namespace clang { /// Define the kind of constexpr specifier. enum class ConstexprSpecKind { Unspecified, Constexpr, Consteval, Constinit }; + /// In an if statement, this denotes whether the the statement is + /// a constexpr or consteval if statement. + enum class IfStatementKind : unsigned { + Ordinary, + Constexpr, + ConstevalNonNegated, + ConstevalNegated + }; + /// Specifies the width of a type, e.g., short, long, or long long. enum class TypeSpecifierWidth { Unspecified, Short, Long, LongLong }; @@ -59,6 +68,7 @@ namespace clang { TST_float, TST_double, TST_float128, + TST_ibm128, TST_bool, // _Bool TST_decimal32, // _Decimal32 TST_decimal64, // _Decimal64 diff --git a/contrib/llvm-project/clang/include/clang/Basic/Stack.h b/contrib/llvm-project/clang/include/clang/Basic/Stack.h index 3418c3bad11b..30ebd94aedd1 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/Stack.h +++ b/contrib/llvm-project/clang/include/clang/Basic/Stack.h @@ -39,7 +39,7 @@ namespace clang { /// is insufficient, calls Diag to emit a diagnostic before calling Fn. inline void runWithSufficientStackSpace(llvm::function_ref<void()> Diag, llvm::function_ref<void()> Fn) { -#ifdef LLVM_ENABLE_THREADS +#if LLVM_ENABLE_THREADS if (LLVM_UNLIKELY(isStackNearlyExhausted())) runWithSufficientStackSpaceSlow(Diag, Fn); else diff --git a/contrib/llvm-project/clang/include/clang/Basic/StmtNodes.td b/contrib/llvm-project/clang/include/clang/Basic/StmtNodes.td index 508f1fddf1b3..ab31c544ea9d 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/StmtNodes.td +++ b/contrib/llvm-project/clang/include/clang/Basic/StmtNodes.td @@ -219,12 +219,14 @@ def AsTypeExpr : StmtNode<Expr>; // OpenMP Directives. def OMPCanonicalLoop : StmtNode<Stmt>; def OMPExecutableDirective : StmtNode<Stmt, 1>; +def OMPMetaDirective : StmtNode<OMPExecutableDirective>; def OMPLoopBasedDirective : StmtNode<OMPExecutableDirective, 1>; def OMPLoopDirective : StmtNode<OMPLoopBasedDirective, 1>; def OMPParallelDirective : StmtNode<OMPExecutableDirective>; def OMPSimdDirective : StmtNode<OMPLoopDirective>; -def OMPTileDirective : StmtNode<OMPLoopBasedDirective>; -def OMPUnrollDirective : StmtNode<OMPLoopBasedDirective>; +def OMPLoopTransformationDirective : StmtNode<OMPLoopBasedDirective, 1>; +def OMPTileDirective : StmtNode<OMPLoopTransformationDirective>; +def OMPUnrollDirective : StmtNode<OMPLoopTransformationDirective>; def OMPForDirective : StmtNode<OMPLoopDirective>; def OMPForSimdDirective : StmtNode<OMPLoopDirective>; def OMPSectionsDirective : StmtNode<OMPExecutableDirective>; @@ -280,3 +282,4 @@ def OMPTargetTeamsDistributeSimdDirective : StmtNode<OMPLoopDirective>; def OMPInteropDirective : StmtNode<OMPExecutableDirective>; def OMPDispatchDirective : StmtNode<OMPExecutableDirective>; def OMPMaskedDirective : StmtNode<OMPExecutableDirective>; +def OMPGenericLoopDirective : StmtNode<OMPLoopDirective>; diff --git a/contrib/llvm-project/clang/include/clang/Basic/TargetBuiltins.h b/contrib/llvm-project/clang/include/clang/Basic/TargetBuiltins.h index ed53b10f61ef..d4ea8e98b2e3 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/TargetBuiltins.h +++ b/contrib/llvm-project/clang/include/clang/Basic/TargetBuiltins.h @@ -124,10 +124,21 @@ namespace clang { enum { LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, LastTSBuiltin }; } + namespace RISCVVector { + enum { + LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, +#define BUILTIN(ID, TYPE, ATTRS) BI##ID, +#include "clang/Basic/BuiltinsRISCVVector.def" + FirstTSBuiltin, + }; + } + /// RISCV builtins namespace RISCV { enum { LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, + FirstRVVBuiltin = clang::Builtin::FirstTSBuiltin, + LastRVVBuiltin = RISCVVector::FirstTSBuiltin - 1, #define BUILTIN(ID, TYPE, ATTRS) BI##ID, #include "clang/Basic/BuiltinsRISCV.def" LastTSBuiltin diff --git a/contrib/llvm-project/clang/include/clang/Basic/TargetInfo.h b/contrib/llvm-project/clang/include/clang/Basic/TargetInfo.h index 4f0cbf986b31..3e1e09417c66 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/TargetInfo.h +++ b/contrib/llvm-project/clang/include/clang/Basic/TargetInfo.h @@ -53,6 +53,15 @@ class SourceManager; namespace Builtin { struct Info; } +enum class FloatModeKind { + NoFloat = 255, + Float = 0, + Double, + LongDouble, + Float128, + Ibm128 +}; + /// Fields controlling how types are laid out in memory; these may need to /// be copied for targets like AMDGPU that base their ABIs on an auxiliary /// CPU target. @@ -64,7 +73,7 @@ struct TransferrableTargetInfo { unsigned char BFloat16Width, BFloat16Align; unsigned char FloatWidth, FloatAlign; unsigned char DoubleWidth, DoubleAlign; - unsigned char LongDoubleWidth, LongDoubleAlign, Float128Align; + unsigned char LongDoubleWidth, LongDoubleAlign, Float128Align, Ibm128Align; unsigned char LargeArrayMinWidth, LargeArrayAlign; unsigned char LongWidth, LongAlign; unsigned char LongLongWidth, LongLongAlign; @@ -104,7 +113,7 @@ struct TransferrableTargetInfo { unsigned MaxTLSAlign; const llvm::fltSemantics *HalfFormat, *BFloat16Format, *FloatFormat, - *DoubleFormat, *LongDoubleFormat, *Float128Format; + *DoubleFormat, *LongDoubleFormat, *Float128Format, *Ibm128Format; ///===---- Target Data Type Query Methods -------------------------------===// enum IntType { @@ -121,13 +130,6 @@ struct TransferrableTargetInfo { UnsignedLongLong }; - enum RealType { - NoFloat = 255, - Float = 0, - Double, - LongDouble, - Float128 - }; protected: IntType SizeType, IntMaxType, PtrDiffType, IntPtrType, WCharType, WIntType, Char16Type, Char32Type, Int64Type, Int16Type, SigAtomicType, @@ -200,6 +202,9 @@ protected: bool HasFloat128; bool HasFloat16; bool HasBFloat16; + bool HasIbm128; + bool HasLongDouble; + bool HasFPReturn; bool HasStrictFP; unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth; @@ -210,9 +215,6 @@ protected: unsigned char RegParmMax, SSERegParmMax; TargetCXXABI TheCXXABI; const LangASMap *AddrSpaceMap; - const unsigned *GridValues = - nullptr; // Array of target-specific GPU grid values that must be - // consistent between host RTL (plugin), device RTL, and clang. mutable StringRef PlatformName; mutable VersionTuple PlatformMinVersion; @@ -401,7 +403,8 @@ public: /// is represented as one of those two). At this time, there is no support /// for an explicit "PPC double-double" type (i.e. __ibm128) so we only /// need to differentiate between "long double" and IEEE quad precision. - RealType getRealTypeByWidth(unsigned BitWidth, bool ExplicitIEEE) const; + FloatModeKind getRealTypeByWidth(unsigned BitWidth, + FloatModeKind ExplicitType) const; /// Return the alignment (in bits) of the specified integer type enum. /// @@ -597,6 +600,16 @@ public: /// Determine whether the _BFloat16 type is supported on this target. virtual bool hasBFloat16Type() const { return HasBFloat16; } + /// Determine whether the __ibm128 type is supported on this target. + virtual bool hasIbm128Type() const { return HasIbm128; } + + /// Determine whether the long double type is supported on this target. + virtual bool hasLongDoubleType() const { return HasLongDouble; } + + /// Determine whether return of a floating point value is supported + /// on this target. + virtual bool hasFPReturn() const { return HasFPReturn; } + /// Determine whether constrained floating point is supported on this target. virtual bool hasStrictFP() const { return HasStrictFP; } @@ -675,12 +688,23 @@ public: return *Float128Format; } + /// getIbm128Width/Align/Format - Return the size/align/format of + /// '__ibm128'. + unsigned getIbm128Width() const { return 128; } + unsigned getIbm128Align() const { return Ibm128Align; } + const llvm::fltSemantics &getIbm128Format() const { return *Ibm128Format; } + /// Return the mangled code of long double. virtual const char *getLongDoubleMangling() const { return "e"; } /// Return the mangled code of __float128. virtual const char *getFloat128Mangling() const { return "g"; } + /// Return the mangled code of __ibm128. + virtual const char *getIbm128Mangling() const { + llvm_unreachable("ibm128 not implemented on this target"); + } + /// Return the mangled code of bfloat. virtual const char *getBFloat16Mangling() const { llvm_unreachable("bfloat not implemented on this target"); @@ -833,8 +857,8 @@ public: /// Check whether the given real type should use the "fpret" flavor of /// Objective-C message passing on this target. - bool useObjCFPRetForRealType(RealType T) const { - return RealTypeUsesObjCFPRet & (1 << T); + bool useObjCFPRetForRealType(FloatModeKind T) const { + return RealTypeUsesObjCFPRet & (1 << (int)T); } /// Check whether _Complex long double should use the "fp2ret" flavor @@ -870,6 +894,11 @@ public: /// across the current set of primary and secondary targets. virtual ArrayRef<Builtin::Info> getTargetBuiltins() const = 0; + /// Returns target-specific min and max values VScale_Range. + virtual Optional<std::pair<unsigned, unsigned>> + getVScaleRange(const LangOptions &LangOpts) const { + return None; + } /// The __builtin_clz* and __builtin_ctz* built-in /// functions are specified to have undefined results for zero inputs, but /// on targets that support these operations in a way that provides @@ -993,8 +1022,7 @@ public: } bool isValidAsmImmediate(const llvm::APInt &Value) const { if (!ImmSet.empty()) - return Value.isSignedIntN(32) && - ImmSet.count(Value.getZExtValue()) != 0; + return Value.isSignedIntN(32) && ImmSet.contains(Value.getZExtValue()); return !ImmRange.isConstrained || (Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max)); } @@ -1404,10 +1432,10 @@ public: return LangAS::Default; } - /// Return a target-specific GPU grid value based on the GVIDX enum \p gv - unsigned getGridValue(llvm::omp::GVIDX gv) const { - assert(GridValues != nullptr && "GridValues not initialized"); - return GridValues[gv]; + // access target-specific GPU grid values that must be consistent between + // host RTL (plugin), deviceRTL and clang. + virtual const llvm::omp::GV &getGridValue() const { + llvm_unreachable("getGridValue not implemented on this target"); } /// Retrieve the name of the platform as it is used in the diff --git a/contrib/llvm-project/clang/include/clang/Basic/TokenKinds.def b/contrib/llvm-project/clang/include/clang/Basic/TokenKinds.def index 48a664e3494e..0dd5936aa3e6 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/TokenKinds.def +++ b/contrib/llvm-project/clang/include/clang/Basic/TokenKinds.def @@ -438,6 +438,7 @@ TYPE_TRAIT_2(__builtin_types_compatible_p, TypeCompatible, KEYNOCXX) KEYWORD(__builtin_va_arg , KEYALL) KEYWORD(__extension__ , KEYALL) KEYWORD(__float128 , KEYALL) +KEYWORD(__ibm128 , KEYALL) KEYWORD(__imag , KEYALL) KEYWORD(__int128 , KEYALL) KEYWORD(__label__ , KEYALL) @@ -827,10 +828,11 @@ PRAGMA_ANNOTATION(pragma_redefine_extname) // handles them. PRAGMA_ANNOTATION(pragma_fp_contract) -// Annotation for #pragma STDC FENV_ACCESS +// Annotations for #pragma STDC FENV_ACCESS and #pragma fenv_access (MS compat) // The lexer produces these so that they only take effect when the parser // handles them. PRAGMA_ANNOTATION(pragma_fenv_access) +PRAGMA_ANNOTATION(pragma_fenv_access_ms) // Annotation for #pragma STDC FENV_ROUND // The lexer produces these so that they only take effect when the parser diff --git a/contrib/llvm-project/clang/include/clang/Basic/X86Target.def b/contrib/llvm-project/clang/include/clang/Basic/X86Target.def deleted file mode 100644 index 70f3879f33a1..000000000000 --- a/contrib/llvm-project/clang/include/clang/Basic/X86Target.def +++ /dev/null @@ -1,110 +0,0 @@ -//===--- X86Target.def - X86 Feature/Processor Database ---------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This file defines the X86-specific Features and Processors, as used by -// the X86 Targets. -// -//===----------------------------------------------------------------------===// - -#ifndef FEATURE -#define FEATURE(ENUM) -#endif - -#ifndef CPU_SPECIFIC -#define CPU_SPECIFIC(NAME, MANGLING, FEATURES) -#endif - -#ifndef CPU_SPECIFIC_ALIAS -#define CPU_SPECIFIC_ALIAS(NEW_NAME, NAME) -#endif - -// List of CPU Supports features in order. These need to remain in the order -// required by attribute 'target' checking. Note that not all are supported/ -// prioritized by GCC, so synchronization with GCC's implementation may require -// changing some existing values. -FEATURE(FEATURE_CMOV) -FEATURE(FEATURE_MMX) -FEATURE(FEATURE_SSE) -FEATURE(FEATURE_SSE2) -FEATURE(FEATURE_SSE3) -FEATURE(FEATURE_SSSE3) -FEATURE(FEATURE_SSE4_A) -FEATURE(FEATURE_SSE4_1) -FEATURE(FEATURE_SSE4_2) -FEATURE(FEATURE_POPCNT) -FEATURE(FEATURE_AES) -FEATURE(FEATURE_PCLMUL) -FEATURE(FEATURE_AVX) -FEATURE(FEATURE_BMI) -FEATURE(FEATURE_FMA4) -FEATURE(FEATURE_XOP) -FEATURE(FEATURE_FMA) -FEATURE(FEATURE_BMI2) -FEATURE(FEATURE_AVX2) -FEATURE(FEATURE_AVX512F) -FEATURE(FEATURE_AVX512VL) -FEATURE(FEATURE_AVX512BW) -FEATURE(FEATURE_AVX512DQ) -FEATURE(FEATURE_AVX512CD) -FEATURE(FEATURE_AVX512ER) -FEATURE(FEATURE_AVX512PF) -FEATURE(FEATURE_AVX512VBMI) -FEATURE(FEATURE_AVX512IFMA) -FEATURE(FEATURE_AVX5124VNNIW) -FEATURE(FEATURE_AVX5124FMAPS) -FEATURE(FEATURE_AVX512VPOPCNTDQ) -FEATURE(FEATURE_AVX512VBMI2) -FEATURE(FEATURE_GFNI) -FEATURE(FEATURE_VPCLMULQDQ) -FEATURE(FEATURE_AVX512VNNI) -FEATURE(FEATURE_AVX512BITALG) -FEATURE(FEATURE_AVX512BF16) -FEATURE(FEATURE_AVX512VP2INTERSECT) - - -// FIXME: When commented out features are supported in LLVM, enable them here. -CPU_SPECIFIC("generic", 'A', "") -CPU_SPECIFIC("pentium", 'B', "") -CPU_SPECIFIC("pentium_pro", 'C', "+cmov") -CPU_SPECIFIC("pentium_mmx", 'D', "+mmx") -CPU_SPECIFIC("pentium_ii", 'E', "+cmov,+mmx") -CPU_SPECIFIC("pentium_iii", 'H', "+cmov,+mmx,+sse") -CPU_SPECIFIC_ALIAS("pentium_iii_no_xmm_regs", "pentium_iii") -CPU_SPECIFIC("pentium_4", 'J', "+cmov,+mmx,+sse,+sse2") -CPU_SPECIFIC("pentium_m", 'K', "+cmov,+mmx,+sse,+sse2") -CPU_SPECIFIC("pentium_4_sse3", 'L', "+cmov,+mmx,+sse,+sse2,+sse3") -CPU_SPECIFIC("core_2_duo_ssse3", 'M', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3") -CPU_SPECIFIC("core_2_duo_sse4_1", 'N', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1") -CPU_SPECIFIC("atom", 'O', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+movbe") -CPU_SPECIFIC("atom_sse4_2", 'c', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt") -CPU_SPECIFIC("core_i7_sse4_2", 'P', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt") -CPU_SPECIFIC("core_aes_pclmulqdq", 'Q', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt") -CPU_SPECIFIC("atom_sse4_2_movbe", 'd', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt") -CPU_SPECIFIC("goldmont", 'i', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt") -CPU_SPECIFIC("sandybridge", 'R', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx") -CPU_SPECIFIC_ALIAS("core_2nd_gen_avx", "sandybridge") -CPU_SPECIFIC("ivybridge", 'S', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+f16c,+avx") -CPU_SPECIFIC_ALIAS("core_3rd_gen_avx", "ivybridge") -CPU_SPECIFIC("haswell", 'V', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2") -CPU_SPECIFIC_ALIAS("core_4th_gen_avx", "haswell") -CPU_SPECIFIC("core_4th_gen_avx_tsx", 'W', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2") -CPU_SPECIFIC("broadwell", 'X', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx") -CPU_SPECIFIC_ALIAS("core_5th_gen_avx", "broadwell") -CPU_SPECIFIC("core_5th_gen_avx_tsx", 'Y', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx") -CPU_SPECIFIC("knl", 'Z', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512f,+adx,+avx512er,+avx512pf,+avx512cd") -CPU_SPECIFIC_ALIAS("mic_avx512", "knl") -CPU_SPECIFIC("skylake", 'b', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx,+mpx") -CPU_SPECIFIC( "skylake_avx512", 'a', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512dq,+avx512f,+adx,+avx512cd,+avx512bw,+avx512vl,+clwb") -CPU_SPECIFIC("cannonlake", 'e', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512dq,+avx512f,+adx,+avx512ifma,+avx512cd,+avx512bw,+avx512vl,+avx512vbmi") -CPU_SPECIFIC("knm", 'j', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512f,+adx,+avx512er,+avx512pf,+avx512cd,+avx5124fmaps,+avx5124vnniw,+avx512vpopcntdq") - -#undef CPU_SPECIFIC_ALIAS -#undef CPU_SPECIFIC -#undef PROC_64_BIT -#undef PROC_32_BIT -#undef FEATURE diff --git a/contrib/llvm-project/clang/include/clang/Basic/riscv_vector.td b/contrib/llvm-project/clang/include/clang/Basic/riscv_vector.td index 48c032dd1422..cc242da7f1ca 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/riscv_vector.td +++ b/contrib/llvm-project/clang/include/clang/Basic/riscv_vector.td @@ -170,16 +170,27 @@ class RVVBuiltin<string suffix, string prototype, string type_range, // is always the first operand in builtin and IR intrinsic. bit HasMaskedOffOperand = true; - // This builtin has a granted vector length parameter in the last position. + // This builtin has a granted vector length parameter. bit HasVL = true; + // There are several cases for specifying tail policy. + // 1. Add tail policy argument to masked intrinsics. It may have the maskedoff + // argument or not. + // * Have the maskedoff argument: (HasPolicy = true, HasMaskedOffOperand = true) + // Ex: vadd_vv_i8m1_mt(mask, maskedoff, op1, op2, vl, ta); + // * Do not have the maskedoff argument: (HasPolicy = true, HasMaskedOffOperand = false) + // Ex: vmacc_vv_i8m1_mt(mask, vd, vs1, vs2, vl, ta); + // 2. Add dest argument for no mask intrinsics. (TODO) + // Ex: vmv_v_x_i8m1_t(dest, src, vl); + // 3. Always tail agnostic. (HasPolicy = false) + // Ex: vmseq_vv_i8m1_b8_m(mask, maskedoff, op1, op2, vl); + // The tail policy argument is located at the last position. + bit HasPolicy = true; + // This builtin supports non-masked function overloading api. // All masked operations support overloading api. bit HasNoMaskedOverloaded = true; - // Reads or writes "memory" or has other side-effects. - bit HasSideEffects = false; - // This builtin is valid for the given Log2LMULs. list<int> Log2LMUL = [0, 1, 2, 3, -1, -2, -3]; @@ -204,13 +215,18 @@ class RVVBuiltin<string suffix, string prototype, string type_range, // an automatic definition in header is emitted. string HeaderCode = ""; - // Sub extension of vector spec. Currently only support Zvamo or Zvlsseg. + // Sub extension of vector spec. Currently only support Zvlsseg. string RequiredExtension = ""; // Number of fields for Zvlsseg. int NF = 1; } +class RVVHeader +{ + code HeaderCode; +} + //===----------------------------------------------------------------------===// // Basic classes with automatic codegen. //===----------------------------------------------------------------------===// @@ -557,6 +573,7 @@ class IsFloat<string type> { } let HasNoMaskedOverloaded = false, + HasPolicy = false, ManualCodegen = [{ IntrinsicTypes = {ResultType, Ops[1]->getType()}; Ops[0] = Builder.CreateBitCast(Ops[0], ResultType->getPointerTo()); @@ -568,10 +585,24 @@ let HasNoMaskedOverloaded = false, Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo()); }] in { class RVVVLEMaskBuiltin : RVVBuiltin<"m", "mPCUe", "c"> { - let Name = "vle1_v"; - let IRName = "vle1"; + let Name = "vlm_v"; + let IRName = "vlm"; let HasMask = false; } +} + +let HasNoMaskedOverloaded = false, + ManualCodegen = [{ + IntrinsicTypes = {ResultType, Ops[1]->getType()}; + Ops[0] = Builder.CreateBitCast(Ops[0], ResultType->getPointerTo()); + }], + ManualCodegenMask= [{ + // Move mask to right before vl. + std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); + Ops.push_back(ConstantInt::get(Ops.back()->getType(), TAIL_UNDISTURBED)); + IntrinsicTypes = {ResultType, Ops[3]->getType()}; + Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo()); + }] in { multiclass RVVVLEBuiltin<list<string> types> { let Name = NAME # "_v", IRName = "vle", @@ -602,7 +633,7 @@ multiclass RVVVLEFFBuiltin<list<string> types> { llvm::Value *V = Builder.CreateExtractValue(LoadValue, {0}); // Store new_vl. clang::CharUnits Align = - CGM.getNaturalTypeAlignment(getContext().getSizeType()); + CGM.getNaturalPointeeTypeAlignment(E->getArg(1)->getType()); Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {1}), Address(NewVL, Align)); return V; @@ -612,6 +643,7 @@ multiclass RVVVLEFFBuiltin<list<string> types> { { // Move mask to right before vl. std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); + Ops.push_back(ConstantInt::get(Ops.back()->getType(), TAIL_UNDISTURBED)); IntrinsicTypes = {ResultType, Ops[4]->getType()}; Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo()); Value *NewVL = Ops[2]; @@ -621,7 +653,7 @@ multiclass RVVVLEFFBuiltin<list<string> types> { llvm::Value *V = Builder.CreateExtractValue(LoadValue, {0}); // Store new_vl. clang::CharUnits Align = - CGM.getNaturalTypeAlignment(getContext().getSizeType()); + CGM.getNaturalPointeeTypeAlignment(E->getArg(3)->getType()); Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {1}), Address(NewVL, Align)); return V; @@ -649,6 +681,7 @@ multiclass RVVVLSEBuiltin<list<string> types> { ManualCodegenMask= [{ // Move mask to right before vl. std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); + Ops.push_back(ConstantInt::get(Ops.back()->getType(), TAIL_UNDISTURBED)); IntrinsicTypes = {ResultType, Ops[4]->getType()}; Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo()); }] in { @@ -669,6 +702,7 @@ multiclass RVVIndexedLoad<string op> { ManualCodegenMask = [{ // Move mask to right before vl. std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); + Ops.push_back(ConstantInt::get(Ops.back()->getType(), TAIL_UNDISTURBED)); IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops[4]->getType()}; Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo()); }] in { @@ -688,6 +722,7 @@ multiclass RVVIndexedLoad<string op> { } let HasMaskedOffOperand = false, + HasPolicy = false, ManualCodegen = [{ // Builtin: (ptr, value, vl). Intrinsic: (value, ptr, vl) std::swap(Ops[0], Ops[1]); @@ -701,8 +736,8 @@ let HasMaskedOffOperand = false, IntrinsicTypes = {Ops[0]->getType(), Ops[3]->getType()}; }] in { class RVVVSEMaskBuiltin : RVVBuiltin<"m", "0PUem", "c"> { - let Name = "vse1_v"; - let IRName = "vse1"; + let Name = "vsm_v"; + let IRName = "vsm"; let HasMask = false; } multiclass RVVVSEBuiltin<list<string> types> { @@ -724,6 +759,7 @@ multiclass RVVVSSEBuiltin<list<string> types> { IRName = "vsse", IRNameMask = "vsse_mask", HasMaskedOffOperand = false, + HasPolicy = false, ManualCodegen = [{ // Builtin: (ptr, stride, value, vl). Intrinsic: (value, ptr, stride, vl) std::rotate(Ops.begin(), Ops.begin() + 2, Ops.begin() + 3); @@ -747,6 +783,7 @@ multiclass RVVVSSEBuiltin<list<string> types> { multiclass RVVIndexedStore<string op> { let HasMaskedOffOperand = false, + HasPolicy = false, ManualCodegen = [{ // Builtin: (ptr, index, value, vl). Intrinsic: (value, ptr, index, vl) std::rotate(Ops.begin(), Ops.begin() + 2, Ops.begin() + 3); @@ -805,14 +842,14 @@ multiclass RVVUnitStridedSegLoad<string op> { ManualCodegen = [{ { // builtin: (val0 address, val1 address, ..., ptr, vl) - IntrinsicTypes = {Ops[0]->getType()->getPointerElementType(), + IntrinsicTypes = {ConvertType(E->getArg(0)->getType()->getPointeeType()), Ops[NF + 1]->getType()}; // intrinsic: (ptr, vl) llvm::Value *Operands[] = {Ops[NF], Ops[NF + 1]}; llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes); llvm::Value *LoadValue = Builder.CreateCall(F, Operands, ""); - clang::CharUnits Align = CharUnits::fromQuantity( - IntrinsicTypes[0]->getScalarSizeInBits() / 8); + clang::CharUnits Align = + CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType()); llvm::Value *V; for (unsigned I = 0; I < NF; ++I) { V = Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {I}), @@ -825,7 +862,7 @@ multiclass RVVUnitStridedSegLoad<string op> { { // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, vl) // intrinsic: (maskedoff0, ..., ptr, mask, vl) - IntrinsicTypes = {Ops[0]->getType()->getPointerElementType(), + IntrinsicTypes = {ConvertType(E->getArg(0)->getType()->getPointeeType()), Ops[2 * NF + 2]->getType()}; SmallVector<llvm::Value*, 12> Operands; for (unsigned I = 0; I < NF; ++I) @@ -833,11 +870,12 @@ multiclass RVVUnitStridedSegLoad<string op> { Operands.push_back(Ops[2 * NF + 1]); Operands.push_back(Ops[NF]); Operands.push_back(Ops[2 * NF + 2]); - assert(Operands.size() == NF + 3); + Operands.push_back(ConstantInt::get(Ops.back()->getType(), TAIL_UNDISTURBED)); + assert(Operands.size() == NF + 4); llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes); llvm::Value *LoadValue = Builder.CreateCall(F, Operands, ""); - clang::CharUnits Align = CharUnits::fromQuantity( - IntrinsicTypes[0]->getScalarSizeInBits() / 8); + clang::CharUnits Align = + CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType()); llvm::Value *V; for (unsigned I = 0; I < NF; ++I) { V = Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {I}), @@ -875,15 +913,15 @@ multiclass RVVUnitStridedSegLoadFF<string op> { ManualCodegen = [{ { // builtin: (val0 address, val1 address, ..., ptr, new_vl, vl) - IntrinsicTypes = {Ops[0]->getType()->getPointerElementType(), + IntrinsicTypes = {ConvertType(E->getArg(0)->getType()->getPointeeType()), Ops[NF + 2]->getType()}; // intrinsic: (ptr, vl) llvm::Value *Operands[] = {Ops[NF], Ops[NF + 2]}; Value *NewVL = Ops[NF + 1]; llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes); llvm::Value *LoadValue = Builder.CreateCall(F, Operands, ""); - clang::CharUnits Align = CharUnits::fromQuantity( - IntrinsicTypes[0]->getScalarSizeInBits() / 8); + clang::CharUnits Align = + CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType()); for (unsigned I = 0; I < NF; ++I) { Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {I}), Address(Ops[I], Align)); @@ -897,7 +935,7 @@ multiclass RVVUnitStridedSegLoadFF<string op> { { // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, new_vl, vl) // intrinsic: (maskedoff0, ..., ptr, mask, vl) - IntrinsicTypes = {Ops[0]->getType()->getPointerElementType(), + IntrinsicTypes = {ConvertType(E->getArg(0)->getType()->getPointeeType()), Ops[2 * NF + 3]->getType()}; SmallVector<llvm::Value*, 12> Operands; for (unsigned I = 0; I < NF; ++I) @@ -905,12 +943,13 @@ multiclass RVVUnitStridedSegLoadFF<string op> { Operands.push_back(Ops[2 * NF + 1]); Operands.push_back(Ops[NF]); Operands.push_back(Ops[2 * NF + 3]); + Operands.push_back(ConstantInt::get(Ops.back()->getType(), TAIL_UNDISTURBED)); Value *NewVL = Ops[2 * NF + 2]; - assert(Operands.size() == NF + 3); + assert(Operands.size() == NF + 4); llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes); llvm::Value *LoadValue = Builder.CreateCall(F, Operands, ""); - clang::CharUnits Align = CharUnits::fromQuantity( - IntrinsicTypes[0]->getScalarSizeInBits() / 8); + clang::CharUnits Align = + CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType()); for (unsigned I = 0; I < NF; ++I) { Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {I}), Address(Ops[I], Align)); @@ -949,14 +988,14 @@ multiclass RVVStridedSegLoad<string op> { ManualCodegen = [{ { // builtin: (val0 address, val1 address, ..., ptr, stride, vl) - IntrinsicTypes = {Ops[0]->getType()->getPointerElementType(), + IntrinsicTypes = {ConvertType(E->getArg(0)->getType()->getPointeeType()), Ops[NF + 2]->getType()}; // intrinsic: (ptr, stride, vl) llvm::Value *Operands[] = {Ops[NF], Ops[NF + 1], Ops[NF + 2]}; llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes); llvm::Value *LoadValue = Builder.CreateCall(F, Operands, ""); - clang::CharUnits Align = CharUnits::fromQuantity( - IntrinsicTypes[0]->getScalarSizeInBits() / 8); + clang::CharUnits Align = + CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType()); llvm::Value *V; for (unsigned I = 0; I < NF; ++I) { V = Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {I}), @@ -969,7 +1008,7 @@ multiclass RVVStridedSegLoad<string op> { { // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, stride, vl) // intrinsic: (maskedoff0, ..., ptr, stride, mask, vl) - IntrinsicTypes = {Ops[0]->getType()->getPointerElementType(), + IntrinsicTypes = {ConvertType(E->getArg(0)->getType()->getPointeeType()), Ops[2 * NF + 3]->getType()}; SmallVector<llvm::Value*, 12> Operands; for (unsigned I = 0; I < NF; ++I) @@ -978,11 +1017,12 @@ multiclass RVVStridedSegLoad<string op> { Operands.push_back(Ops[2 * NF + 2]); Operands.push_back(Ops[NF]); Operands.push_back(Ops[2 * NF + 3]); - assert(Operands.size() == NF + 4); + Operands.push_back(ConstantInt::get(Ops.back()->getType(), TAIL_UNDISTURBED)); + assert(Operands.size() == NF + 5); llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes); llvm::Value *LoadValue = Builder.CreateCall(F, Operands, ""); - clang::CharUnits Align = CharUnits::fromQuantity( - IntrinsicTypes[0]->getScalarSizeInBits() / 8); + clang::CharUnits Align = + CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType()); llvm::Value *V; for (unsigned I = 0; I < NF; ++I) { V = Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {I}), @@ -1015,14 +1055,14 @@ multiclass RVVIndexedSegLoad<string op> { ManualCodegen = [{ { // builtin: (val0 address, val1 address, ..., ptr, index, vl) - IntrinsicTypes = {Ops[0]->getType()->getPointerElementType(), + IntrinsicTypes = {ConvertType(E->getArg(0)->getType()->getPointeeType()), Ops[NF + 1]->getType(), Ops[NF + 2]->getType()}; // intrinsic: (ptr, index, vl) llvm::Value *Operands[] = {Ops[NF], Ops[NF + 1], Ops[NF + 2]}; llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes); llvm::Value *LoadValue = Builder.CreateCall(F, Operands, ""); - clang::CharUnits Align = CharUnits::fromQuantity( - IntrinsicTypes[0]->getScalarSizeInBits() / 8); + clang::CharUnits Align = + CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType()); llvm::Value *V; for (unsigned I = 0; I < NF; ++I) { V = Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {I}), @@ -1034,7 +1074,7 @@ multiclass RVVIndexedSegLoad<string op> { ManualCodegenMask = [{ { // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, index, vl) - IntrinsicTypes = {Ops[0]->getType()->getPointerElementType(), + IntrinsicTypes = {ConvertType(E->getArg(0)->getType()->getPointeeType()), Ops[2 * NF + 2]->getType(), Ops[2 * NF + 3]->getType()}; // intrinsic: (maskedoff0, ..., ptr, index, mask, vl) SmallVector<llvm::Value*, 12> Operands; @@ -1044,11 +1084,12 @@ multiclass RVVIndexedSegLoad<string op> { Operands.push_back(Ops[2 * NF + 2]); Operands.push_back(Ops[NF]); Operands.push_back(Ops[2 * NF + 3]); - assert(Operands.size() == NF + 4); + Operands.push_back(ConstantInt::get(Ops.back()->getType(), TAIL_UNDISTURBED)); + assert(Operands.size() == NF + 5); llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes); llvm::Value *LoadValue = Builder.CreateCall(F, Operands, ""); - clang::CharUnits Align = CharUnits::fromQuantity( - IntrinsicTypes[0]->getScalarSizeInBits() / 8); + clang::CharUnits Align = + CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType()); llvm::Value *V; for (unsigned I = 0; I < NF; ++I) { V = Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {I}), @@ -1094,6 +1135,7 @@ multiclass RVVUnitStridedSegStore<string op> { IRNameMask = op # nf # "_mask", NF = nf, HasMaskedOffOperand = false, + HasPolicy = false, ManualCodegen = [{ { // Builtin: (ptr, val0, val1, ..., vl) @@ -1139,6 +1181,7 @@ multiclass RVVStridedSegStore<string op> { IRNameMask = op # nf # "_mask", NF = nf, HasMaskedOffOperand = false, + HasPolicy = false, ManualCodegen = [{ { // Builtin: (ptr, stride, val0, val1, ..., vl). @@ -1180,6 +1223,7 @@ multiclass RVVIndexedSegStore<string op> { IRNameMask = op # nf # "_mask", NF = nf, HasMaskedOffOperand = false, + HasPolicy = false, ManualCodegen = [{ { // Builtin: (ptr, index, val0, val1, ..., vl) @@ -1213,35 +1257,6 @@ multiclass RVVIndexedSegStore<string op> { } } -multiclass RVVAMOBuiltinSet<bit has_signed = false, bit has_unsigned = false, - bit has_fp = false> { - defvar type_list = !if(has_fp, ["i","l","f","d"], ["i","l"]); - foreach type = type_list in - foreach eew_list = EEWList in { - defvar eew = eew_list[0]; - defvar eew_index = eew_list[1]; - let Name = NAME # "ei" # eew # "_" # "v", - IRName = NAME, - IRNameMask = NAME # "_mask", - HasMaskedOffOperand = false, - ManualCodegen = [{ - // base, bindex, value, vl - IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[3]->getType()}; - Ops[0] = Builder.CreateBitCast(Ops[0], ResultType->getPointerTo()); - }], - ManualCodegenMask = [{ - std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); - IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[4]->getType()}; - Ops[0] = Builder.CreateBitCast(Ops[0], ResultType->getPointerTo()); - }] in { - if has_signed then - def : RVVBuiltin<"v", "vPe" # eew_index # "Uvv", type>; - if !and(!not(IsFloat<type>.val), has_unsigned) then - def : RVVBuiltin<"Uv", "UvPUe" # eew_index # "UvUv", type>; - } - } -} - multiclass RVVPseudoUnaryBuiltin<string IR, string type_range> { let Name = NAME, IRName = IR, @@ -1259,6 +1274,7 @@ multiclass RVVPseudoUnaryBuiltin<string IR, string type_range> { ManualCodegenMask = [{ { std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); + Ops.push_back(ConstantInt::get(Ops.back()->getType(), TAIL_UNDISTURBED)); // maskedoff, op1, mask, vl IntrinsicTypes = {ResultType, cast<llvm::VectorType>(ResultType)->getElementType(), @@ -1289,6 +1305,7 @@ multiclass RVVPseudoVNotBuiltin<string IR, string type_range> { ManualCodegenMask = [{ { std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); + Ops.push_back(ConstantInt::get(Ops.back()->getType(), TAIL_UNDISTURBED)); // maskedoff, op1, mask, vl IntrinsicTypes = {ResultType, cast<llvm::VectorType>(ResultType)->getElementType(), @@ -1336,6 +1353,7 @@ multiclass RVVPseudoVFUnaryBuiltin<string IR, string type_range> { ManualCodegenMask = [{ { std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); + Ops.push_back(ConstantInt::get(Ops.back()->getType(), TAIL_UNDISTURBED)); // maskedoff, op1, mask, vl IntrinsicTypes = {ResultType, Ops[1]->getType(), @@ -1368,6 +1386,7 @@ multiclass RVVPseudoVWCVTBuiltin<string IR, string MName, string type_range, ManualCodegenMask = [{ { std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); + Ops.push_back(ConstantInt::get(Ops.back()->getType(), TAIL_UNDISTURBED)); // maskedoff, op1, mask, vl IntrinsicTypes = {ResultType, Ops[1]->getType(), @@ -1403,6 +1422,7 @@ multiclass RVVPseudoVNCVTBuiltin<string IR, string MName, string type_range, ManualCodegenMask = [{ { std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1); + Ops.push_back(ConstantInt::get(Ops.back()->getType(), TAIL_UNDISTURBED)); // maskedoff, op1, mask, vl IntrinsicTypes = {ResultType, Ops[1]->getType(), @@ -1422,7 +1442,7 @@ multiclass RVVPseudoVNCVTBuiltin<string IR, string MName, string type_range, // 6.1. vsetvli/vsetvl instructions let HasVL = false, HasMask = false, - HasSideEffects = true, + HasPolicy = false, Log2LMUL = [0], ManualCodegen = [{IntrinsicTypes = {ResultType};}] in // Set XLEN type { @@ -1492,13 +1512,13 @@ let HasVL = false, // 7. Vector Loads and Stores // 7.4. Vector Unit-Stride Instructions -def vle1: RVVVLEMaskBuiltin; +def vlm: RVVVLEMaskBuiltin; defm vle8: RVVVLEBuiltin<["c"]>; defm vle16: RVVVLEBuiltin<["s","x"]>; defm vle32: RVVVLEBuiltin<["i","f"]>; defm vle64: RVVVLEBuiltin<["l","d"]>; -def vse1 : RVVVSEMaskBuiltin; +def vsm : RVVVSEMaskBuiltin; defm vse8 : RVVVSEBuiltin<["c"]>; defm vse16: RVVVSEBuiltin<["s","x"]>; defm vse32: RVVVSEBuiltin<["i","f"]>; @@ -1541,19 +1561,6 @@ defm : RVVIndexedSegStore<"vsuxseg">; defm : RVVIndexedSegStore<"vsoxseg">; } -// 8. Vector AMO Operations -let RequiredExtension = "Zvamo" in { -defm vamoswap : RVVAMOBuiltinSet< /* hasSigned */ true, /* hasUnsigned */ true, /* hasFP */ true>; -defm vamoadd : RVVAMOBuiltinSet< /* hasSigned */ true, /* hasUnsigned */ true>; -defm vamoxor : RVVAMOBuiltinSet< /* hasSigned */ true, /* hasUnsigned */ true>; -defm vamoand : RVVAMOBuiltinSet< /* hasSigned */ true, /* hasUnsigned */ true>; -defm vamoor : RVVAMOBuiltinSet< /* hasSigned */ true, /* hasUnsigned */ true>; -defm vamomin : RVVAMOBuiltinSet< /* hasSigned */ true>; -defm vamomax : RVVAMOBuiltinSet< /* hasSigned */ true>; -defm vamominu : RVVAMOBuiltinSet< /* hasSigned */ false, /* hasUnsigned */ true>; -defm vamomaxu : RVVAMOBuiltinSet< /* hasSigned */ false, /* hasUnsigned */ true>; -} - // 12. Vector Integer Arithmetic Instructions // 12.1. Vector Single-Width Integer Add and Subtract defm vadd : RVVIntBinBuiltinSet; @@ -1596,7 +1603,7 @@ let Log2LMUL = [-3, -2, -1, 0] in { } // 12.4. Vector Integer Add-with-Carry / Subtract-with-Borrow Instructions -let HasMask = false in { +let HasMask = false, HasPolicy = false in { defm vadc : RVVCarryinBuiltinSet; defm vmadc : RVVCarryOutInBuiltinSet<"vmadc_carry_in">; defm vmadc : RVVIntMaskOutBuiltinSet; @@ -1624,6 +1631,7 @@ defm vncvt_x_x_w : RVVPseudoVNCVTBuiltin<"vnsrl", "vncvt_x", "csi", ["Uv", "UvUw"]]>; // 12.8. Vector Integer Comparison Instructions +let HasPolicy = false in { defm vmseq : RVVIntMaskOutBuiltinSet; defm vmsne : RVVIntMaskOutBuiltinSet; defm vmsltu : RVVUnsignedMaskOutBuiltinSet; @@ -1634,6 +1642,7 @@ defm vmsgtu : RVVUnsignedMaskOutBuiltinSet; defm vmsgt : RVVSignedMaskOutBuiltinSet; defm vmsgeu : RVVUnsignedMaskOutBuiltinSet; defm vmsge : RVVSignedMaskOutBuiltinSet; +} // 12.9. Vector Integer Min/Max Instructions defm vminu : RVVUnsignedBinBuiltinSet; @@ -1669,6 +1678,7 @@ defm vwmulsu : RVVOutOp0Op1BuiltinSet<"vwmulsu", "csi", } // 12.13. Vector Single-Width Integer Multiply-Add Instructions +let HasPolicy = false in { defm vmacc : RVVIntTerBuiltinSet; defm vnmsac : RVVIntTerBuiltinSet; defm vmadd : RVVIntTerBuiltinSet; @@ -1689,10 +1699,11 @@ defm vwmaccsu : RVVOutOp1Op2BuiltinSet<"vwmaccsu", "csi", defm vwmaccus : RVVOutOp1Op2BuiltinSet<"vwmaccus", "csi", [["vx", "w", "wwUev"]]>; } +} // 12.15. Vector Integer Merge Instructions // C/C++ Operand: (mask, op1, op2, vl), Intrinsic: (op1, op2, mask, vl) -let HasMask = false, +let HasMask = false, HasPolicy = false, ManualCodegen = [{ std::rotate(Ops.begin(), Ops.begin() + 1, Ops.begin() + 3); IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[3]->getType()}; @@ -1705,7 +1716,7 @@ let HasMask = false, } // 12.16. Vector Integer Move Instructions -let HasMask = false in { +let HasMask = false, HasPolicy = false in { let MangledName = "vmv_v" in { defm vmv_v : RVVOutBuiltinSet<"vmv_v_v", "csil", [["v", "Uv", "UvUv"]]>; @@ -1769,6 +1780,7 @@ let Log2LMUL = [-2, -1, 0, 1, 2] in { } // 14.6. Vector Single-Width Floating-Point Fused Multiply-Add Instructions +let HasPolicy = false in { defm vfmacc : RVVFloatingTerBuiltinSet; defm vfnmacc : RVVFloatingTerBuiltinSet; defm vfmsac : RVVFloatingTerBuiltinSet; @@ -1783,6 +1795,7 @@ defm vfwmacc : RVVFloatingWidenTerBuiltinSet; defm vfwnmacc : RVVFloatingWidenTerBuiltinSet; defm vfwmsac : RVVFloatingWidenTerBuiltinSet; defm vfwnmsac : RVVFloatingWidenTerBuiltinSet; +} // 14.8. Vector Floating-Point Square-Root Instruction def vfsqrt : RVVFloatingUnaryVVBuiltin; @@ -1805,32 +1818,34 @@ defm vfneg_v : RVVPseudoVFUnaryBuiltin<"vfsgnjn", "xfd">; defm vfabs_v : RVVPseudoVFUnaryBuiltin<"vfsgnjx", "xfd">; // 14.13. Vector Floating-Point Compare Instructions +let HasPolicy = false in { defm vmfeq : RVVFloatingMaskOutBuiltinSet; defm vmfne : RVVFloatingMaskOutBuiltinSet; defm vmflt : RVVFloatingMaskOutBuiltinSet; defm vmfle : RVVFloatingMaskOutBuiltinSet; defm vmfgt : RVVFloatingMaskOutBuiltinSet; defm vmfge : RVVFloatingMaskOutBuiltinSet; +} // 14.14. Vector Floating-Point Classify Instruction -let Name = "vfclass_v" in +let Name = "vfclass_v", HasPolicy = false in def vfclass : RVVOp0Builtin<"Uv", "Uvv", "xfd">; // 14.15. Vector Floating-Point Merge Instructio // C/C++ Operand: (mask, op1, op2, vl), Builtin: (op1, op2, mask, vl) -let HasMask = false, +let HasMask = false, HasPolicy = false, ManualCodegen = [{ std::rotate(Ops.begin(), Ops.begin() + 1, Ops.begin() + 3); IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[3]->getType()}; }] in { - defm vmerge : RVVOutOp1BuiltinSet<"vfmerge", "xfd", + defm vmerge : RVVOutOp1BuiltinSet<"vmerge", "xfd", [["vvm", "v", "vmvv"]]>; defm vfmerge : RVVOutOp1BuiltinSet<"vfmerge", "xfd", [["vfm", "v", "vmve"]]>; } // 14.16. Vector Floating-Point Move Instruction -let HasMask = false, HasNoMaskedOverloaded = false in +let HasMask = false, HasNoMaskedOverloaded = false, HasPolicy = false in defm vfmv_v : RVVOutBuiltinSet<"vfmv_v_f", "xfd", [["f", "v", "ve"]]>; @@ -1867,6 +1882,7 @@ let Log2LMUL = [-3, -2, -1, 0, 1, 2] in { // 15. Vector Reduction Operations // 15.1. Vector Single-Width Integer Reduction Instructions +let HasPolicy = false in { defm vredsum : RVVIntReductionBuiltinSet; defm vredmaxu : RVVUnsignedReductionBuiltin; defm vredmax : RVVSignedReductionBuiltin; @@ -1888,22 +1904,23 @@ let HasMaskedOffOperand = false in { // 15.3. Vector Single-Width Floating-Point Reduction Instructions defm vfredmax : RVVFloatingReductionBuiltin; defm vfredmin : RVVFloatingReductionBuiltin; -defm vfredsum : RVVFloatingReductionBuiltin; +defm vfredusum : RVVFloatingReductionBuiltin; defm vfredosum : RVVFloatingReductionBuiltin; // 15.4. Vector Widening Floating-Point Reduction Instructions -defm vfwredsum : RVVFloatingWidenReductionBuiltin; +defm vfwredusum : RVVFloatingWidenReductionBuiltin; defm vfwredosum : RVVFloatingWidenReductionBuiltin; +} // 16. Vector Mask Instructions // 16.1. Vector Mask-Register Logical Instructions def vmand : RVVMaskBinBuiltin; def vmnand : RVVMaskBinBuiltin; -def vmandnot : RVVMaskBinBuiltin; +def vmandn : RVVMaskBinBuiltin; def vmxor : RVVMaskBinBuiltin; def vmor : RVVMaskBinBuiltin; def vmnor : RVVMaskBinBuiltin; -def vmornot : RVVMaskBinBuiltin; +def vmorn : RVVMaskBinBuiltin; def vmxnor : RVVMaskBinBuiltin; // pseudoinstructions def vmclr : RVVMaskNullaryBuiltin; @@ -1911,8 +1928,9 @@ def vmset : RVVMaskNullaryBuiltin; defm vmmv_m : RVVPseudoMaskBuiltin<"vmand", "c">; defm vmnot_m : RVVPseudoMaskBuiltin<"vmnand", "c">; -// 16.2. Vector mask population count vpopc -def vpopc : RVVMaskOp0Builtin<"um">; +let HasPolicy = false in { +// 16.2. Vector count population in mask vcpop.m +def vcpop : RVVMaskOp0Builtin<"um">; // 16.3. vfirst find-first-set mask bit def vfirst : RVVMaskOp0Builtin<"lm">; @@ -1934,10 +1952,11 @@ let HasNoMaskedOverloaded = false in { defm vid : RVVOutBuiltinSet<"vid", "csil", [["v", "v", "v"], ["v", "Uv", "Uv"]]>; } +} // 17. Vector Permutation Instructions // 17.1. Integer Scalar Move Instructions -let HasMask = false in { +let HasMask = false, HasPolicy = false in { let HasVL = false, MangledName = "vmv_x" in defm vmv_x : RVVOp0BuiltinSet<"vmv_x_s", "csil", [["s", "ve", "ev"], @@ -1949,7 +1968,7 @@ let HasMask = false in { } // 17.2. Floating-Point Scalar Move Instructions -let HasMask = false in { +let HasMask = false, HasPolicy = false in { let HasVL = false, MangledName = "vfmv_f" in defm vfmv_f : RVVOp0BuiltinSet<"vfmv_f_s", "xfd", [["s", "ve", "ev"]]>; @@ -1960,10 +1979,12 @@ let HasMask = false in { } // 17.3. Vector Slide Instructions +let HasPolicy = false in { // 17.3.1. Vector Slideup Instructions defm vslideup : RVVSlideBuiltinSet; // 17.3.2. Vector Slidedown Instructions defm vslidedown : RVVSlideBuiltinSet; +} // 17.3.3. Vector Slide1up Instructions defm vslide1up : RVVSlideOneBuiltinSet; @@ -1990,7 +2011,7 @@ defm vrgatherei16 : RVVOutBuiltinSet<"vrgatherei16_vv", "csil", [["vv", "Uv", "UvUv(Log2EEW:4)Uv"]]>; // 17.5. Vector Compress Instruction -let HasMask = false, +let HasMask = false, HasPolicy = false, ManualCodegen = [{ std::rotate(Ops.begin(), Ops.begin() + 1, Ops.begin() + 3); IntrinsicTypes = {ResultType, Ops[3]->getType()}; @@ -2005,7 +2026,7 @@ let HasMask = false, // Miscellaneous let HasMask = false, HasVL = false, IRName = "" in { - let Name = "vreinterpret_v", + let Name = "vreinterpret_v", HasPolicy = false, ManualCodegen = [{ return Builder.CreateBitCast(Ops[0], ResultType); }] in { @@ -2027,7 +2048,7 @@ let HasMask = false, HasVL = false, IRName = "" in { } } - let Name = "vundefined", HasNoMaskedOverloaded = false, + let Name = "vundefined", HasNoMaskedOverloaded = false, HasPolicy = false, ManualCodegen = [{ return llvm::UndefValue::get(ResultType); }] in { @@ -2037,7 +2058,7 @@ let HasMask = false, HasVL = false, IRName = "" in { // LMUL truncation // C/C++ Operand: VecTy, IR Operand: VecTy, Index - let Name = "vlmul_trunc_v", MangledName = "vlmul_trunc", + let Name = "vlmul_trunc_v", MangledName = "vlmul_trunc", HasPolicy = false, ManualCodegen = [{ { ID = Intrinsic::experimental_vector_extract; IntrinsicTypes = {ResultType, Ops[0]->getType()}; @@ -2055,7 +2076,7 @@ let HasMask = false, HasVL = false, IRName = "" in { // LMUL extension // C/C++ Operand: SubVecTy, IR Operand: VecTy, SubVecTy, Index - let Name = "vlmul_ext_v", MangledName = "vlmul_ext", + let Name = "vlmul_ext_v", MangledName = "vlmul_ext", HasPolicy = false, ManualCodegen = [{ ID = Intrinsic::experimental_vector_insert; IntrinsicTypes = {ResultType, Ops[0]->getType()}; @@ -2073,11 +2094,16 @@ let HasMask = false, HasVL = false, IRName = "" in { } } - let Name = "vget_v", + let Name = "vget_v", HasPolicy = false, ManualCodegen = [{ { ID = Intrinsic::experimental_vector_extract; - ScalableVectorType *VecTy = cast<ScalableVectorType>(ResultType); + auto *VecTy = cast<ScalableVectorType>(ResultType); + auto *OpVecTy = cast<ScalableVectorType>(Ops[0]->getType()); + // Mask to only valid indices. + unsigned MaxIndex = OpVecTy->getMinNumElements() / VecTy->getMinNumElements(); + assert(isPowerOf2_32(MaxIndex)); + Ops[1] = Builder.CreateAnd(Ops[1], MaxIndex - 1); Ops[1] = Builder.CreateMul(Ops[1], ConstantInt::get(Ops[1]->getType(), VecTy->getMinNumElements())); @@ -2086,17 +2112,22 @@ let HasMask = false, HasVL = false, IRName = "" in { } }] in { foreach dst_lmul = ["(SFixedLog2LMUL:0)", "(SFixedLog2LMUL:1)", "(SFixedLog2LMUL:2)"] in { - def : RVVBuiltin<"v" # dst_lmul # "v", dst_lmul # "vvKz", "csilfd", dst_lmul # "v">; + def : RVVBuiltin<"v" # dst_lmul # "v", dst_lmul # "vvKz", "csilxfd", dst_lmul # "v">; def : RVVBuiltin<"Uv" # dst_lmul # "Uv", dst_lmul # "UvUvKz", "csil", dst_lmul # "Uv">; } } - let Name = "vset_v", Log2LMUL = [0, 1, 2], + let Name = "vset_v", Log2LMUL = [0, 1, 2], HasPolicy = false, ManualCodegen = [{ { ID = Intrinsic::experimental_vector_insert; IntrinsicTypes = {ResultType, Ops[2]->getType()}; - ScalableVectorType *VecTy = cast<ScalableVectorType>(Ops[2]->getType()); + auto *ResVecTy = cast<ScalableVectorType>(ResultType); + auto *VecTy = cast<ScalableVectorType>(Ops[2]->getType()); + // Mask to only valid indices. + unsigned MaxIndex = ResVecTy->getMinNumElements() / VecTy->getMinNumElements(); + assert(isPowerOf2_32(MaxIndex)); + Ops[1] = Builder.CreateAnd(Ops[1], MaxIndex - 1); Ops[1] = Builder.CreateMul(Ops[1], ConstantInt::get(Ops[1]->getType(), VecTy->getMinNumElements())); @@ -2105,8 +2136,14 @@ let HasMask = false, HasVL = false, IRName = "" in { } }] in { foreach dst_lmul = ["(LFixedLog2LMUL:1)", "(LFixedLog2LMUL:2)", "(LFixedLog2LMUL:3)"] in { - def : RVVBuiltin<"v" # dst_lmul # "v", dst_lmul # "v" # dst_lmul # "vKzv", "csilfd">; + def : RVVBuiltin<"v" # dst_lmul # "v", dst_lmul # "v" # dst_lmul # "vKzv", "csilxfd">; def : RVVBuiltin<"Uv" # dst_lmul # "Uv", dst_lmul # "Uv" # dst_lmul #"UvKzUv", "csil">; } } } + +let HeaderCode = [{ +#define VE_TAIL_UNDISTURBED 0 +#define VE_TAIL_AGNOSTIC 1 +}] in +def policy : RVVHeader; diff --git a/contrib/llvm-project/clang/include/clang/CodeGen/ModuleBuilder.h b/contrib/llvm-project/clang/include/clang/CodeGen/ModuleBuilder.h index f9d056ed8b1e..26587e73bf6c 100644 --- a/contrib/llvm-project/clang/include/clang/CodeGen/ModuleBuilder.h +++ b/contrib/llvm-project/clang/include/clang/CodeGen/ModuleBuilder.h @@ -74,6 +74,10 @@ public: /// This may return null if there was no matching declaration. const Decl *GetDeclForMangledName(llvm::StringRef MangledName); + /// Given a global declaration, return a mangled name for this declaration + /// which has been added to this code generator via a Handle method. + llvm::StringRef GetMangledName(GlobalDecl GD); + /// Return the LLVM address of the given global entity. /// /// \param isForDefinition If true, the caller intends to define the diff --git a/contrib/llvm-project/clang/include/clang/DirectoryWatcher/DirectoryWatcher.h b/contrib/llvm-project/clang/include/clang/DirectoryWatcher/DirectoryWatcher.h index 4475807dfce9..d879b6411c9e 100644 --- a/contrib/llvm-project/clang/include/clang/DirectoryWatcher/DirectoryWatcher.h +++ b/contrib/llvm-project/clang/include/clang/DirectoryWatcher/DirectoryWatcher.h @@ -20,7 +20,7 @@ namespace clang { /// Provides notifications for file changes in a directory. /// /// Invokes client-provided function on every filesystem event in the watched -/// directory. Initially the the watched directory is scanned and for every file +/// directory. Initially the watched directory is scanned and for every file /// found, an event is synthesized as if the file was added. /// /// This is not a general purpose directory monitoring tool - list of diff --git a/contrib/llvm-project/clang/include/clang/Driver/Distro.h b/contrib/llvm-project/clang/include/clang/Driver/Distro.h index 0d2a0939639e..2723f75e8945 100644 --- a/contrib/llvm-project/clang/include/clang/Driver/Distro.h +++ b/contrib/llvm-project/clang/include/clang/Driver/Distro.h @@ -37,6 +37,7 @@ public: DebianStretch, DebianBuster, DebianBullseye, + DebianBookworm, Exherbo, RHEL5, RHEL6, @@ -72,6 +73,7 @@ public: UbuntuGroovy, UbuntuHirsute, UbuntuImpish, + UbuntuJammy, UnknownDistro }; @@ -119,11 +121,11 @@ public: bool IsOpenSUSE() const { return DistroVal == OpenSUSE; } bool IsDebian() const { - return DistroVal >= DebianLenny && DistroVal <= DebianBullseye; + return DistroVal >= DebianLenny && DistroVal <= DebianBookworm; } bool IsUbuntu() const { - return DistroVal >= UbuntuHardy && DistroVal <= UbuntuImpish; + return DistroVal >= UbuntuHardy && DistroVal <= UbuntuJammy; } bool IsAlpineLinux() const { return DistroVal == AlpineLinux; } diff --git a/contrib/llvm-project/clang/include/clang/Driver/Driver.h b/contrib/llvm-project/clang/include/clang/Driver/Driver.h index da7e8386a151..8b1f7091e701 100644 --- a/contrib/llvm-project/clang/include/clang/Driver/Driver.h +++ b/contrib/llvm-project/clang/include/clang/Driver/Driver.h @@ -253,6 +253,14 @@ public: /// or when using the -gen-reproducer driver flag. unsigned GenReproducer : 1; + // getFinalPhase - Determine which compilation mode we are in and record + // which option we used to determine the final phase. + // TODO: Much of what getFinalPhase returns are not actually true compiler + // modes. Fold this functionality into Types::getCompilationPhases and + // handleArguments. + phases::ID getFinalPhase(const llvm::opt::DerivedArgList &DAL, + llvm::opt::Arg **FinalPhaseArg = nullptr) const; + private: /// Certain options suppress the 'no input files' warning. unsigned SuppressMissingInputWarning : 1; @@ -270,14 +278,6 @@ private: llvm::opt::DerivedArgList * TranslateInputArgs(const llvm::opt::InputArgList &Args) const; - // getFinalPhase - Determine which compilation mode we are in and record - // which option we used to determine the final phase. - // TODO: Much of what getFinalPhase returns are not actually true compiler - // modes. Fold this functionality into Types::getCompilationPhases and - // handleArguments. - phases::ID getFinalPhase(const llvm::opt::DerivedArgList &DAL, - llvm::opt::Arg **FinalPhaseArg = nullptr) const; - // handleArguments - All code related to claiming and printing diagnostics // related to arguments to the driver are done here. void handleArguments(Compilation &C, llvm::opt::DerivedArgList &Args, diff --git a/contrib/llvm-project/clang/include/clang/Driver/Options.td b/contrib/llvm-project/clang/include/clang/Driver/Options.td index a0cbcae0bdc3..9bde64cf49fd 100644 --- a/contrib/llvm-project/clang/include/clang/Driver/Options.td +++ b/contrib/llvm-project/clang/include/clang/Driver/Options.td @@ -272,7 +272,7 @@ class MigratorOpts<string base> // Args.hasArg(OPT_ffoo) can be used to check that the flag is enabled. // This is useful if the option is usually disabled. // Use this only when the option cannot be declared via BoolFOption. -multiclass OptInFFlag<string name, string pos_prefix, string neg_prefix="", +multiclass OptInCC1FFlag<string name, string pos_prefix, string neg_prefix="", string help="", list<OptionFlag> flags=[]> { def f#NAME : Flag<["-"], "f"#name>, Flags<[CC1Option] # flags>, Group<f_Group>, HelpText<pos_prefix # help>; @@ -283,7 +283,7 @@ multiclass OptInFFlag<string name, string pos_prefix, string neg_prefix="", // A boolean option which is opt-out in CC1. The negative option exists in CC1 and // Args.hasArg(OPT_fno_foo) can be used to check that the flag is disabled. // Use this only when the option cannot be declared via BoolFOption. -multiclass OptOutFFlag<string name, string pos_prefix, string neg_prefix, +multiclass OptOutCC1FFlag<string name, string pos_prefix, string neg_prefix, string help="", list<OptionFlag> flags=[]> { def f#NAME : Flag<["-"], "f"#name>, Flags<flags>, Group<f_Group>, HelpText<pos_prefix # help>; @@ -291,6 +291,27 @@ multiclass OptOutFFlag<string name, string pos_prefix, string neg_prefix, Group<f_Group>, HelpText<neg_prefix # help>; } +// A boolean option which is opt-in in FC1. The positive option exists in FC1 and +// Args.hasArg(OPT_ffoo) can be used to check that the flag is enabled. +// This is useful if the option is usually disabled. +multiclass OptInFC1FFlag<string name, string pos_prefix, string neg_prefix="", + string help="", list<OptionFlag> flags=[]> { + def f#NAME : Flag<["-"], "f"#name>, Flags<[FC1Option] # flags>, + Group<f_Group>, HelpText<pos_prefix # help>; + def fno_#NAME : Flag<["-"], "fno-"#name>, Flags<flags>, + Group<f_Group>, HelpText<neg_prefix # help>; +} + +// A boolean option which is opt-out in FC1. The negative option exists in FC1 and +// Args.hasArg(OPT_fno_foo) can be used to check that the flag is disabled. +multiclass OptOutFC1FFlag<string name, string pos_prefix, string neg_prefix, + string help="", list<OptionFlag> flags=[]> { + def f#NAME : Flag<["-"], "f"#name>, Flags<flags>, + Group<f_Group>, HelpText<pos_prefix # help>; + def fno_#NAME : Flag<["-"], "fno-"#name>, Flags<[FC1Option] # flags>, + Group<f_Group>, HelpText<neg_prefix # help>; +} + // Creates a positive and negative flags where both of them are prefixed with // "m", have help text specified for positive and negative option, and a Group // optionally specified by the opt_group argument, otherwise Group<m_Group>. @@ -386,8 +407,7 @@ class MarshalledFlagRec<FlagDefExpanded flag, FlagDefExpanded other, Default default> : Flag<["-"], flag.Spelling>, Flags<flag.OptionFlags>, HelpText<flag.Help>, MarshallingInfoBooleanFlag<kpm, default.Value, flag.ValueAsCode, - flag.RecordName, other.ValueAsCode, - other.RecordName>, + other.ValueAsCode, other.RecordName>, ImpliedByAnyOf<implied.ImpliedBy, implied.ValueAsCode> {} // Generates TableGen records for two command line flags that control the same @@ -467,7 +487,6 @@ defvar render_script = LangOpts<"RenderScript">; defvar hip = LangOpts<"HIP">; defvar gnu_mode = LangOpts<"GNUMode">; defvar asm_preprocessor = LangOpts<"AsmPreprocessor">; -defvar cpp_modules = LangOpts<"CPlusPlusModules">; defvar std = !strconcat("LangStandard::getLangStandardForKind(", lang_std.KeyPath, ")"); @@ -598,12 +617,15 @@ def objcmt_migrate_designated_init : Flag<["-"], "objcmt-migrate-designated-init HelpText<"Enable migration to infer NS_DESIGNATED_INITIALIZER for initializer methods">, MarshallingInfoBitfieldFlag<FrontendOpts<"ObjCMTAction">, "FrontendOptions::ObjCMT_DesignatedInitializer">; -def objcmt_whitelist_dir_path: Joined<["-"], "objcmt-whitelist-dir-path=">, Flags<[CC1Option]>, +def objcmt_allowlist_dir_path: Joined<["-"], "objcmt-allowlist-dir-path=">, Flags<[CC1Option]>, HelpText<"Only modify files with a filename contained in the provided directory path">, - MarshallingInfoString<FrontendOpts<"ObjCMTWhiteListPath">>; + MarshallingInfoString<FrontendOpts<"ObjCMTAllowListPath">>; +def : Joined<["-"], "objcmt-whitelist-dir-path=">, Flags<[CC1Option]>, + HelpText<"Alias for -objcmt-allowlist-dir-path">, + Alias<objcmt_allowlist_dir_path>; // The misspelt "white-list" [sic] alias is due for removal. def : Joined<["-"], "objcmt-white-list-dir-path=">, Flags<[CC1Option]>, - Alias<objcmt_whitelist_dir_path>; + Alias<objcmt_allowlist_dir_path>; // Make sure all other -ccc- options are rejected. def ccc_ : Joined<["-"], "ccc-">, Group<internal_Group>, Flags<[Unsupported]>; @@ -701,7 +723,7 @@ def ObjC : Flag<["-"], "ObjC">, Flags<[NoXarchOption]>, def O : Joined<["-"], "O">, Group<O_Group>, Flags<[CC1Option]>; def O_flag : Flag<["-"], "O">, Flags<[CC1Option]>, Alias<O>, AliasArgs<["1"]>; def Ofast : Joined<["-"], "Ofast">, Group<O_Group>, Flags<[CC1Option]>; -def P : Flag<["-"], "P">, Flags<[CC1Option]>, Group<Preprocessor_Group>, +def P : Flag<["-"], "P">, Flags<[CC1Option,FlangOption,FC1Option]>, Group<Preprocessor_Group>, HelpText<"Disable linemarker output in -E mode">, MarshallingInfoNegativeFlag<PreprocessorOutputOpts<"ShowLineMarkers">>; def Qy : Flag<["-"], "Qy">, Flags<[CC1Option]>, @@ -815,7 +837,9 @@ def autocomplete : Joined<["--"], "autocomplete=">; def bind__at__load : Flag<["-"], "bind_at_load">; def bundle__loader : Separate<["-"], "bundle_loader">; def bundle : Flag<["-"], "bundle">; -def b : JoinedOrSeparate<["-"], "b">, Flags<[Unsupported]>; +def b : JoinedOrSeparate<["-"], "b">, Flags<[LinkerInput, RenderAsInput]>, + HelpText<"Pass -b <arg> to the linker on AIX (only).">, MetaVarName<"<arg>">, + Group<Link_Group>; def cl_opt_disable : Flag<["-"], "cl-opt-disable">, Group<opencl_Group>, Flags<[CC1Option]>, HelpText<"OpenCL only. This option disables all optimizations. By default optimizations are enabled.">; def cl_strict_aliasing : Flag<["-"], "cl-strict-aliasing">, Group<opencl_Group>, Flags<[CC1Option]>, @@ -843,7 +867,8 @@ def cl_no_signed_zeros : Flag<["-"], "cl-no-signed-zeros">, Group<opencl_Group>, HelpText<"OpenCL only. Allow use of less precise no signed zeros computations in the generated binary.">, MarshallingInfoFlag<LangOpts<"CLNoSignedZero">>; def cl_std_EQ : Joined<["-"], "cl-std=">, Group<opencl_Group>, Flags<[CC1Option]>, - HelpText<"OpenCL language standard to compile for.">, Values<"cl,CL,cl1.0,CL1.0,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,cl3.0,CL3.0,clc++,CLC++">; + HelpText<"OpenCL language standard to compile for.">, + Values<"cl,CL,cl1.0,CL1.0,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,cl3.0,CL3.0,clc++,CLC++,clc++1.0,CLC++1.0,clc++2021,CLC++2021">; def cl_denorms_are_zero : Flag<["-"], "cl-denorms-are-zero">, Group<opencl_Group>, HelpText<"OpenCL only. Allow denormals to be flushed to zero.">; def cl_fp32_correctly_rounded_divide_sqrt : Flag<["-"], "cl-fp32-correctly-rounded-divide-sqrt">, Group<opencl_Group>, Flags<[CC1Option]>, @@ -1004,7 +1029,7 @@ def fuse_cuid_EQ : Joined<["-"], "fuse-cuid=">, "offloading languages CUDA and HIP: 'hash' (ID's generated by hashing " "file path and command line options) | 'random' (ID's generated as " "random numbers) | 'none' (disabled). Default is 'hash'. This option " - "will be overriden by option '-cuid=[ID]' if it is specified." >; + "will be overridden by option '-cuid=[ID]' if it is specified." >; def libomptarget_amdgcn_bc_path_EQ : Joined<["--"], "libomptarget-amdgcn-bc-path=">, Group<i_Group>, HelpText<"Path to libomptarget-amdgcn bitcode library">; def libomptarget_nvptx_bc_path_EQ : Joined<["--"], "libomptarget-nvptx-bc-path=">, Group<i_Group>, @@ -1064,6 +1089,9 @@ defm access_control : BoolFOption<"access-control", PosFlag<SetTrue>>; def falign_functions : Flag<["-"], "falign-functions">, Group<f_Group>; def falign_functions_EQ : Joined<["-"], "falign-functions=">, Group<f_Group>; +def falign_loops_EQ : Joined<["-"], "falign-loops=">, Group<f_Group>, Flags<[CC1Option]>, MetaVarName<"<N>">, + HelpText<"N must be a power of two. Align loops to the boundary">, + MarshallingInfoInt<CodeGenOpts<"LoopAlignment">>; def fno_align_functions: Flag<["-"], "fno-align-functions">, Group<f_Group>; defm allow_editor_placeholders : BoolFOption<"allow-editor-placeholders", LangOpts<"AllowEditorPlaceholders">, DefaultFalse, @@ -1250,12 +1278,19 @@ def fprofile_list_EQ : Joined<["-"], "fprofile-list=">, Group<f_Group>, Flags<[CC1Option, CoreOption]>, HelpText<"Filename defining the list of functions/files to instrument">, MarshallingInfoStringVector<LangOpts<"ProfileListFiles">>; +def fswift_async_fp_EQ : Joined<["-"], "fswift-async-fp=">, + Group<f_Group>, Flags<[CC1Option, CC1AsOption, CoreOption]>, MetaVarName<"<option>">, + HelpText<"Control emission of Swift async extended frame info (option: auto, always, never)">, + Values<"auto,always,never">, + NormalizedValuesScope<"CodeGenOptions::SwiftAsyncFramePointerKind">, + NormalizedValues<["Auto", "Always", "Never"]>, + MarshallingInfoEnum<CodeGenOpts<"SwiftAsyncFramePointer">, "Always">; defm addrsig : BoolFOption<"addrsig", CodeGenOpts<"Addrsig">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Emit">, NegFlag<SetFalse, [], "Don't emit">, BothFlags<[CoreOption], " an address-significance table">>; -defm blocks : OptInFFlag<"blocks", "Enable the 'blocks' language feature", "", "", [CoreOption]>; +defm blocks : OptInCC1FFlag<"blocks", "Enable the 'blocks' language feature", "", "", [CoreOption]>; def fbootclasspath_EQ : Joined<["-"], "fbootclasspath=">, Group<f_Group>; defm borland_extensions : BoolFOption<"borland-extensions", LangOpts<"Borland">, DefaultFalse, @@ -1271,7 +1306,7 @@ def fclang_abi_compat_EQ : Joined<["-"], "fclang-abi-compat=">, Group<f_clang_Gr Flags<[CC1Option]>, MetaVarName<"<version>">, Values<"<major>.<minor>,latest">, HelpText<"Attempt to match the ABI of Clang <version>">; def fclasspath_EQ : Joined<["-"], "fclasspath=">, Group<f_Group>; -defm color_diagnostics : OptInFFlag<"color-diagnostics", "Enable", "Disable", " colors in diagnostics", +defm color_diagnostics : OptInCC1FFlag<"color-diagnostics", "Enable", "Disable", " colors in diagnostics", [CoreOption, FlangOption]>; def fdiagnostics_color : Flag<["-"], "fdiagnostics-color">, Group<f_Group>, Flags<[CoreOption, NoXarchOption]>; @@ -1329,8 +1364,11 @@ defm cxx_exceptions: BoolFOption<"cxx-exceptions", defm async_exceptions: BoolFOption<"async-exceptions", LangOpts<"EHAsynch">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Enable EH Asynchronous exceptions">, NegFlag<SetFalse>>; -def fcxx_modules : Flag <["-"], "fcxx-modules">, Group<f_Group>, - Flags<[NoXarchOption]>; +defm cxx_modules : BoolFOption<"cxx-modules", + LangOpts<"CPlusPlusModules">, Default<cpp20.KeyPath>, + NegFlag<SetFalse, [CC1Option], "Disable">, PosFlag<SetTrue, [], "Enable">, + BothFlags<[NoXarchOption], " modules for C++">>, + ShouldParseIf<cplusplus.KeyPath>; def fdebug_pass_arguments : Flag<["-"], "fdebug-pass-arguments">, Group<f_Group>; def fdebug_pass_structure : Flag<["-"], "fdebug-pass-structure">, Group<f_Group>; def fdepfile_entry : Joined<["-"], "fdepfile-entry=">, @@ -1389,7 +1427,7 @@ def fno_elide_type : Flag<["-"], "fno-elide-type">, Group<f_Group>, HelpText<"Do not elide types when printing diagnostics">, MarshallingInfoNegativeFlag<DiagnosticOpts<"ElideType">>; def feliminate_unused_debug_symbols : Flag<["-"], "feliminate-unused-debug-symbols">, Group<f_Group>; -defm eliminate_unused_debug_types : OptOutFFlag<"eliminate-unused-debug-types", +defm eliminate_unused_debug_types : OptOutCC1FFlag<"eliminate-unused-debug-types", "Do not emit ", "Emit ", " debug info for defined but unused types">; def femit_all_decls : Flag<["-"], "femit-all-decls">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Emit all declarations, even if unused">, @@ -1489,7 +1527,7 @@ defm cxx_static_destructors : BoolFOption<"c++-static-destructors", def fsymbol_partition_EQ : Joined<["-"], "fsymbol-partition=">, Group<f_Group>, Flags<[CC1Option]>, MarshallingInfoString<CodeGenOpts<"SymbolPartition">>; -defm memory_profile : OptInFFlag<"memory-profile", "Enable", "Disable", " heap memory profiling">; +defm memory_profile : OptInCC1FFlag<"memory-profile", "Enable", "Disable", " heap memory profiling">; def fmemory_profile_EQ : Joined<["-"], "fmemory-profile=">, Group<f_Group>, Flags<[CC1Option]>, MetaVarName<"<directory>">, HelpText<"Enable heap memory profiling and dump results into <directory>">; @@ -1729,8 +1767,11 @@ defm reciprocal_math : BoolFOption<"reciprocal-math", PosFlag<SetTrue, [CC1Option], "Allow division operations to be reassociated", [menable_unsafe_fp_math.KeyPath]>, NegFlag<SetFalse>>; -def fapprox_func : Flag<["-"], "fapprox-func">, Group<f_Group>, Flags<[CC1Option, NoDriverOption]>, - MarshallingInfoFlag<LangOpts<"ApproxFunc">>, ImpliedByAnyOf<[menable_unsafe_fp_math.KeyPath]>; +defm approx_func : BoolFOption<"approx-func", LangOpts<"ApproxFunc">, DefaultFalse, + PosFlag<SetTrue, [CC1Option], "Allow certain math function calls to be replaced " + "with an approximately equivalent calculation", + [menable_unsafe_fp_math.KeyPath]>, + NegFlag<SetFalse>>; defm finite_math_only : BoolFOption<"finite-math-only", LangOpts<"FiniteMathOnly">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "", [cl_finite_math_only.KeyPath, ffast_math.KeyPath]>, @@ -1770,7 +1811,7 @@ defm strict_float_cast_overflow : BoolFOption<"strict-float-cast-overflow", defm protect_parens : BoolFOption<"protect-parens", LangOpts<"ProtectParens">, DefaultFalse, - PosFlag<SetTrue, [CoreOption, CC1Option], + PosFlag<SetTrue, [CoreOption, CC1Option], "Determines whether the optimizer honors parentheses when " "floating-point expressions are evaluated">, NegFlag<SetFalse>>; @@ -1799,6 +1840,9 @@ def frewrite_map_file_EQ : Joined<["-"], "frewrite-map-file=">, defm use_line_directives : BoolFOption<"use-line-directives", PreprocessorOutputOpts<"UseLineDirectives">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Use #line in preprocessed output">, NegFlag<SetFalse>>; +defm minimize_whitespace : BoolFOption<"minimize-whitespace", + PreprocessorOutputOpts<"MinimizeWhitespace">, DefaultFalse, + PosFlag<SetTrue, [CC1Option], "Minimize whitespace when emitting preprocessor output">, NegFlag<SetFalse>>; def ffreestanding : Flag<["-"], "ffreestanding">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Assert that the compilation takes place in a freestanding environment">, @@ -1837,7 +1881,7 @@ def fexperimental_isel : Flag<["-"], "fexperimental-isel">, Group<f_clang_Group> Alias<fglobal_isel>; defm legacy_pass_manager : BoolOption<"f", "legacy-pass-manager", CodeGenOpts<"LegacyPassManager">, Default<"!static_cast<unsigned>(LLVM_ENABLE_NEW_PASS_MANAGER)">, - PosFlag<SetTrue, [], "Use the legacy pass manager in LLVM">, + PosFlag<SetTrue, [], "Use the legacy pass manager in LLVM (deprecated, to be removed in a future release)">, NegFlag<SetFalse, [], "Use the new pass manager in LLVM">, BothFlags<[CC1Option]>>, Group<f_clang_Group>; def fexperimental_new_pass_manager : Flag<["-"], "fexperimental-new-pass-manager">, @@ -1985,16 +2029,18 @@ def fapple_link_rtlib : Flag<["-"], "fapple-link-rtlib">, Group<f_Group>, HelpText<"Force linking the clang builtins runtime library">; def flto_EQ : Joined<["-"], "flto=">, Flags<[CoreOption, CC1Option]>, Group<f_Group>, HelpText<"Set LTO mode to either 'full' or 'thin'">, Values<"thin,full">; -def flto_EQ_jobserver : Flag<["-"], "flto=jobserver">, Group<f_Group>; -def flto_EQ_auto : Flag<["-"], "flto=auto">, Group<f_Group>; +def flto_EQ_jobserver : Flag<["-"], "flto=jobserver">, Group<f_Group>, + Alias<flto_EQ>, AliasArgs<["full"]>, HelpText<"Enable LTO in 'full' mode">; +def flto_EQ_auto : Flag<["-"], "flto=auto">, Group<f_Group>, + Alias<flto_EQ>, AliasArgs<["full"]>, HelpText<"Enable LTO in 'full' mode">; def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group<f_Group>, - HelpText<"Enable LTO in 'full' mode">; + Alias<flto_EQ>, AliasArgs<["full"]>, HelpText<"Enable LTO in 'full' mode">; def fno_lto : Flag<["-"], "fno-lto">, Flags<[CoreOption, CC1Option]>, Group<f_Group>, HelpText<"Disable LTO mode (default)">; def foffload_lto_EQ : Joined<["-"], "foffload-lto=">, Flags<[CoreOption]>, Group<f_Group>, HelpText<"Set LTO mode to either 'full' or 'thin' for offload compilation">, Values<"thin,full">; def foffload_lto : Flag<["-"], "foffload-lto">, Flags<[CoreOption]>, Group<f_Group>, - HelpText<"Enable LTO in 'full' mode for offload compilation">; + Alias<foffload_lto_EQ>, AliasArgs<["full"]>, HelpText<"Enable LTO in 'full' mode for offload compilation">; def fno_offload_lto : Flag<["-"], "fno-offload-lto">, Flags<[CoreOption]>, Group<f_Group>, HelpText<"Disable LTO mode (default) for offload compilation">; def flto_jobs_EQ : Joined<["-"], "flto-jobs=">, @@ -2130,9 +2176,9 @@ defm pch_instantiate_templates : BoolFOption<"pch-instantiate-templates", LangOpts<"PCHInstantiateTemplates">, DefaultFalse, PosFlag<SetTrue, [], "Instantiate templates already while building a PCH">, NegFlag<SetFalse>, BothFlags<[CC1Option, CoreOption]>>; -defm pch_codegen: OptInFFlag<"pch-codegen", "Generate ", "Do not generate ", +defm pch_codegen: OptInCC1FFlag<"pch-codegen", "Generate ", "Do not generate ", "code for uses of this PCH that assumes an explicit object file will be built for the PCH">; -defm pch_debuginfo: OptInFFlag<"pch-debuginfo", "Generate ", "Do not generate ", +defm pch_debuginfo: OptInCC1FFlag<"pch-debuginfo", "Generate ", "Do not generate ", "debug info for types in an object file built from this PCH and do not generate them elsewhere">; def fimplicit_module_maps : Flag <["-"], "fimplicit-module-maps">, Group<f_Group>, @@ -2143,7 +2189,7 @@ def fmodules_ts : Flag <["-"], "fmodules-ts">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Enable support for the C++ Modules TS">, MarshallingInfoFlag<LangOpts<"ModulesTS">>; defm modules : BoolFOption<"modules", - LangOpts<"Modules">, Default<!strconcat(fmodules_ts.KeyPath, "||", cpp_modules.KeyPath)>, + LangOpts<"Modules">, Default<!strconcat(fmodules_ts.KeyPath, "||", fcxx_modules.KeyPath)>, PosFlag<SetTrue, [CC1Option], "Enable the 'modules' language feature">, NegFlag<SetFalse>, BothFlags<[NoXarchOption, CoreOption]>>; def fmodule_maps : Flag <["-"], "fmodule-maps">, Flags<[CoreOption]>, Alias<fimplicit_module_maps>; @@ -2202,8 +2248,6 @@ def fno_diagnostics_color : Flag<["-"], "fno-diagnostics-color">, Group<f_Group> Flags<[CoreOption, NoXarchOption]>; def fno_common : Flag<["-"], "fno-common">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Compile common globals like normal definitions">; -def fno_cxx_modules : Flag <["-"], "fno-cxx-modules">, Group<f_Group>, - Flags<[NoXarchOption]>; defm digraphs : BoolFOption<"digraphs", LangOpts<"Digraphs">, Default<std#".hasDigraphs()">, PosFlag<SetTrue, [], "Enable alternative token representations '<:', ':>', '<%', '%>', '%:', '%:%:' (default)">, @@ -2338,12 +2382,23 @@ def fobjc_disable_direct_methods_for_testing : Group<f_Group>, Flags<[CC1Option]>, HelpText<"Ignore attribute objc_direct so that direct methods can be tested">, MarshallingInfoFlag<LangOpts<"ObjCDisableDirectMethodsForTesting">>; +defm objc_avoid_heapify_local_blocks : BoolFOption<"objc-avoid-heapify-local-blocks", + CodeGenOpts<"ObjCAvoidHeapifyLocalBlocks">, DefaultFalse, + PosFlag<SetTrue, [], "Try">, + NegFlag<SetFalse, [], "Don't try">, + BothFlags<[CC1Option, NoDriverOption], " to avoid heapifying local blocks">>; 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]>; +defm openmp_extensions: BoolFOption<"openmp-extensions", + LangOpts<"OpenMPExtensions">, DefaultTrue, + PosFlag<SetTrue, [CC1Option, NoArgumentUnused], + "Enable all Clang extensions for OpenMP directives and clauses">, + NegFlag<SetFalse, [CC1Option, NoArgumentUnused], + "Disable all Clang extensions for OpenMP directives and clauses">>; def fopenmp_EQ : Joined<["-"], "fopenmp=">, Group<f_Group>; def fopenmp_use_tls : Flag<["-"], "fopenmp-use-tls">, Group<f_Group>, Flags<[NoArgumentUnused, HelpHidden]>; @@ -2374,6 +2429,18 @@ def fopenmp_cuda_blocks_per_sm_EQ : Joined<["-"], "fopenmp-cuda-blocks-per-sm="> Flags<[CC1Option, NoArgumentUnused, HelpHidden]>; def fopenmp_cuda_teams_reduction_recs_num_EQ : Joined<["-"], "fopenmp-cuda-teams-reduction-recs-num=">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>; +def fopenmp_target_debug : Flag<["-"], "fopenmp-target-debug">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused]>, + 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">, + Group<f_Group>, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>; +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">, + Group<f_Group>, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>; +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, PosFlag<SetTrue, [CC1Option], "Use the new bitcode library for OpenMP offloading">, @@ -2495,7 +2562,7 @@ defm signed_char : BoolFOption<"signed-char", ShouldParseIf<!strconcat("!", open_cl.KeyPath)>; defm split_stack : BoolFOption<"split-stack", CodeGenOpts<"EnableSegmentedStacks">, DefaultFalse, - NegFlag<SetFalse, [], "Wouldn't use segmented stack">, + NegFlag<SetFalse, [], "Wouldn't use segmented stack">, PosFlag<SetTrue, [CC1Option], "Use segmented stack">>; def fstack_protector_all : Flag<["-"], "fstack-protector-all">, Group<f_Group>, HelpText<"Enable stack protectors for all functions">; @@ -2526,7 +2593,7 @@ def ftrivial_auto_var_init : Joined<["-"], "ftrivial-auto-var-init=">, Group<f_G NormalizedValues<["Uninitialized", "Zero", "Pattern"]>, MarshallingInfoEnum<LangOpts<"TrivialAutoVarInit">, "Uninitialized">; def enable_trivial_var_init_zero : Flag<["-"], "enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang">, - Flags<[CC1Option, CoreOption]>, + Flags<[CC1Option, CoreOption, NoArgumentUnused]>, HelpText<"Trivial automatic variable initialization to zero is only here for benchmarks, it'll eventually be removed, and I'm OK with that because I'm only using it to benchmark">; def ftrivial_auto_var_init_stop_after : Joined<["-"], "ftrivial-auto-var-init-stop-after=">, Group<f_Group>, Flags<[CC1Option, CoreOption]>, HelpText<"Stop initializing trivial automatic stack variables after the specified number of instances">, @@ -2683,10 +2750,10 @@ def fverbose_asm : Flag<["-"], "fverbose-asm">, Group<f_Group>, def dA : Flag<["-"], "dA">, Alias<fverbose_asm>; defm visibility_from_dllstorageclass : BoolFOption<"visibility-from-dllstorageclass", LangOpts<"VisibilityFromDLLStorageClass">, DefaultFalse, - PosFlag<SetTrue, [CC1Option], "Set the visiblity of symbols in the generated code from their DLL storage class">, + PosFlag<SetTrue, [CC1Option], "Set the visibility of symbols in the generated code from their DLL storage class">, NegFlag<SetFalse>>; def fvisibility_dllexport_EQ : Joined<["-"], "fvisibility-dllexport=">, Group<f_Group>, Flags<[CC1Option]>, - HelpText<"The visibility for dllexport defintions [-fvisibility-from-dllstorageclass]">, + HelpText<"The visibility for dllexport definitions [-fvisibility-from-dllstorageclass]">, MarshallingInfoVisibility<LangOpts<"DLLExportVisibility">, "DefaultVisibility">, ShouldParseIf<fvisibility_from_dllstorageclass.KeyPath>; def fvisibility_nodllstorageclass_EQ : Joined<["-"], "fvisibility-nodllstorageclass=">, Group<f_Group>, Flags<[CC1Option]>, @@ -2719,6 +2786,10 @@ def fvisibility_ms_compat : Flag<["-"], "fvisibility-ms-compat">, Group<f_Group> def fvisibility_global_new_delete_hidden : Flag<["-"], "fvisibility-global-new-delete-hidden">, Group<f_Group>, HelpText<"Give global C++ operator new and delete declarations hidden visibility">, Flags<[CC1Option]>, MarshallingInfoFlag<LangOpts<"GlobalAllocationFunctionVisibilityHidden">>; +def fnew_infallible : Flag<["-"], "fnew-infallible">, Group<f_Group>, + HelpText<"Treats throwing global C++ operator new as always returning valid memory " + "(annotates with __attribute__((returns_nonnull)) and throw()). This is detectable in source.">, + Flags<[CC1Option]>, MarshallingInfoFlag<LangOpts<"NewInfallible">>; defm whole_program_vtables : BoolFOption<"whole-program-vtables", CodeGenOpts<"WholeProgramVTables">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Enables whole-program vtable optimization. Requires -flto">, @@ -2910,6 +2981,14 @@ def gsplit_dwarf_EQ : Joined<["-"], "gsplit-dwarf=">, Group<g_flags_Group>, HelpText<"Set DWARF fission mode to either 'split' or 'single'">, Values<"split,single">; def gno_split_dwarf : Flag<["-"], "gno-split-dwarf">, Group<g_flags_Group>; +def gsimple_template_names : Flag<["-"], "gsimple-template-names">, Group<g_flags_Group>; +def gsimple_template_names_EQ + : Joined<["-"], "gsimple-template-names=">, + HelpText<"Use simple template names in DWARF, or include the full " + "template name with a modified prefix for validation">, + Values<"simple,mangled">, Flags<[CC1Option, NoDriverOption]>; +def gno_simple_template_names : Flag<["-"], "gno-simple-template-names">, + Group<g_flags_Group>; def ggnu_pubnames : Flag<["-"], "ggnu-pubnames">, Group<g_flags_Group>, Flags<[CC1Option]>; def gno_gnu_pubnames : Flag<["-"], "gno-gnu-pubnames">, Group<g_flags_Group>; def gpubnames : Flag<["-"], "gpubnames">, Group<g_flags_Group>, Flags<[CC1Option]>; @@ -3052,6 +3131,10 @@ def mwatchos_simulator_version_min_EQ : Joined<["-"], "mwatchos-simulator-versio def mwatchsimulator_version_min_EQ : Joined<["-"], "mwatchsimulator-version-min=">, Alias<mwatchos_simulator_version_min_EQ>; def march_EQ : Joined<["-"], "march=">, Group<m_Group>, Flags<[CoreOption]>; def masm_EQ : Joined<["-"], "masm=">, Group<m_Group>, Flags<[NoXarchOption]>; +def inline_asm_EQ : Joined<["-"], "inline-asm=">, Group<m_Group>, Flags<[CC1Option]>, + Values<"att,intel">, + NormalizedValuesScope<"CodeGenOptions">, NormalizedValues<["IAD_ATT", "IAD_Intel"]>, + MarshallingInfoEnum<CodeGenOpts<"InlineAsmDialect">, "IAD_ATT">; def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group<m_Group>, Flags<[CC1Option]>, MarshallingInfoString<TargetOpts<"CodeModel">, [{"default"}]>; def mtls_size_EQ : Joined<["-"], "mtls-size=">, Group<m_Group>, Flags<[NoXarchOption, CC1Option]>, @@ -3097,6 +3180,9 @@ def mlinker_version_EQ : Joined<["-"], "mlinker-version=">, def mllvm : Separate<["-"], "mllvm">, Flags<[CC1Option,CC1AsOption,CoreOption]>, HelpText<"Additional arguments to forward to LLVM's option processing">, MarshallingInfoStringVector<FrontendOpts<"LLVMArgs">>; +def ffuchsia_api_level_EQ : Joined<["-"], "ffuchsia-api-level=">, + Group<m_Group>, Flags<[CC1Option]>, HelpText<"Set Fuchsia API level">, + MarshallingInfoInt<LangOpts<"FuchsiaAPILevel">>; def mmacosx_version_min_EQ : Joined<["-"], "mmacosx-version-min=">, Group<m_Group>, HelpText<"Set Mac OS X deployment target">; def mmacos_version_min_EQ : Joined<["-"], "mmacos-version-min=">, @@ -3110,6 +3196,10 @@ def mno_outline : Flag<["-"], "mno-outline">, Group<f_clang_Group>, Flags<[CC1Op HelpText<"Disable function outlining (AArch64 only)">; def mno_ms_bitfields : Flag<["-"], "mno-ms-bitfields">, Group<m_Group>, HelpText<"Do not set the default structure layout to be compatible with the Microsoft compiler standard">; +def mskip_rax_setup : Flag<["-"], "mskip-rax-setup">, Group<m_Group>, Flags<[CC1Option]>, + HelpText<"Skip setting up RAX register when passing variable arguments (x86 only)">, + MarshallingInfoFlag<CodeGenOpts<"SkipRaxSetup">>; +def mno_skip_rax_setup : Flag<["-"], "mno-skip-rax-setup">, Group<m_Group>, Flags<[CC1Option]>; def mstackrealign : Flag<["-"], "mstackrealign">, Group<m_Group>, Flags<[CC1Option]>, HelpText<"Force realign the stack at entry to every function">, MarshallingInfoFlag<CodeGenOpts<"StackRealignment">>; @@ -3133,6 +3223,8 @@ def meabi : Separate<["-"], "meabi">, Group<m_Group>, Flags<[CC1Option]>, MarshallingInfoEnum<TargetOpts<"EABIVersion">, "Default">, NormalizedValuesScope<"llvm::EABI">, NormalizedValues<["Default", "EABI4", "EABI5", "GNU"]>; +def mtargetos_EQ : Joined<["-"], "mtargetos=">, Group<m_Group>, + HelpText<"Set the deployment target to be the specified OS and OS version">; def mno_constant_cfstrings : Flag<["-"], "mno-constant-cfstrings">, Group<m_Group>; def mno_global_merge : Flag<["-"], "mno-global-merge">, Group<m_Group>, Flags<[CC1Option]>, @@ -3227,6 +3319,12 @@ defm aapcs_bitfield_width : BoolOption<"f", "aapcs-bitfield-width", def mgeneral_regs_only : Flag<["-"], "mgeneral-regs-only">, Group<m_Group>, HelpText<"Generate code which only uses the general purpose registers (AArch64/x86 only)">; +def mfix_cmse_cve_2021_35465 : Flag<["-"], "mfix-cmse-cve-2021-35465">, + Group<m_arm_Features_Group>, + HelpText<"Work around VLLDM erratum CVE-2021-35465 (ARM only)">; +def mno_fix_cmse_cve_2021_35465 : Flag<["-"], "mno-fix-cmse-cve-2021-35465">, + Group<m_arm_Features_Group>, + HelpText<"Don't work around VLLDM erratum CVE-2021-35465 (ARM only)">; def mfix_cortex_a53_835769 : Flag<["-"], "mfix-cortex-a53-835769">, Group<m_aarch64_Features_Group>, HelpText<"Workaround Cortex-A53 erratum 835769 (AArch64 only)">; @@ -3244,13 +3342,20 @@ foreach i = {8-15,18} in def fcall_saved_x#i : Flag<["-"], "fcall-saved-x"#i>, Group<m_aarch64_Features_Group>, HelpText<"Make the x"#i#" register call-saved (AArch64 only)">; -def msve_vector_bits_EQ : Joined<["-"], "msve-vector-bits=">, - Group<m_aarch64_Features_Group>, Flags<[NoXarchOption,CC1Option]>, +def msve_vector_bits_EQ : Joined<["-"], "msve-vector-bits=">, Group<m_aarch64_Features_Group>, HelpText<"Specify the size in bits of an SVE vector register. Defaults to the" - " vector length agnostic value of \"scalable\". (AArch64 only)">, - Values<"128,256,512,1024,2048,scalable">, - NormalizedValues<["128", "256", "512", "1024", "2048", "0"]>, - MarshallingInfoEnum<LangOpts<"ArmSveVectorBits">, "0">; + " vector length agnostic value of \"scalable\". (AArch64 only)">; + +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)">, + MarshallingInfoInt<LangOpts<"VScaleMin">>; +def mvscale_max_EQ : Joined<["-"], "mvscale-max=">, + Group<m_aarch64_Features_Group>, Flags<[NoXarchOption,CC1Option]>, + HelpText<"Specify the vscale maximum. Defaults to the" + " vector length agnostic value of \"0\". (AArch64 only)">, + MarshallingInfoInt<LangOpts<"VScaleMax">>; def msign_return_address_EQ : Joined<["-"], "msign-return-address=">, Flags<[CC1Option]>, Group<m_Group>, Values<"none,all,non-leaf">, @@ -3263,6 +3368,8 @@ def mharden_sls_EQ : Joined<["-"], "mharden-sls=">, def msimd128 : Flag<["-"], "msimd128">, Group<m_wasm_Features_Group>; def mno_simd128 : Flag<["-"], "mno-simd128">, Group<m_wasm_Features_Group>; +def mrelaxed_simd : Flag<["-"], "mrelaxed-simd">, Group<m_wasm_Features_Group>; +def mno_relaxed_simd : Flag<["-"], "mno-relaxed-simd">, Group<m_wasm_Features_Group>; def mnontrapping_fptoint : Flag<["-"], "mnontrapping-fptoint">, Group<m_wasm_Features_Group>; def mno_nontrapping_fptoint : Flag<["-"], "mno-nontrapping-fptoint">, Group<m_wasm_Features_Group>; def msign_ext : Flag<["-"], "msign-ext">, Group<m_wasm_Features_Group>; @@ -3635,8 +3742,10 @@ def multi__module : Flag<["-"], "multi_module">; def multiply__defined__unused : Separate<["-"], "multiply_defined_unused">; def multiply__defined : Separate<["-"], "multiply_defined">; def mwarn_nonportable_cfstrings : Flag<["-"], "mwarn-nonportable-cfstrings">, Group<m_Group>; +def canonical_prefixes : Flag<["-"], "canonical-prefixes">, Flags<[HelpHidden, CoreOption]>, + HelpText<"Use absolute paths for invoking subcommands (default)">; def no_canonical_prefixes : Flag<["-"], "no-canonical-prefixes">, Flags<[HelpHidden, CoreOption]>, - HelpText<"Use relative instead of canonical paths">; + HelpText<"Use relative paths for invoking subcommands">; def no_cpp_precomp : Flag<["-"], "no-cpp-precomp">, Group<clang_ignored_f_Group>; def no_integrated_cpp : Flag<["-", "--"], "no-integrated-cpp">, Flags<[NoXarchOption]>; def no_pedantic : Flag<["-", "--"], "no-pedantic">, Group<pedantic_Group>; @@ -4075,6 +4184,7 @@ def mx87 : Flag<["-"], "mx87">, Group<m_x86_Features_Group>; def mno_x87 : Flag<["-"], "mno-x87">, Group<m_x86_Features_Group>; def m80387 : Flag<["-"], "m80387">, Alias<mx87>; def mno_80387 : Flag<["-"], "mno-80387">, Alias<mno_x87>; +def mno_fp_ret_in_387 : Flag<["-"], "mno-fp-ret-in-387">, Alias<mno_x87>; def mmmx : Flag<["-"], "mmmx">, Group<m_x86_Features_Group>; def mno_mmx : Flag<["-"], "mno-mmx">, Group<m_x86_Features_Group>; def m3dnow : Flag<["-"], "m3dnow">, Group<m_x86_Features_Group>; @@ -4124,6 +4234,8 @@ def mavx512dq : Flag<["-"], "mavx512dq">, Group<m_x86_Features_Group>; def mno_avx512dq : Flag<["-"], "mno-avx512dq">, Group<m_x86_Features_Group>; def mavx512er : Flag<["-"], "mavx512er">, Group<m_x86_Features_Group>; def mno_avx512er : Flag<["-"], "mno-avx512er">, Group<m_x86_Features_Group>; +def mavx512fp16 : Flag<["-"], "mavx512fp16">, Group<m_x86_Features_Group>; +def mno_avx512fp16 : Flag<["-"], "mno-avx512fp16">, Group<m_x86_Features_Group>; def mavx512ifma : Flag<["-"], "mavx512ifma">, Group<m_x86_Features_Group>; def mno_avx512ifma : Flag<["-"], "mno-avx512ifma">, Group<m_x86_Features_Group>; def mavx512pf : Flag<["-"], "mavx512pf">, Group<m_x86_Features_Group>; @@ -4160,6 +4272,8 @@ def mwbnoinvd : Flag<["-"], "mwbnoinvd">, Group<m_x86_Features_Group>; def mno_wbnoinvd : Flag<["-"], "mno-wbnoinvd">, Group<m_x86_Features_Group>; def mclzero : Flag<["-"], "mclzero">, Group<m_x86_Features_Group>; def mno_clzero : Flag<["-"], "mno-clzero">, Group<m_x86_Features_Group>; +def mcrc32 : Flag<["-"], "mcrc32">, Group<m_x86_Features_Group>; +def mno_crc32 : Flag<["-"], "mno-crc32">, Group<m_x86_Features_Group>; def mcx16 : Flag<["-"], "mcx16">, Group<m_x86_Features_Group>; def mno_cx16 : Flag<["-"], "mno-cx16">, Group<m_x86_Features_Group>; def menqcmd : Flag<["-"], "menqcmd">, Group<m_x86_Features_Group>; @@ -4258,7 +4372,6 @@ def mno_vzeroupper : Flag<["-"], "mno-vzeroupper">, Group<m_x86_Features_Group>; // These are legacy user-facing driver-level option spellings. They are always // aliases for options that are spelled using the more common Unix / GNU flag // style of double-dash and equals-joined flags. -def gcc_toolchain_legacy_spelling : Separate<["-"], "gcc-toolchain">, Alias<gcc_toolchain>; def target_legacy_spelling : Separate<["-"], "target">, Alias<target>; // Special internal option to handle -Xlinker --no-demangle. @@ -4298,7 +4411,6 @@ def ld_path_EQ : Joined<["--"], "ld-path=">, Group<Link_Group>; defm align_labels : BooleanFFlag<"align-labels">, Group<clang_ignored_gcc_optimization_f_Group>; def falign_labels_EQ : Joined<["-"], "falign-labels=">, Group<clang_ignored_gcc_optimization_f_Group>; defm align_loops : BooleanFFlag<"align-loops">, Group<clang_ignored_gcc_optimization_f_Group>; -def falign_loops_EQ : Joined<["-"], "falign-loops=">, Group<clang_ignored_gcc_optimization_f_Group>; defm align_jumps : BooleanFFlag<"align-jumps">, Group<clang_ignored_gcc_optimization_f_Group>; def falign_jumps_EQ : Joined<["-"], "falign-jumps=">, Group<clang_ignored_gcc_optimization_f_Group>; @@ -4492,26 +4604,18 @@ def fdefault_real_8 : Flag<["-"],"fdefault-real-8">, Group<f_Group>, HelpText<"Set the default real kind to an 8 byte wide type">; def flarge_sizes : Flag<["-"],"flarge-sizes">, Group<f_Group>, HelpText<"Use INTEGER(KIND=8) for the result type in size-related intrinsics">; -def fbackslash : Flag<["-"], "fbackslash">, Group<f_Group>, - HelpText<"Specify that backslash in string introduces an escape character">, - DocBrief<[{Change the interpretation of backslashes in string literals from -a single backslash character to "C-style" escape characters.}]>; -def fno_backslash : Flag<["-"], "fno-backslash">, Group<f_Group>; -def fxor_operator : Flag<["-"], "fxor-operator">, Group<f_Group>, - HelpText<"Enable .XOR. as a synonym of .NEQV.">; -def fno_xor_operator : Flag<["-"], "fno-xor-operator">, Group<f_Group>; -def flogical_abbreviations : Flag<["-"], "flogical-abbreviations">, Group<f_Group>, - HelpText<"Enable logical abbreviations">; -def fno_logical_abbreviations : Flag<["-"], "fno-logical-abbreviations">, Group<f_Group>; -def fimplicit_none : Flag<["-"], "fimplicit-none">, Group<f_Group>, - HelpText<"No implicit typing allowed unless overridden by IMPLICIT statements">; -def fno_implicit_none : Flag<["-"], "fno-implicit-none">, Group<f_Group>; + def falternative_parameter_statement : Flag<["-"], "falternative-parameter-statement">, Group<f_Group>, HelpText<"Enable the old style PARAMETER statement">; def fintrinsic_modules_path : Separate<["-"], "fintrinsic-modules-path">, Group<f_Group>, MetaVarName<"<dir>">, HelpText<"Specify where to find the compiled intrinsic modules">, - DocBrief<[{This option specifies the location of pre-compiled intrinsic modules, + DocBrief<[{This option specifies the location of pre-compiled intrinsic modules, if they are not in the default location expected by the compiler.}]>; + +defm backslash : OptInFC1FFlag<"backslash", "Specify that backslash in string introduces an escape character">; +defm xor_operator : OptInFC1FFlag<"xor-operator", "Enable .XOR. as a synonym of .NEQV.">; +defm logical_abbreviations : OptInFC1FFlag<"logical-abbreviations", "Enable logical abbreviations">; +defm implicit_none : OptInFC1FFlag<"implicit-none", "No implicit typing allowed unless overridden by IMPLICIT statements">; } def J : JoinedOrSeparate<["-"], "J">, @@ -4559,18 +4663,16 @@ def fdebug_measure_parse_tree : Flag<["-"], "fdebug-measure-parse-tree">, Group< HelpText<"Measure the parse tree">; def fdebug_pre_fir_tree : Flag<["-"], "fdebug-pre-fir-tree">, Group<Action_Group>, HelpText<"Dump the pre-FIR tree">; -def fdebug_module_writer : Flag<["-"],"fdebug-module-writer">, +def fdebug_module_writer : Flag<["-"],"fdebug-module-writer">, HelpText<"Enable debug messages while writing module files">; def fget_symbols_sources : Flag<["-"], "fget-symbols-sources">, Group<Action_Group>, HelpText<"Dump symbols and their source code locations">; def module_suffix : Separate<["-"], "module-suffix">, Group<f_Group>, MetaVarName<"<suffix>">, HelpText<"Use <suffix> as the suffix for module files (the default value is `.mod`)">; -def fanalyzed_objects_for_unparse : Flag<["-"], - "fanalyzed-objects-for-unparse">, Group<f_Group>; -def fno_analyzed_objects_for_unparse : Flag<["-"], - "fno-analyzed-objects-for-unparse">, Group<f_Group>, - HelpText<"Do not use the analyzed objects when unparsing">; +def fno_reformat : Flag<["-"], "fno-reformat">, Group<Preprocessor_Group>, + HelpText<"Dump the cooked character stream in -E mode">; +defm analyzed_objects_for_unparse : OptOutFC1FFlag<"analyzed-objects-for-unparse", "", "Do not use the analyzed objects when unparsing">; } @@ -4954,9 +5056,9 @@ def mregparm : Separate<["-"], "mregparm">, def msmall_data_limit : Separate<["-"], "msmall-data-limit">, HelpText<"Put global and static data smaller than the limit into a special section">, MarshallingInfoInt<CodeGenOpts<"SmallDataLimit">>; -def munwind_tables : Flag<["-"], "munwind-tables">, +def funwind_tables_EQ : Joined<["-"], "funwind-tables=">, HelpText<"Generate unwinding tables for all functions">, - MarshallingInfoFlag<CodeGenOpts<"UnwindTables">>; + MarshallingInfoInt<CodeGenOpts<"UnwindTables">>; def mconstructor_aliases : Flag<["-"], "mconstructor-aliases">, HelpText<"Emit complete constructors and destructors as aliases when possible">, MarshallingInfoFlag<CodeGenOpts<"CXXCtorDtorAliases">>; @@ -5034,6 +5136,14 @@ def fsanitize_coverage_stack_depth : Flag<["-"], "fsanitize-coverage-stack-depth">, HelpText<"Enable max stack depth tracing">, MarshallingInfoFlag<CodeGenOpts<"SanitizeCoverageStackDepth">>; +def fsanitize_coverage_trace_loads + : Flag<["-"], "fsanitize-coverage-trace-loads">, + HelpText<"Enable tracing of loads">, + MarshallingInfoFlag<CodeGenOpts<"SanitizeCoverageTraceLoads">>; +def fsanitize_coverage_trace_stores + : Flag<["-"], "fsanitize-coverage-trace-stores">, + HelpText<"Enable tracing of stores">, + MarshallingInfoFlag<CodeGenOpts<"SanitizeCoverageTraceStores">>; def fpatchable_function_entry_offset_EQ : Joined<["-"], "fpatchable-function-entry-offset=">, MetaVarName<"<M>">, HelpText<"Generate M NOPs before function entry">, @@ -5228,16 +5338,19 @@ def code_completion_with_fixits : Flag<["-"], "code-completion-with-fixits">, def disable_free : Flag<["-"], "disable-free">, HelpText<"Disable freeing of memory on exit">, MarshallingInfoFlag<FrontendOpts<"DisableFree">>; +defm clear_ast_before_backend : BoolOption<"", + "clear-ast-before-backend", + CodeGenOpts<"ClearASTBeforeBackend">, + DefaultFalse, + PosFlag<SetTrue, [], "Clear">, + NegFlag<SetFalse, [], "Don't clear">, + BothFlags<[], " the Clang AST before running backend code generation">>; def enable_noundef_analysis : Flag<["-"], "enable-noundef-analysis">, Group<f_Group>, HelpText<"Enable analyzing function argument and return types for mandatory definedness">, MarshallingInfoFlag<CodeGenOpts<"EnableNoundefAttrs">>; def discard_value_names : Flag<["-"], "discard-value-names">, HelpText<"Discard value names in LLVM IR">, MarshallingInfoFlag<CodeGenOpts<"DiscardValueNames">>; -def load : Separate<["-"], "load">, MetaVarName<"<dsopath>">, - HelpText<"Load the named plugin (dynamic shared object)">; -def plugin : Separate<["-"], "plugin">, MetaVarName<"<name>">, - HelpText<"Use the named plugin action instead of the default action (use \"help\" to list available options)">; def plugin_arg : JoinedAndSeparate<["-"], "plugin-arg-">, MetaVarName<"<name> <arg>">, HelpText<"Pass <arg> to plugin <name>">; @@ -5250,6 +5363,8 @@ def ast_dump_filter : Separate<["-"], "ast-dump-filter">, " nodes having a certain substring in a qualified name. Use" " -ast-list to list all filterable declaration node names.">, MarshallingInfoString<FrontendOpts<"ASTDumpFilter">>; +def ast_dump_filter_EQ : Joined<["-"], "ast-dump-filter=">, + Alias<ast_dump_filter>; def fno_modules_global_index : Flag<["-"], "fno-modules-global-index">, HelpText<"Do not automatically generate or update the global module index">, MarshallingInfoNegativeFlag<FrontendOpts<"UseGlobalModuleIndex">>; @@ -5273,6 +5388,12 @@ def fmodules_embed_all_files : Joined<["-"], "fmodules-embed-all-files">, HelpText<"Embed the contents of all files read by this compilation into " "the produced module file.">, MarshallingInfoFlag<FrontendOpts<"ModulesEmbedAllFiles">>; +defm fimplicit_modules_use_lock : BoolOption<"f", "implicit-modules-use-lock", + FrontendOpts<"BuildingImplicitModuleUsesLock">, DefaultTrue, + NegFlag<SetFalse>, + PosFlag<SetTrue, [], + "Use filesystem locks for implicit modules builds to avoid " + "duplicating work in competing clang invocations.">>; // FIXME: We only need this in C++ modules / Modules TS if we might textually // enter a different module (eg, when building a header unit). def fmodules_local_submodule_visibility : @@ -5280,7 +5401,7 @@ def fmodules_local_submodule_visibility : HelpText<"Enforce name visibility rules across submodules of the same " "top-level module.">, MarshallingInfoFlag<LangOpts<"ModulesLocalVisibility">>, - ImpliedByAnyOf<[fmodules_ts.KeyPath, cpp_modules.KeyPath]>; + ImpliedByAnyOf<[fmodules_ts.KeyPath, fcxx_modules.KeyPath]>; def fmodules_codegen : Flag<["-"], "fmodules-codegen">, HelpText<"Generate code for uses of this module that assumes an explicit " @@ -5804,6 +5925,12 @@ def init_only : Flag<["-"], "init-only">, HelpText<"Only execute frontend initialization">; } // let Group = Action_Group + +def load : Separate<["-"], "load">, MetaVarName<"<dsopath>">, + HelpText<"Load the named plugin (dynamic shared object)">; +def plugin : Separate<["-"], "plugin">, MetaVarName<"<name>">, + HelpText<"Use the named plugin action instead of the default action (use \"help\" to list available options)">; + } // let Flags = [CC1Option, FC1Option, NoDriverOption] //===----------------------------------------------------------------------===// @@ -6027,16 +6154,7 @@ def _SLASH_WX_ : CLFlag<"WX-">, HelpText<"Do not treat warnings as errors (default)">, Alias<W_Joined>, AliasArgs<["no-error"]>; def _SLASH_w_flag : CLFlag<"w">, HelpText<"Disable all warnings">, Alias<w>; -def _SLASH_wd4005 : CLFlag<"wd4005">, Alias<W_Joined>, - AliasArgs<["no-macro-redefined"]>; -def _SLASH_wd4018 : CLFlag<"wd4018">, Alias<W_Joined>, - AliasArgs<["no-sign-compare"]>; -def _SLASH_wd4100 : CLFlag<"wd4100">, Alias<W_Joined>, - AliasArgs<["no-unused-parameter"]>; -def _SLASH_wd4910 : CLFlag<"wd4910">, Alias<W_Joined>, - AliasArgs<["no-dllexport-explicit-instantiation-decl"]>; -def _SLASH_wd4996 : CLFlag<"wd4996">, Alias<W_Joined>, - AliasArgs<["no-deprecated-declarations"]>; +def _SLASH_wd : CLCompileJoined<"wd">; def _SLASH_vd : CLJoined<"vd">, HelpText<"Control vtordisp placement">, Alias<vtordisp_mode_EQ>; def _SLASH_X : CLFlag<"X">, @@ -6172,6 +6290,8 @@ def _SLASH_TC : CLCompileFlag<"TC">, HelpText<"Treat all source files as C">; def _SLASH_Tp : CLCompileJoinedOrSeparate<"Tp">, HelpText<"Treat <file> as C++ source file">, MetaVarName<"<file>">; def _SLASH_TP : CLCompileFlag<"TP">, HelpText<"Treat all source files as C++">; +def _SLASH_diasdkdir : CLJoinedOrSeparate<"diasdkdir">, + HelpText<"Path to the DIA SDK">, MetaVarName<"<dir>">; def _SLASH_vctoolsdir : CLJoinedOrSeparate<"vctoolsdir">, HelpText<"Path to the VCToolChain">, MetaVarName<"<dir>">; def _SLASH_vctoolsversion : CLJoinedOrSeparate<"vctoolsversion">, @@ -6181,7 +6301,7 @@ def _SLASH_winsdkdir : CLJoinedOrSeparate<"winsdkdir">, def _SLASH_winsdkversion : CLJoinedOrSeparate<"winsdkversion">, HelpText<"Full version of the Windows SDK, defaults to newest found">; def _SLASH_winsysroot : CLJoinedOrSeparate<"winsysroot">, - HelpText<"Same as /vctoolsdir <dir>/VC/Tools/MSVC/<vctoolsversion> /winsdkdir <dir>/Windows Kits/10">, + HelpText<"Same as \"/diasdkdir <dir>/DIA SDK\" /vctoolsdir <dir>/VC/Tools/MSVC/<vctoolsversion> \"/winsdkdir <dir>/Windows Kits/10\"">, MetaVarName<"<dir>">; def _SLASH_volatile_iso : Option<["/", "-"], "volatile:iso", KIND_FLAG>, Group<_SLASH_volatile_Group>, Flags<[CLOption, NoXarchOption]>, diff --git a/contrib/llvm-project/clang/include/clang/Driver/Phases.h b/contrib/llvm-project/clang/include/clang/Driver/Phases.h index ce914dd70514..9003c5857351 100644 --- a/contrib/llvm-project/clang/include/clang/Driver/Phases.h +++ b/contrib/llvm-project/clang/include/clang/Driver/Phases.h @@ -22,11 +22,10 @@ namespace phases { Assemble, Link, IfsMerge, - LastPhase = IfsMerge, }; enum { - MaxNumberOfPhases = LastPhase + 1 + MaxNumberOfPhases = IfsMerge + 1 }; const char *getPhaseName(ID Id); diff --git a/contrib/llvm-project/clang/include/clang/Driver/SanitizerArgs.h b/contrib/llvm-project/clang/include/clang/Driver/SanitizerArgs.h index e9e329e7cb53..84bb324775d1 100644 --- a/contrib/llvm-project/clang/include/clang/Driver/SanitizerArgs.h +++ b/contrib/llvm-project/clang/include/clang/Driver/SanitizerArgs.h @@ -65,7 +65,8 @@ class SanitizerArgs { public: /// Parses the sanitizer arguments from an argument list. - SanitizerArgs(const ToolChain &TC, const llvm::opt::ArgList &Args); + SanitizerArgs(const ToolChain &TC, const llvm::opt::ArgList &Args, + bool DiagnoseErrors = true); bool needsSharedRt() const { return SharedRuntime; } diff --git a/contrib/llvm-project/clang/include/clang/Driver/ToolChain.h b/contrib/llvm-project/clang/include/clang/Driver/ToolChain.h index 882ae40086ce..dad861d586cb 100644 --- a/contrib/llvm-project/clang/include/clang/Driver/ToolChain.h +++ b/contrib/llvm-project/clang/include/clang/Driver/ToolChain.h @@ -113,6 +113,13 @@ public: RM_Disabled, }; + struct BitCodeLibraryInfo { + std::string Path; + bool ShouldInternalize; + BitCodeLibraryInfo(StringRef Path, bool ShouldInternalize = true) + : Path(Path), ShouldInternalize(ShouldInternalize) {} + }; + enum FileType { FT_Object, FT_Static, FT_Shared }; private: @@ -155,7 +162,7 @@ private: Tool *getOffloadBundler() const; Tool *getOffloadWrapper() const; - mutable std::unique_ptr<SanitizerArgs> SanitizerArguments; + mutable bool SanitizerArgsChecked = false; mutable std::unique_ptr<XRayArgs> XRayArguments; /// The effective clang triple for the current Job. @@ -259,7 +266,7 @@ public: const Multilib &getMultilib() const { return SelectedMultilib; } - const SanitizerArgs& getSanitizerArgs() const; + SanitizerArgs getSanitizerArgs(const llvm::opt::ArgList &JobArgs) const; const XRayArgs& getXRayArgs() const; @@ -478,15 +485,12 @@ public: virtual bool isPICDefault() const = 0; /// Test whether this toolchain defaults to PIE. - virtual bool isPIEDefault() const = 0; - - /// Test whether this toolchaind defaults to non-executable stacks. - virtual bool isNoExecStackDefault() const; + virtual bool isPIEDefault(const llvm::opt::ArgList &Args) const = 0; /// Tests whether this toolchain forces its default for PIC, PIE or /// non-PIC. If this returns true, any PIC related flags should be ignored - /// and instead the results of \c isPICDefault() and \c isPIEDefault() are - /// used exclusively. + /// and instead the results of \c isPICDefault() and \c isPIEDefault(const + /// llvm::opt::ArgList &Args) are used exclusively. virtual bool isPICDefaultForced() const = 0; /// SupportsProfiling - Does this tool chain support -pg. @@ -681,7 +685,7 @@ public: const llvm::opt::ArgList &Args) const; /// Get paths of HIP device libraries. - virtual llvm::SmallVector<std::string, 12> + virtual llvm::SmallVector<BitCodeLibraryInfo, 12> getHIPDeviceLibs(const llvm::opt::ArgList &Args) const; /// Return sanitizers which are available in this toolchain. diff --git a/contrib/llvm-project/clang/include/clang/Driver/Types.h b/contrib/llvm-project/clang/include/clang/Driver/Types.h index 6a1f57416ae5..4aecf7ee1e52 100644 --- a/contrib/llvm-project/clang/include/clang/Driver/Types.h +++ b/contrib/llvm-project/clang/include/clang/Driver/Types.h @@ -66,6 +66,14 @@ namespace types { /// isAcceptedByClang - Can clang handle this input type. bool isAcceptedByClang(ID Id); + /// isDerivedFromC - Is the input derived from C. + /// + /// That is, does the lexer follow the rules of + /// TokenConcatenation::AvoidConcat. If this is the case, the preprocessor may + /// add and remove whitespace between tokens. Used to determine whether the + /// input can be processed by -fminimize-whitespace. + bool isDerivedFromC(ID Id); + /// isCXX - Is this a "C++" input (C++ and Obj-C++ sources and headers). bool isCXX(ID Id); @@ -103,7 +111,7 @@ namespace types { /// getCompilationPhases - Get the list of compilation phases ('Phases') to be /// done for type 'Id' up until including LastPhase. llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> - getCompilationPhases(ID Id, phases::ID LastPhase = phases::LastPhase); + getCompilationPhases(ID Id, phases::ID LastPhase = phases::IfsMerge); llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> getCompilationPhases(const clang::driver::Driver &Driver, llvm::opt::DerivedArgList &DAL, ID Id); diff --git a/contrib/llvm-project/clang/include/clang/Format/Format.h b/contrib/llvm-project/clang/include/clang/Format/Format.h index c424e79a971c..d38bc6e3f0e6 100755 --- a/contrib/llvm-project/clang/include/clang/Format/Format.h +++ b/contrib/llvm-project/clang/include/clang/Format/Format.h @@ -40,7 +40,11 @@ enum class ParseError { Success = 0, Error, Unsuitable, - BinPackTrailingCommaConflict + BinPackTrailingCommaConflict, + InvalidQualifierSpecified, + DuplicateQualifierSpecified, + MissingQualifierType, + MissingQualifierOrder }; class ParseErrorCategory final : public std::error_category { public: @@ -59,6 +63,7 @@ struct FormatStyle { bool InheritsParentConfig; /// The extra indent or outdent of access modifiers, e.g. ``public:``. + /// \version 3.3 int AccessModifierOffset; /// Different styles for aligning after open brackets. @@ -88,6 +93,7 @@ struct FormatStyle { /// /// This applies to round brackets (parentheses), angle brackets and square /// brackets. + /// \version 3.8 BracketAlignmentStyle AlignAfterOpenBracket; /// Different style for aligning array initializers. @@ -117,6 +123,7 @@ struct FormatStyle { }; /// if not ``None``, when using initialization for an array of structs /// aligns the fields into columns. + /// \version 13 ArrayInitializerAlignmentStyle AlignArrayOfStructures; /// Styles for alignment of consecutive tokens. Tokens can be assignment signs @@ -201,6 +208,7 @@ struct FormatStyle { /// /* some comment */ /// #define bar(y, z) (y + z) /// \endcode + /// \version 9 AlignConsecutiveStyle AlignConsecutiveMacros; /// Style of aligning consecutive assignments. @@ -269,6 +277,7 @@ struct FormatStyle { /// /* A comment. */ /// double e = 4; /// \endcode + /// \version 3.8 AlignConsecutiveStyle AlignConsecutiveAssignments; /// Style of aligning consecutive bit field. @@ -338,6 +347,7 @@ struct FormatStyle { /// /* A comment. */ /// int ee : 3; /// \endcode + /// \version 11 AlignConsecutiveStyle AlignConsecutiveBitFields; /// Style of aligning consecutive declarations. @@ -407,6 +417,7 @@ struct FormatStyle { /// /* A comment. */ /// bool c = false; /// \endcode + /// \version 3.8 AlignConsecutiveStyle AlignConsecutiveDeclarations; /// Different styles for aligning escaped newlines. @@ -441,6 +452,7 @@ struct FormatStyle { }; /// Options for aligning backslashes in escaped newlines. + /// \version 5 EscapedNewlineAlignmentStyle AlignEscapedNewlines; /// Different styles for aligning operands. @@ -479,6 +491,7 @@ struct FormatStyle { /// If ``true``, horizontally align operands of binary and ternary /// expressions. + /// \version 12 OperandAlignmentStyle AlignOperands; /// If ``true``, aligns trailing comments. @@ -487,6 +500,7 @@ struct FormatStyle { /// int a; // My comment a vs. int a; // My comment a /// int b = 2; // comment b int b = 2; // comment about b /// \endcode + /// \version 3.7 bool AlignTrailingComments; /// \brief If a function call or braced initializer list doesn't fit on a @@ -503,22 +517,12 @@ struct FormatStyle { /// c, /// d); /// \endcode + /// \version 9 bool AllowAllArgumentsOnNextLine; - /// \brief If a constructor definition with a member initializer list doesn't - /// fit on a single line, allow putting all member initializers onto the next - /// line, if ```ConstructorInitializerAllOnOneLineOrOnePerLine``` is true. - /// Note that this parameter has no effect if - /// ```ConstructorInitializerAllOnOneLineOrOnePerLine``` is false. - /// \code - /// true: - /// MyClass::MyClass() : - /// member0(0), member1(2) {} - /// - /// false: - /// MyClass::MyClass() : - /// member0(0), - /// member1(2) {} + /// This option is **deprecated**. See ``NextLine`` of + /// ``PackConstructorInitializers``. + /// \version 9 bool AllowAllConstructorInitializersOnNextLine; /// If the function declaration doesn't fit on a line, @@ -536,6 +540,7 @@ struct FormatStyle { /// int d, /// int e); /// \endcode + /// \version 3.3 bool AllowAllParametersOfDeclarationOnNextLine; /// Allow short enums on a single line. @@ -544,12 +549,12 @@ struct FormatStyle { /// enum { A, B } myEnum; /// /// false: - /// enum - /// { + /// enum { /// A, /// B /// } myEnum; /// \endcode + /// \version 12 bool AllowShortEnumsOnASingleLine; /// Different styles for merging short blocks containing at most one @@ -582,6 +587,7 @@ struct FormatStyle { /// Dependent on the value, ``while (true) { continue; }`` can be put on a /// single line. + /// \version 11 ShortBlockStyle AllowShortBlocksOnASingleLine; /// If ``true``, short case labels will be contracted to a single line. @@ -595,6 +601,7 @@ struct FormatStyle { /// return; /// } /// \endcode + /// \version 3.6 bool AllowShortCaseLabelsOnASingleLine; /// Different styles for merging short functions containing at most one @@ -647,6 +654,7 @@ struct FormatStyle { /// Dependent on the value, ``int f() { return 0; }`` can be put on a /// single line. + /// \version 3.5 ShortFunctionStyle AllowShortFunctionsOnASingleLine; /// Different styles for handling short if statements. @@ -717,6 +725,7 @@ struct FormatStyle { }; /// Dependent on the value, ``if (a) return;`` can be put on a single line. + /// \version 9 ShortIfStyle AllowShortIfStatementsOnASingleLine; /// Different styles for merging short lambdas containing at most one @@ -750,10 +759,12 @@ struct FormatStyle { /// Dependent on the value, ``auto lambda []() { return 0; }`` can be put on a /// single line. + /// \version 9 ShortLambdaStyle AllowShortLambdasOnASingleLine; /// If ``true``, ``while (true) continue;`` can be put on a single /// line. + /// \version 3.7 bool AllowShortLoopsOnASingleLine; /// Different ways to break after the function definition return type. @@ -841,9 +852,11 @@ struct FormatStyle { /// The function definition return type breaking style to use. This /// option is **deprecated** and is retained for backwards compatibility. + /// \version 3.7 DefinitionReturnTypeBreakingStyle AlwaysBreakAfterDefinitionReturnType; /// The function declaration return type breaking style to use. + /// \version 3.8 ReturnTypeBreakingStyle AlwaysBreakAfterReturnType; /// If ``true``, always break before multiline string literals. @@ -858,6 +871,7 @@ struct FormatStyle { /// "bbbb" "cccc"; /// "cccc"; /// \endcode + /// \version 3.4 bool AlwaysBreakBeforeMultilineStrings; /// Different ways to break after the template declaration. @@ -897,6 +911,7 @@ struct FormatStyle { }; /// The template declaration breaking style to use. + /// \version 7 BreakTemplateDeclarationsStyle AlwaysBreakTemplateDeclarations; /// A vector of strings that should be interpreted as attributes/qualifiers @@ -915,6 +930,7 @@ struct FormatStyle { /// AttributeMacros: ['__capability', '__output', '__ununsed'] /// \endcode /// + /// \version 12 std::vector<std::string> AttributeMacros; /// If ``false``, a function call's arguments will either be all on the @@ -933,6 +949,7 @@ struct FormatStyle { /// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); /// } /// \endcode + /// \version 3.7 bool BinPackArguments; /// The style of inserting trailing commas into container literals. @@ -962,6 +979,7 @@ struct FormatStyle { /// // ^ inserted /// ] /// \endcode + /// \version 12 TrailingCommaStyle InsertTrailingCommas; /// If ``false``, a function declaration's or function definition's @@ -976,6 +994,7 @@ struct FormatStyle { /// int aaaaaaaaaaaaaaaaaaaa, /// int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {} /// \endcode + /// \version 3.7 bool BinPackParameters; /// The style of wrapping parameters on the same line (bin-packed) or @@ -1030,6 +1049,7 @@ struct FormatStyle { }; /// The way to wrap binary operators. + /// \version 3.6 BinaryOperatorStyle BreakBeforeBinaryOperators; /// Different ways to attach braces to their surrounding context. @@ -1464,6 +1484,7 @@ struct FormatStyle { }; /// The brace breaking style to use. + /// \version 3.7 BraceBreakingStyle BreakBeforeBraces; /// Different ways to wrap braces after control statements. @@ -1738,6 +1759,7 @@ struct FormatStyle { /// AfterStruct: false /// SplitEmptyFunction: false /// \endcode + /// \version 3.8 BraceWrappingFlags BraceWrapping; /// If ``true``, concept will be placed on a new line. @@ -1749,6 +1771,7 @@ struct FormatStyle { /// false: /// template<typename T> concept ... /// \endcode + /// \version 13 bool BreakBeforeConceptDeclarations; /// If ``true``, ternary operators will be placed after line breaks. @@ -1763,6 +1786,7 @@ struct FormatStyle { /// firstValue : /// SecondValueVeryVeryVeryVeryLong; /// \endcode + /// \version 3.7 bool BreakBeforeTernaryOperators; /// Different ways to break initializers. @@ -1791,7 +1815,8 @@ struct FormatStyle { BCIS_AfterColon }; - /// The constructor initializers style to use. + /// The break constructor initializers style to use. + /// \version 5 BreakConstructorInitializersStyle BreakConstructorInitializers; /// Break after each annotation on a field in Java files. @@ -1801,6 +1826,7 @@ struct FormatStyle { /// @Mock /// DataLoad loader; /// \endcode + /// \version 3.8 bool BreakAfterJavaFieldAnnotations; /// Allow breaking string literals when formatting. @@ -1814,6 +1840,7 @@ struct FormatStyle { /// const char* x = /// "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString"; /// \endcode + /// \version 3.9 bool BreakStringLiterals; /// The column limit. @@ -1821,6 +1848,7 @@ struct FormatStyle { /// A column limit of ``0`` means that there is no column limit. In this case, /// clang-format will respect the input's line breaking decisions within /// statements unless they contradict other rules. + /// \version 3.7 unsigned ColumnLimit; /// A regular expression that describes comments with special meaning, @@ -1830,8 +1858,77 @@ struct FormatStyle { /// // Will leave the following line unaffected /// #include <vector> // FOOBAR pragma: keep /// \endcode + /// \version 3.7 std::string CommentPragmas; + /// Different specifiers and qualifiers alignment styles. + enum QualifierAlignmentStyle { + /// Don't change specifiers/qualifiers to either Left or Right alignment + /// (default). + /// \code + /// int const a; + /// const int *a; + /// \endcode + QAS_Leave, + /// Change specifiers/qualifiers to be left-aligned. + /// \code + /// const int a; + /// const int *a; + /// \endcode + QAS_Left, + /// Change specifiers/qualifiers to be right-aligned. + /// \code + /// int const a; + /// int const *a; + /// \endcode + QAS_Right, + /// Change specifiers/qualifiers to be aligned based on ``QualifierOrder``. + /// With: + /// \code{.yaml} + /// QualifierOrder: ['inline', 'static' , 'type', 'const'] + /// \endcode + /// + /// \code + /// + /// int const a; + /// int const *a; + /// \endcode + QAS_Custom + }; + + /// Different ways to arrange specifiers and qualifiers (e.g. const/volatile). + /// \warning + /// Setting ``QualifierAlignment`` to something other than `Leave`, COULD + /// lead to incorrect code formatting due to incorrect decisions made due to + /// clang-formats lack of complete semantic information. + /// As such extra care should be taken to review code changes made by the use + /// of this option. + /// \endwarning + /// \version 14 + QualifierAlignmentStyle QualifierAlignment; + + /// The order in which the qualifiers appear. + /// Order is an array that can contain any of the following: + /// + /// * const + /// * inline + /// * static + /// * constexpr + /// * volatile + /// * restrict + /// * type + /// + /// Note: it MUST contain 'type'. + /// Items to the left of 'type' will be placed to the left of the type and + /// aligned in the order supplied. Items to the right of 'type' will be placed + /// to the right of the type and aligned in the order supplied. + /// + /// \code{.yaml} + /// QualifierOrder: ['inline', 'static', 'type', 'const', 'volatile' ] + /// \endcode + /// \version 14 + std::vector<std::string> QualifierOrder; + /// Different ways to break inheritance list. enum BreakInheritanceListStyle : unsigned char { /// Break inheritance list before the colon and after the commas. @@ -1869,6 +1966,7 @@ struct FormatStyle { }; /// The inheritance list style to use. + /// \version 7 BreakInheritanceListStyle BreakInheritanceList; /// If ``true``, consecutive namespace declarations will be on the same @@ -1892,30 +1990,17 @@ struct FormatStyle { /// namespace Extra { /// }}} /// \endcode + /// \version 5 bool CompactNamespaces; - // clang-format off - /// If the constructor initializers don't fit on a line, put each - /// initializer on its own line. - /// \code - /// true: - /// SomeClass::Constructor() - /// : aaaaaaaa(aaaaaaaa), aaaaaaaa(aaaaaaaa), aaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa) { - /// return 0; - /// } - /// - /// false: - /// SomeClass::Constructor() - /// : aaaaaaaa(aaaaaaaa), aaaaaaaa(aaaaaaaa), - /// aaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa) { - /// return 0; - /// } - /// \endcode + /// This option is **deprecated**. See ``CurrentLine`` of + /// ``PackConstructorInitializers``. + /// \version 3.7 bool ConstructorInitializerAllOnOneLineOrOnePerLine; - // clang-format on /// The number of characters to use for indentation of constructor /// initializer lists as well as inheritance lists. + /// \version 3.7 unsigned ConstructorInitializerIndentWidth; /// Indent width for line continuations. @@ -1926,6 +2011,7 @@ struct FormatStyle { /// longFunction( // Again a long comment /// arg); /// \endcode + /// \version 3.7 unsigned ContinuationIndentWidth; /// If ``true``, format braced lists as best suited for C++11 braced @@ -1948,10 +2034,12 @@ struct FormatStyle { /// f(MyMap[{composite, key}]); f(MyMap[{ composite, key }]); /// new int[3]{1, 2, 3}; new int[3]{ 1, 2, 3 }; /// \endcode + /// \version 3.4 bool Cpp11BracedListStyle; /// \brief Analyze the formatted file for the most used line ending (``\r\n`` /// or ``\n``). ``UseCRLF`` is only used as a fallback if none can be derived. + /// \version 11 bool DeriveLineEnding; /// If ``true``, analyze the formatted file for the most common @@ -1959,9 +2047,11 @@ struct FormatStyle { /// Pointer and reference alignment styles are going to be updated according /// to the preferences found in the file. /// ``PointerAlignment`` is then used only as fallback. + /// \version 3.7 bool DerivePointerAlignment; /// Disables formatting completely. + /// \version 3.7 bool DisableFormat; /// Different styles for empty line after access modifiers. @@ -2012,6 +2102,7 @@ struct FormatStyle { /// Defines when to put an empty line after access modifiers. /// ``EmptyLineBeforeAccessModifier`` configuration handles the number of /// empty lines between two access modifiers. + /// \version 14 EmptyLineAfterAccessModifierStyle EmptyLineAfterAccessModifier; /// Different styles for empty line before access modifiers. @@ -2074,6 +2165,7 @@ struct FormatStyle { }; /// Defines in which cases to put empty line before access modifiers. + /// \version 13 EmptyLineBeforeAccessModifierStyle EmptyLineBeforeAccessModifier; /// If ``true``, clang-format detects whether function calls and @@ -2086,8 +2178,56 @@ struct FormatStyle { /// /// NOTE: This is an experimental flag, that might go away or be renamed. Do /// not use this in config files, etc. Use at your own risk. + /// \version 3.7 bool ExperimentalAutoDetectBinPacking; + /// Different ways to try to fit all constructor initializers on a line. + enum PackConstructorInitializersStyle : unsigned char { + /// Always put each constructor initializer on its own line. + /// \code + /// Constructor() + /// : a(), + /// b() + /// \endcode + PCIS_Never, + /// Bin-pack constructor initializers. + /// \code + /// Constructor() + /// : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(), + /// cccccccccccccccccccc() + /// \endcode + PCIS_BinPack, + /// Put all constructor initializers on the current line if they fit. + /// Otherwise, put each one on its own line. + /// \code + /// Constructor() : a(), b() + /// + /// Constructor() + /// : aaaaaaaaaaaaaaaaaaaa(), + /// bbbbbbbbbbbbbbbbbbbb(), + /// ddddddddddddd() + /// \endcode + PCIS_CurrentLine, + /// Same as ``PCIS_CurrentLine`` except that if all constructor initializers + /// do not fit on the current line, try to fit them on the next line. + /// \code + /// Constructor() : a(), b() + /// + /// Constructor() + /// : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(), ddddddddddddd() + /// + /// Constructor() + /// : aaaaaaaaaaaaaaaaaaaa(), + /// bbbbbbbbbbbbbbbbbbbb(), + /// cccccccccccccccccccc() + /// \endcode + PCIS_NextLine, + }; + + /// The pack constructor initializers style to use. + /// \version 14; + PackConstructorInitializersStyle PackConstructorInitializers; + /// If ``true``, clang-format adds missing namespace end comments for /// short namespaces and fixes invalid existing ones. Short ones are /// controlled by "ShortNamespaceLines". @@ -2098,6 +2238,7 @@ struct FormatStyle { /// bar(); bar(); /// } // namespace a } /// \endcode + /// \version 5 bool FixNamespaceComments; /// A vector of macros that should be interpreted as foreach loops @@ -2115,6 +2256,7 @@ struct FormatStyle { /// \endcode /// /// For example: BOOST_FOREACH. + /// \version 3.7 std::vector<std::string> ForEachMacros; /// A vector of macros that should be interpreted as conditionals @@ -2135,6 +2277,7 @@ struct FormatStyle { /// /// For example: `KJ_IF_MAYBE /// <https://github.com/capnproto/capnproto/blob/master/kjdoc/tour.md#maybes>`_ + /// \version 14 std::vector<std::string> IfMacros; /// \brief A vector of macros that should be interpreted as type declarations @@ -2151,6 +2294,7 @@ struct FormatStyle { /// \endcode /// /// For example: OpenSSL STACK_OF, BSD LIST_ENTRY. + /// \version 9 std::vector<std::string> TypenameMacros; /// A vector of macros that should be interpreted as complete @@ -2161,6 +2305,7 @@ struct FormatStyle { /// clang-format aware of such cases. /// /// For example: Q_UNUSED + /// \version 8 std::vector<std::string> StatementMacros; /// A vector of macros which are used to open namespace blocks. @@ -2173,6 +2318,7 @@ struct FormatStyle { /// \endcode /// /// For example: TESTSUITE + /// \version 9 std::vector<std::string> NamespaceMacros; /// A vector of macros which are whitespace-sensitive and should not @@ -2189,6 +2335,7 @@ struct FormatStyle { /// \endcode /// /// For example: BOOST_PP_STRINGIZE + /// \version 12 std::vector<std::string> WhitespaceSensitiveMacros; tooling::IncludeStyle IncludeStyle; @@ -2217,6 +2364,7 @@ struct FormatStyle { /// return 1; return 1; /// } } /// \endcode + /// \version 13 bool IndentAccessModifiers; /// Indent case labels one level from the switch statement. @@ -2235,6 +2383,7 @@ struct FormatStyle { /// plop(); plop(); /// } } /// \endcode + /// \version 3.3 bool IndentCaseLabels; /// Indent case label blocks one level from the case label. @@ -2257,6 +2406,7 @@ struct FormatStyle { /// } /// } /// \endcode + /// \version 11 bool IndentCaseBlocks; /// Indent goto labels. @@ -2273,6 +2423,7 @@ struct FormatStyle { /// return 1; return 1; /// } } /// \endcode + /// \version 10 bool IndentGotoLabels; /// Options for indenting preprocessor directives. @@ -2307,6 +2458,7 @@ struct FormatStyle { }; /// The preprocessor directive indenting style to use. + /// \version 6 PPDirectiveIndentStyle IndentPPDirectives; /// Indents extern blocks @@ -2346,6 +2498,7 @@ struct FormatStyle { }; /// IndentExternBlockStyle is the type of indenting of extern blocks. + /// \version 12 IndentExternBlockStyle IndentExternBlock; /// Indent the requires clause in a template @@ -2364,6 +2517,7 @@ struct FormatStyle { /// //.... /// } /// \endcode + /// \version 13 bool IndentRequires; /// The number of columns to use for indentation. @@ -2377,6 +2531,7 @@ struct FormatStyle { /// } /// } /// \endcode + /// \version 3.7 unsigned IndentWidth; /// Indent if a function definition or declaration is wrapped after the @@ -2390,6 +2545,7 @@ struct FormatStyle { /// LoooooooooooooooooooooooooooooooooooooooongReturnType /// LoooooooooooooooooooooooooooooooongFunctionDeclaration(); /// \endcode + /// \version 3.7 bool IndentWrappedFunctionNames; /// A vector of prefixes ordered by the desired groups for Java imports. @@ -2423,6 +2579,7 @@ struct FormatStyle { /// /// import org.example.ClassD; /// \endcode + /// \version 8 std::vector<std::string> JavaImportGroups; /// Quotation styles for JavaScript strings. Does not affect template @@ -2449,6 +2606,7 @@ struct FormatStyle { }; /// The JavaScriptQuoteStyle to use for JavaScript strings. + /// \version 3.9 JavaScriptQuoteStyle JavaScriptQuotes; // clang-format off @@ -2464,6 +2622,7 @@ struct FormatStyle { /// false: /// import {VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying,} from "some/module.js" /// \endcode + /// \version 3.9 bool JavaScriptWrapImports; // clang-format on @@ -2475,6 +2634,7 @@ struct FormatStyle { /// bar(); } /// } /// \endcode + /// \version 3.7 bool KeepEmptyLinesAtTheStartOfBlocks; /// Supported languages. @@ -2511,6 +2671,7 @@ struct FormatStyle { bool isJson() const { return Language == LK_Json; } /// Language, this format style is targeted at. + /// \version 3.5 LanguageKind Language; /// Indentation logic for lambda bodies. @@ -2543,16 +2704,17 @@ struct FormatStyle { /// ``OuterScope``. The KJ style guide requires ``OuterScope``. /// `KJ style guide /// <https://github.com/capnproto/capnproto/blob/master/kjdoc/style-guide.md>`_ + /// \version 13 LambdaBodyIndentationKind LambdaBodyIndentation; /// A regular expression matching macros that start a block. /// \code /// # With: /// MacroBlockBegin: "^NS_MAP_BEGIN|\ - /// NS_TABLE_HEAD$" + /// NS_TABLE_HEAD$" /// MacroBlockEnd: "^\ - /// NS_MAP_END|\ - /// NS_TABLE_.*_END$" + /// NS_MAP_END|\ + /// NS_TABLE_.*_END$" /// /// NS_MAP_BEGIN /// foo(); @@ -2571,9 +2733,11 @@ struct FormatStyle { /// bar(); /// NS_TABLE_FOO_END /// \endcode + /// \version 3.7 std::string MacroBlockBegin; /// A regular expression matching macros that end a block. + /// \version 3.7 std::string MacroBlockEnd; /// The maximum number of consecutive empty lines to keep. @@ -2587,6 +2751,7 @@ struct FormatStyle { /// return i; /// } /// \endcode + /// \version 3.7 unsigned MaxEmptyLinesToKeep; /// Different ways to indent namespace contents. @@ -2624,6 +2789,7 @@ struct FormatStyle { }; /// The indentation used for namespaces. + /// \version 3.7 NamespaceIndentationKind NamespaceIndentation; /// Controls bin-packing Objective-C protocol conformance list @@ -2656,6 +2822,7 @@ struct FormatStyle { /// ddddddddddddd> { /// } /// \endcode + /// \version 7 BinPackStyle ObjCBinPackProtocolList; /// The number of characters to use for indentation of ObjC blocks. @@ -2666,10 +2833,12 @@ struct FormatStyle { /// [self onOperationDone]; /// }]; /// \endcode + /// \version 3.7 unsigned ObjCBlockIndentWidth; /// Add a space after ``@property`` in Objective-C, i.e. use /// ``@property (readonly)`` instead of ``@property(readonly)``. + /// \version 3.7 bool ObjCSpaceAfterProperty; /// Break parameters list into lines when there is nested block @@ -2693,39 +2862,50 @@ struct FormatStyle { /// }] /// } /// \endcode + /// \version 12 bool ObjCBreakBeforeNestedBlockParam; /// Add a space in front of an Objective-C protocol list, i.e. use /// ``Foo <Protocol>`` instead of ``Foo<Protocol>``. + /// \version 3.7 bool ObjCSpaceBeforeProtocolList; /// The penalty for breaking around an assignment operator. + /// \version 5 unsigned PenaltyBreakAssignment; /// The penalty for breaking a function call after ``call(``. + /// \version 3.7 unsigned PenaltyBreakBeforeFirstCallParameter; /// The penalty for each line break introduced inside a comment. + /// \version 3.7 unsigned PenaltyBreakComment; /// The penalty for breaking before the first ``<<``. + /// \version 3.7 unsigned PenaltyBreakFirstLessLess; /// The penalty for each line break introduced inside a string literal. + /// \version 3.7 unsigned PenaltyBreakString; /// The penalty for breaking after template declaration. + /// \version 7 unsigned PenaltyBreakTemplateDeclaration; /// The penalty for each character outside of the column limit. + /// \version 3.7 unsigned PenaltyExcessCharacter; /// Penalty for putting the return type of a function onto its own /// line. + /// \version 3.7 unsigned PenaltyReturnTypeOnItsOwnLine; /// Penalty for each character of whitespace indentation /// (counted relative to leading non-whitespace column). + /// \version 12 unsigned PenaltyIndentedWhitespace; /// The ``&``, ``&&`` and ``*`` alignment style. @@ -2748,6 +2928,7 @@ struct FormatStyle { }; /// Pointer and reference alignment style. + /// \version 3.7 PointerAlignmentStyle PointerAlignment; /// The number of columns to use for indentation of preprocessor statements. @@ -2762,6 +2943,7 @@ struct FormatStyle { /// # define BAR /// #endif /// \endcode + /// \version 14 int PPIndentWidth; /// See documentation of ``RawStringFormats``. @@ -2821,6 +3003,7 @@ struct FormatStyle { /// BasedOnStyle: llvm /// CanonicalDelimiter: 'cc' /// \endcode + /// \version 6 std::vector<RawStringFormat> RawStringFormats; /// \brief The ``&`` and ``&&`` alignment style. @@ -2846,6 +3029,7 @@ struct FormatStyle { /// \brief Reference alignment style (overrides ``PointerAlignment`` for /// references). + /// \version 14 ReferenceAlignmentStyle ReferenceAlignment; // clang-format off @@ -2861,6 +3045,7 @@ struct FormatStyle { /// /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of /// * information */ /// \endcode + /// \version 4 bool ReflowComments; // clang-format on @@ -2883,6 +3068,7 @@ struct FormatStyle { /// int bar; int bar; /// } // namespace b } // namespace b /// \endcode + /// \version 14 unsigned ShortNamespaceLines; /// Include sorting options. @@ -2922,6 +3108,7 @@ struct FormatStyle { /// insensitive fashion. /// If ``CaseSensitive``, includes are sorted in an alphabetical or case /// sensitive fashion. + /// \version 4 SortIncludesOptions SortIncludes; /// Position for Java Static imports. @@ -2945,6 +3132,7 @@ struct FormatStyle { /// When sorting Java imports, by default static imports are placed before /// non-static imports. If ``JavaStaticImportAfterImport`` is ``After``, /// static imports are placed after non-static imports. + /// \version 12 SortJavaStaticImportOptions SortJavaStaticImport; /// If ``true``, clang-format will sort using declarations. @@ -2961,6 +3149,7 @@ struct FormatStyle { /// using std::cout; vs. using std::cin; /// using std::cin; using std::cout; /// \endcode + /// \version 5 bool SortUsingDeclarations; /// If ``true``, a space is inserted after C style casts. @@ -2968,6 +3157,7 @@ struct FormatStyle { /// true: false: /// (int) i; vs. (int)i; /// \endcode + /// \version 3.5 bool SpaceAfterCStyleCast; /// If ``true``, a space is inserted after the logical not operator (``!``). @@ -2975,6 +3165,7 @@ struct FormatStyle { /// true: false: /// ! someExpression(); vs. !someExpression(); /// \endcode + /// \version 9 bool SpaceAfterLogicalNot; /// If \c true, a space will be inserted after the 'template' keyword. @@ -2982,6 +3173,7 @@ struct FormatStyle { /// true: false: /// template <int> void foo(); vs. template<int> void foo(); /// \endcode + /// \version 4 bool SpaceAfterTemplateKeyword; /// Different ways to put a space before opening parentheses. @@ -3014,6 +3206,7 @@ struct FormatStyle { }; /// Defines in which cases to put a space before or after pointer qualifiers + /// \version 12 SpaceAroundPointerQualifiersStyle SpaceAroundPointerQualifiers; /// If ``false``, spaces will be removed before assignment operators. @@ -3022,6 +3215,7 @@ struct FormatStyle { /// int a = 5; vs. int a= 5; /// a += 42; a+= 42; /// \endcode + /// \version 3.7 bool SpaceBeforeAssignmentOperators; /// If ``false``, spaces will be removed before case colon. @@ -3031,6 +3225,7 @@ struct FormatStyle { /// case 1 : break; case 1: break; /// } } /// \endcode + /// \version 12 bool SpaceBeforeCaseColon; /// If ``true``, a space will be inserted before a C++11 braced list @@ -3042,6 +3237,7 @@ struct FormatStyle { /// vector<int> { 1, 2, 3 }; vector<int>{ 1, 2, 3 }; /// new int[3] { 1, 2, 3 }; new int[3]{ 1, 2, 3 }; /// \endcode + /// \version 7 bool SpaceBeforeCpp11BracedList; /// If ``false``, spaces will be removed before constructor initializer @@ -3050,6 +3246,7 @@ struct FormatStyle { /// true: false: /// Foo::Foo() : a(a) {} Foo::Foo(): a(a) {} /// \endcode + /// \version 7 bool SpaceBeforeCtorInitializerColon; /// If ``false``, spaces will be removed before inheritance colon. @@ -3057,10 +3254,11 @@ struct FormatStyle { /// true: false: /// class Foo : Bar {} vs. class Foo: Bar {} /// \endcode + /// \version 7 bool SpaceBeforeInheritanceColon; /// Different ways to put a space before opening parentheses. - enum SpaceBeforeParensOptions : unsigned char { + enum SpaceBeforeParensStyle : unsigned char { /// Never put a space before opening parentheses. /// \code /// void f() { @@ -3084,7 +3282,7 @@ struct FormatStyle { /// ForEach and If macros. This is useful in projects where ForEach/If /// macros are treated as function calls instead of control statements. /// ``SBPO_ControlStatementsExceptForEachMacros`` remains an alias for - /// backward compatability. + /// backward compatibility. /// \code /// void f() { /// Q_FOREACH(...) { @@ -3115,11 +3313,100 @@ struct FormatStyle { /// } /// } /// \endcode - SBPO_Always + SBPO_Always, + /// Configure each individual space before parentheses in + /// `SpaceBeforeParensOptions`. + SBPO_Custom, }; /// Defines in which cases to put a space before opening parentheses. - SpaceBeforeParensOptions SpaceBeforeParens; + /// \version 3.5 + SpaceBeforeParensStyle SpaceBeforeParens; + + /// Precise control over the spacing before parentheses. + /// \code + /// # Should be declared this way: + /// SpaceBeforeParens: Custom + /// SpaceBeforeParensOptions: + /// AfterControlStatements: true + /// AfterFunctionDefinitionName: true + /// \endcode + struct SpaceBeforeParensCustom { + /// If ``true``, put space betwee control statement keywords + /// (for/if/while...) and opening parentheses. + /// \code + /// true: false: + /// if (...) {} vs. if(...) {} + /// \endcode + bool AfterControlStatements; + /// If ``true``, put space between foreach macros and opening parentheses. + /// \code + /// true: false: + /// FOREACH (...) vs. FOREACH(...) + /// <loop-body> <loop-body> + /// \endcode + bool AfterForeachMacros; + /// If ``true``, put a space between function declaration name and opening + /// parentheses. + /// \code + /// true: false: + /// void f (); vs. void f(); + /// \endcode + bool AfterFunctionDeclarationName; + /// If ``true``, put a space between function definition name and opening + /// parentheses. + /// \code + /// true: false: + /// void f () {} vs. void f() {} + /// \endcode + bool AfterFunctionDefinitionName; + /// If ``true``, put space between if macros and opening parentheses. + /// \code + /// true: false: + /// IF (...) vs. IF(...) + /// <conditional-body> <conditional-body> + /// \endcode + bool AfterIfMacros; + /// If ``true``, put a space before opening parentheses only if the + /// parentheses are not empty. + /// \code + /// true: false: + /// void f (int a); vs. void f(); + /// f (a); f(); + /// \endcode + bool BeforeNonEmptyParentheses; + + SpaceBeforeParensCustom() + : AfterControlStatements(false), AfterForeachMacros(false), + AfterFunctionDeclarationName(false), + AfterFunctionDefinitionName(false), AfterIfMacros(false), + BeforeNonEmptyParentheses(false) {} + + bool operator==(const SpaceBeforeParensCustom &Other) const { + return AfterControlStatements == Other.AfterControlStatements && + AfterForeachMacros == Other.AfterForeachMacros && + AfterFunctionDeclarationName == + Other.AfterFunctionDeclarationName && + AfterFunctionDefinitionName == Other.AfterFunctionDefinitionName && + AfterIfMacros == Other.AfterIfMacros && + BeforeNonEmptyParentheses == Other.BeforeNonEmptyParentheses; + } + }; + + /// Control of individual space before parentheses. + /// + /// If ``SpaceBeforeParens`` is set to ``Custom``, use this to specify + /// how each individual space before parentheses case should be handled. + /// Otherwise, this is ignored. + /// \code{.yaml} + /// # Example of usage: + /// SpaceBeforeParens: Custom + /// SpaceBeforeParensOptions: + /// AfterControlStatements: true + /// AfterFunctionDefinitionName: true + /// \endcode + /// \version 14 + SpaceBeforeParensCustom SpaceBeforeParensOptions; /// If ``false``, spaces will be removed before range-based for loop /// colon. @@ -3127,6 +3414,7 @@ struct FormatStyle { /// true: false: /// for (auto v : values) {} vs. for(auto v: values) {} /// \endcode + /// \version 7 bool SpaceBeforeRangeBasedForLoopColon; /// If ``true``, spaces will be inserted into ``{}``. @@ -3135,6 +3423,7 @@ struct FormatStyle { /// void f() { } vs. void f() {} /// while (true) { } while (true) {} /// \endcode + /// \version 11 bool SpaceInEmptyBlock; /// If ``true``, spaces may be inserted into ``()``. @@ -3147,6 +3436,7 @@ struct FormatStyle { /// } } /// } } /// \endcode + /// \version 3.7 bool SpaceInEmptyParentheses; /// The number of spaces before trailing line comments @@ -3163,6 +3453,7 @@ struct FormatStyle { /// } // foo /// } /// \endcode + /// \version 3.7 unsigned SpacesBeforeTrailingComments; /// Styles for adding spacing after ``<`` and before ``>` @@ -3185,6 +3476,7 @@ struct FormatStyle { SIAS_Leave }; /// The SpacesInAnglesStyle to use for template argument lists. + /// \version 14 SpacesInAnglesStyle SpacesInAngles; /// If ``true``, spaces will be inserted around if/for/switch/while @@ -3194,6 +3486,7 @@ struct FormatStyle { /// if ( a ) { ... } vs. if (a) { ... } /// while ( i < 5 ) { ... } while (i < 5) { ... } /// \endcode + /// \version 11 bool SpacesInConditionalStatement; /// If ``true``, spaces are inserted inside container literals (e.g. @@ -3203,6 +3496,7 @@ struct FormatStyle { /// var arr = [ 1, 2, 3 ]; vs. var arr = [1, 2, 3]; /// f({a : 1, b : 2, c : 3}); f({a: 1, b: 2, c: 3}); /// \endcode + /// \version 3.7 bool SpacesInContainerLiterals; /// If ``true``, spaces may be inserted into C style casts. @@ -3210,6 +3504,7 @@ struct FormatStyle { /// true: false: /// x = ( int32 )y vs. x = (int32)y /// \endcode + /// \version 3.7 bool SpacesInCStyleCastParentheses; /// Control of spaces within a single line comment @@ -3223,30 +3518,33 @@ struct FormatStyle { /// How many spaces are allowed at the start of a line comment. To disable the /// maximum set it to ``-1``, apart from that the maximum takes precedence /// over the minimum. - /// \code Minimum = 1 Maximum = -1 - /// // One space is forced + /// \code + /// Minimum = 1 + /// Maximum = -1 + /// // One space is forced /// - /// // but more spaces are possible + /// // but more spaces are possible /// - /// Minimum = 0 - /// Maximum = 0 - /// //Forces to start every comment directly after the slashes + /// Minimum = 0 + /// Maximum = 0 + /// //Forces to start every comment directly after the slashes /// \endcode /// /// Note that in line comment sections the relative indent of the subsequent /// lines is kept, that means the following: /// \code - /// before: after: - /// Minimum: 1 - /// //if (b) { // if (b) { - /// // return true; // return true; - /// //} // } - /// - /// Maximum: 0 - /// /// List: ///List: - /// /// - Foo /// - Foo - /// /// - Bar /// - Bar + /// before: after: + /// Minimum: 1 + /// //if (b) { // if (b) { + /// // return true; // return true; + /// //} // } + /// + /// Maximum: 0 + /// /// List: ///List: + /// /// - Foo /// - Foo + /// /// - Bar /// - Bar /// \endcode + /// \version 14 SpacesInLineComment SpacesInLineCommentPrefix; /// If ``true``, spaces will be inserted after ``(`` and before ``)``. @@ -3254,6 +3552,7 @@ struct FormatStyle { /// true: false: /// t f( Deleted & ) & = delete; vs. t f(Deleted &) & = delete; /// \endcode + /// \version 3.7 bool SpacesInParentheses; /// If ``true``, spaces will be inserted after ``[`` and before ``]``. @@ -3264,6 +3563,7 @@ struct FormatStyle { /// int a[ 5 ]; vs. int a[5]; /// std::unique_ptr<int[]> foo() {} // Won't be affected /// \endcode + /// \version 3.7 bool SpacesInSquareBrackets; /// If ``true``, spaces will be before ``[``. @@ -3273,6 +3573,7 @@ struct FormatStyle { /// int a [5]; vs. int a[5]; /// int a [5][5]; vs. int a[5][5]; /// \endcode + /// \version 11 bool SpaceBeforeSquareBrackets; /// Styles for adding spacing around ``:`` in bitfield definitions. @@ -3301,6 +3602,7 @@ struct FormatStyle { BFCS_After }; /// The BitFieldColonSpacingStyle to use for bitfields. + /// \version 12 BitFieldColonSpacingStyle BitFieldColonSpacing; /// Supported language standards for parsing and formatting C++ constructs. @@ -3335,6 +3637,7 @@ struct FormatStyle { /// c++03: latest: /// vector<set<int> > x; vs. vector<set<int>> x; /// \endcode + /// \version 3.7 LanguageStandard Standard; /// Macros which are ignored in front of a statement, as if they were an @@ -3351,9 +3654,11 @@ struct FormatStyle { /// unsigned char data = 'x'; /// emit signal(data); // Now it's fine again. /// \endcode + /// \version 12 std::vector<std::string> StatementAttributeLikeMacros; /// The number of columns used for tab stops. + /// \version 3.7 unsigned TabWidth; /// Different ways to use tab in formatting. @@ -3375,9 +3680,11 @@ struct FormatStyle { /// \brief Use ``\r\n`` instead of ``\n`` for line breaks. /// Also used as fallback if ``DeriveLineEnding`` is true. + /// \version 11 bool UseCRLF; /// The way to use tab characters in the resulting file. + /// \version 3.7 UseTabStyle UseTab; bool operator==(const FormatStyle &R) const { @@ -3392,8 +3699,6 @@ struct FormatStyle { AlignOperands == R.AlignOperands && AlignTrailingComments == R.AlignTrailingComments && AllowAllArgumentsOnNextLine == R.AllowAllArgumentsOnNextLine && - AllowAllConstructorInitializersOnNextLine == - R.AllowAllConstructorInitializersOnNextLine && AllowAllParametersOfDeclarationOnNextLine == R.AllowAllParametersOfDeclarationOnNextLine && AllowShortEnumsOnASingleLine == R.AllowShortEnumsOnASingleLine && @@ -3424,8 +3729,6 @@ struct FormatStyle { BreakStringLiterals == R.BreakStringLiterals && ColumnLimit == R.ColumnLimit && CommentPragmas == R.CommentPragmas && BreakInheritanceList == R.BreakInheritanceList && - ConstructorInitializerAllOnOneLineOrOnePerLine == - R.ConstructorInitializerAllOnOneLineOrOnePerLine && ConstructorInitializerIndentWidth == R.ConstructorInitializerIndentWidth && ContinuationIndentWidth == R.ContinuationIndentWidth && @@ -3437,6 +3740,7 @@ struct FormatStyle { EmptyLineBeforeAccessModifier == R.EmptyLineBeforeAccessModifier && ExperimentalAutoDetectBinPacking == R.ExperimentalAutoDetectBinPacking && + PackConstructorInitializers == R.PackConstructorInitializers && FixNamespaceComments == R.FixNamespaceComments && ForEachMacros == R.ForEachMacros && IncludeStyle.IncludeBlocks == R.IncludeStyle.IncludeBlocks && @@ -3482,6 +3786,8 @@ struct FormatStyle { PenaltyBreakTemplateDeclaration == R.PenaltyBreakTemplateDeclaration && PointerAlignment == R.PointerAlignment && + QualifierAlignment == R.QualifierAlignment && + QualifierOrder == R.QualifierOrder && RawStringFormats == R.RawStringFormats && ReferenceAlignment == R.ReferenceAlignment && ShortNamespaceLines == R.ShortNamespaceLines && @@ -3497,6 +3803,7 @@ struct FormatStyle { R.SpaceBeforeCtorInitializerColon && SpaceBeforeInheritanceColon == R.SpaceBeforeInheritanceColon && SpaceBeforeParens == R.SpaceBeforeParens && + SpaceBeforeParensOptions == R.SpaceBeforeParensOptions && SpaceAroundPointerQualifiers == R.SpaceAroundPointerQualifiers && SpaceBeforeRangeBasedForLoopColon == R.SpaceBeforeRangeBasedForLoopColon && diff --git a/contrib/llvm-project/clang/include/clang/Frontend/CompilerInstance.h b/contrib/llvm-project/clang/include/clang/Frontend/CompilerInstance.h index 861b15020329..74e152ea5952 100644 --- a/contrib/llvm-project/clang/include/clang/Frontend/CompilerInstance.h +++ b/contrib/llvm-project/clang/include/clang/Frontend/CompilerInstance.h @@ -219,6 +219,9 @@ public: // of the context or else not CompilerInstance specific. bool ExecuteAction(FrontendAction &Act); + /// Load the list of plugins requested in the \c FrontendOptions. + void LoadRequestedPlugins(); + /// } /// @name Compiler Invocation and Options /// { diff --git a/contrib/llvm-project/clang/include/clang/Frontend/CompilerInvocation.h b/contrib/llvm-project/clang/include/clang/Frontend/CompilerInvocation.h index 2245439d0632..922c84a3bee2 100644 --- a/contrib/llvm-project/clang/include/clang/Frontend/CompilerInvocation.h +++ b/contrib/llvm-project/clang/include/clang/Frontend/CompilerInvocation.h @@ -50,6 +50,11 @@ class HeaderSearchOptions; class PreprocessorOptions; class TargetOptions; +// This lets us create the DiagnosticsEngine with a properly-filled-out +// DiagnosticOptions instance. +std::unique_ptr<DiagnosticOptions> +CreateAndPopulateDiagOpts(ArrayRef<const char *> Argv); + /// Fill out Opts based on the options given in Args. /// /// Args must have been created from the OptTable returned by diff --git a/contrib/llvm-project/clang/include/clang/Frontend/FrontendAction.h b/contrib/llvm-project/clang/include/clang/Frontend/FrontendAction.h index dfefddfb4527..039f6f247b6d 100644 --- a/contrib/llvm-project/clang/include/clang/Frontend/FrontendAction.h +++ b/contrib/llvm-project/clang/include/clang/Frontend/FrontendAction.h @@ -270,17 +270,18 @@ public: const std::vector<std::string> &arg) = 0; enum ActionType { - Cmdline, ///< Action is determined by the cc1 command-line - ReplaceAction, ///< Replace the main action - AddBeforeMainAction, ///< Execute the action before the main action - AddAfterMainAction ///< Execute the action after the main action + CmdlineBeforeMainAction, ///< Execute the action before the main action if + ///< on the command line + CmdlineAfterMainAction, ///< Execute the action after the main action if on + ///< the command line + ReplaceAction, ///< Replace the main action + AddBeforeMainAction, ///< Execute the action before the main action + AddAfterMainAction ///< Execute the action after the main action }; /// Get the action type for this plugin /// - /// \return The action type. If the type is Cmdline then by default the - /// plugin does nothing and what it does is determined by the cc1 - /// command-line. - virtual ActionType getActionType() { return Cmdline; } + /// \return The action type. By default we use CmdlineAfterMainAction. + virtual ActionType getActionType() { return CmdlineAfterMainAction; } }; /// Abstract base class to use for preprocessor-based frontend actions. diff --git a/contrib/llvm-project/clang/include/clang/Frontend/FrontendActions.h b/contrib/llvm-project/clang/include/clang/Frontend/FrontendActions.h index ff8d4417eaa4..545a7e842c4f 100644 --- a/contrib/llvm-project/clang/include/clang/Frontend/FrontendActions.h +++ b/contrib/llvm-project/clang/include/clang/Frontend/FrontendActions.h @@ -299,6 +299,15 @@ protected: bool hasPCHSupport() const override { return true; } }; +class GetDependenciesByModuleNameAction : public PreprocessOnlyAction { + StringRef ModuleName; + void ExecuteAction() override; + +public: + GetDependenciesByModuleNameAction(StringRef ModuleName) + : ModuleName(ModuleName) {} +}; + } // end namespace clang #endif diff --git a/contrib/llvm-project/clang/include/clang/Frontend/FrontendOptions.h b/contrib/llvm-project/clang/include/clang/Frontend/FrontendOptions.h index 15c905d712a3..1d9d89a28c6c 100644 --- a/contrib/llvm-project/clang/include/clang/Frontend/FrontendOptions.h +++ b/contrib/llvm-project/clang/include/clang/Frontend/FrontendOptions.h @@ -289,6 +289,9 @@ public: /// Whether we are performing an implicit module build. unsigned BuildingImplicitModule : 1; + /// Whether to use a filesystem lock when building implicit modules. + unsigned BuildingImplicitModuleUsesLock : 1; + /// Whether we should embed all used files into the PCM file. unsigned ModulesEmbedAllFiles : 1; @@ -370,7 +373,7 @@ public: ObjCMT_MigrateDecls | ObjCMT_PropertyDotSyntax) }; unsigned ObjCMTAction = ObjCMT_None; - std::string ObjCMTWhiteListPath; + std::string ObjCMTAllowListPath; std::string MTMigrateDir; std::string ARCMTMigrateReportOut; @@ -461,9 +464,9 @@ public: SkipFunctionBodies(false), UseGlobalModuleIndex(true), GenerateGlobalModuleIndex(true), ASTDumpDecls(false), ASTDumpLookups(false), BuildingImplicitModule(false), - ModulesEmbedAllFiles(false), IncludeTimestamps(true), - UseTemporary(true), AllowPCMWithCompilerErrors(false), - TimeTraceGranularity(500) {} + BuildingImplicitModuleUsesLock(true), ModulesEmbedAllFiles(false), + IncludeTimestamps(true), UseTemporary(true), + AllowPCMWithCompilerErrors(false), TimeTraceGranularity(500) {} /// getInputKindForExtension - Return the appropriate input kind for a file /// extension. For example, "c" would return Language::C. diff --git a/contrib/llvm-project/clang/include/clang/Frontend/PreprocessorOutputOptions.h b/contrib/llvm-project/clang/include/clang/Frontend/PreprocessorOutputOptions.h index 72e5ad1137fb..257538ee0606 100644 --- a/contrib/llvm-project/clang/include/clang/Frontend/PreprocessorOutputOptions.h +++ b/contrib/llvm-project/clang/include/clang/Frontend/PreprocessorOutputOptions.h @@ -24,6 +24,7 @@ public: unsigned ShowIncludeDirectives : 1; ///< Print includes, imports etc. within preprocessed output. unsigned RewriteIncludes : 1; ///< Preprocess include directives only. unsigned RewriteImports : 1; ///< Include contents of transitively-imported modules. + unsigned MinimizeWhitespace : 1; ///< Ignore whitespace from input. public: PreprocessorOutputOptions() { @@ -36,6 +37,7 @@ public: ShowIncludeDirectives = 0; RewriteIncludes = 0; RewriteImports = 0; + MinimizeWhitespace = 0; } }; diff --git a/contrib/llvm-project/clang/include/clang/Interpreter/Interpreter.h b/contrib/llvm-project/clang/include/clang/Interpreter/Interpreter.h index 020cbe2db3d0..2dc0fd5963a2 100644 --- a/contrib/llvm-project/clang/include/clang/Interpreter/Interpreter.h +++ b/contrib/llvm-project/clang/include/clang/Interpreter/Interpreter.h @@ -16,6 +16,9 @@ #include "clang/Interpreter/PartialTranslationUnit.h" +#include "clang/AST/GlobalDecl.h" + +#include "llvm/ExecutionEngine/JITSymbol.h" #include "llvm/Support/Error.h" #include <memory> @@ -65,6 +68,20 @@ public: return Execute(*PTU); return llvm::Error::success(); } + + /// \returns the \c JITTargetAddress of a \c GlobalDecl. This interface uses + /// the CodeGenModule's internal mangling cache to avoid recomputing the + /// mangled name. + llvm::Expected<llvm::JITTargetAddress> getSymbolAddress(GlobalDecl GD) const; + + /// \returns the \c JITTargetAddress of a given name as written in the IR. + llvm::Expected<llvm::JITTargetAddress> + getSymbolAddress(llvm::StringRef IRName) const; + + /// \returns the \c JITTargetAddress of a given name as written in the object + /// file. + llvm::Expected<llvm::JITTargetAddress> + getSymbolAddressFromLinkerName(llvm::StringRef LinkerName) const; }; } // namespace clang diff --git a/contrib/llvm-project/clang/include/clang/Lex/DependencyDirectivesSourceMinimizer.h b/contrib/llvm-project/clang/include/clang/Lex/DependencyDirectivesSourceMinimizer.h index 9bb820156c25..121ca893e314 100644 --- a/contrib/llvm-project/clang/include/clang/Lex/DependencyDirectivesSourceMinimizer.h +++ b/contrib/llvm-project/clang/include/clang/Lex/DependencyDirectivesSourceMinimizer.h @@ -39,6 +39,9 @@ enum TokenKind { pp_import, pp_pragma_import, pp_pragma_once, + pp_pragma_push_macro, + pp_pragma_pop_macro, + pp_pragma_include_alias, pp_include_next, pp_if, pp_ifdef, diff --git a/contrib/llvm-project/clang/include/clang/Lex/HeaderMap.h b/contrib/llvm-project/clang/include/clang/Lex/HeaderMap.h index 53108b00bd16..ca6a49bae3bf 100644 --- a/contrib/llvm-project/clang/include/clang/Lex/HeaderMap.h +++ b/contrib/llvm-project/clang/include/clang/Lex/HeaderMap.h @@ -77,13 +77,6 @@ public: static std::unique_ptr<HeaderMap> Create(const FileEntry *FE, FileManager &FM); - /// Check to see if the specified relative filename is located in this - /// HeaderMap. If so, open it and return its FileEntry. If RawPath is not - /// NULL and the file is found, RawPath will be set to the raw path at which - /// the file was found in the file system. For example, for a search path - /// ".." and a filename "../file.h" this would be "../../file.h". - Optional<FileEntryRef> LookupFile(StringRef Filename, FileManager &FM) const; - using HeaderMapImpl::dump; using HeaderMapImpl::getFileName; using HeaderMapImpl::lookupFilename; diff --git a/contrib/llvm-project/clang/include/clang/Lex/HeaderSearch.h b/contrib/llvm-project/clang/include/clang/Lex/HeaderSearch.h index a35a394f719b..b3445703f782 100644 --- a/contrib/llvm-project/clang/include/clang/Lex/HeaderSearch.h +++ b/contrib/llvm-project/clang/include/clang/Lex/HeaderSearch.h @@ -51,7 +51,7 @@ class TargetInfo; /// The preprocessor keeps track of this information for each /// file that is \#included. struct HeaderFileInfo { - /// True if this is a \#import'd or \#pragma once file. + /// True if this is a \#import'd file. unsigned isImport : 1; /// True if this is a \#pragma once file. @@ -130,13 +130,6 @@ struct HeaderFileInfo { /// any. const IdentifierInfo * getControllingMacro(ExternalPreprocessorSource *External); - - /// Determine whether this is a non-default header file info, e.g., - /// it corresponds to an actual header we've included or tried to include. - bool isNonDefault() const { - return isImport || isPragmaOnce || NumIncludes || ControllingMacro || - ControllingMacroID; - } }; /// An external source of header file information, which may supply @@ -172,6 +165,9 @@ class HeaderSearch { /// Header-search options used to initialize this header search. std::shared_ptr<HeaderSearchOptions> HSOpts; + /// Mapping from SearchDir to HeaderSearchOptions::UserEntries indices. + llvm::DenseMap<unsigned, unsigned> SearchDirToHSEntry; + DiagnosticsEngine &Diags; FileManager &FileMgr; @@ -182,6 +178,9 @@ class HeaderSearch { /// NoCurDirSearch is true, then the check for the file in the current /// directory is suppressed. std::vector<DirectoryLookup> SearchDirs; + /// Whether the DirectoryLookup at the corresponding index in SearchDirs has + /// been successfully used to lookup a file. + std::vector<bool> SearchDirsUsage; unsigned AngledDirIdx = 0; unsigned SystemDirIdx = 0; bool NoCurDirSearch = false; @@ -280,15 +279,17 @@ public: DiagnosticsEngine &getDiags() const { return Diags; } /// Interface for setting the file search paths. - void SetSearchPaths(const std::vector<DirectoryLookup> &dirs, - unsigned angledDirIdx, unsigned systemDirIdx, - bool noCurDirSearch) { + void SetSearchPaths(std::vector<DirectoryLookup> dirs, unsigned angledDirIdx, + unsigned systemDirIdx, bool noCurDirSearch, + llvm::DenseMap<unsigned, unsigned> searchDirToHSEntry) { assert(angledDirIdx <= systemDirIdx && systemDirIdx <= dirs.size() && "Directory indices are unordered"); - SearchDirs = dirs; + SearchDirs = std::move(dirs); + SearchDirsUsage.assign(SearchDirs.size(), false); AngledDirIdx = angledDirIdx; SystemDirIdx = systemDirIdx; NoCurDirSearch = noCurDirSearch; + SearchDirToHSEntry = std::move(searchDirToHSEntry); //LookupFileCache.clear(); } @@ -296,6 +297,7 @@ public: void AddSearchPath(const DirectoryLookup &dir, bool isAngled) { unsigned idx = isAngled ? SystemDirIdx : AngledDirIdx; SearchDirs.insert(SearchDirs.begin() + idx, dir); + SearchDirsUsage.insert(SearchDirsUsage.begin() + idx, false); if (!isAngled) AngledDirIdx++; SystemDirIdx++; @@ -441,8 +443,8 @@ public: /// \return false if \#including the file will have no effect or true /// if we should include it. bool ShouldEnterIncludeFile(Preprocessor &PP, const FileEntry *File, - bool isImport, bool ModulesEnabled, - Module *M); + bool isImport, bool ModulesEnabled, Module *M, + bool &IsFirstIncludeOfFile); /// Return whether the specified file is a normal header, /// a system header, or a C++ friendly system header. @@ -450,11 +452,10 @@ public: return (SrcMgr::CharacteristicKind)getFileInfo(File).DirInfo; } - /// Mark the specified file as a "once only" file, e.g. due to + /// Mark the specified file as a "once only" file due to /// \#pragma once. void MarkFileIncludeOnce(const FileEntry *File) { HeaderFileInfo &FI = getFileInfo(File); - FI.isImport = true; FI.isPragmaOnce = true; } @@ -488,11 +489,6 @@ public: getFileInfo(File).ControllingMacro = ControllingMacro; } - /// Return true if this is the first time encountering this header. - bool FirstTimeLexingFile(const FileEntry *File) { - return getFileInfo(File).NumIncludes == 1; - } - /// Determine whether this file is intended to be safe from /// multiple inclusions, e.g., it has \#pragma once or a controlling /// macro. @@ -500,13 +496,16 @@ public: /// This routine does not consider the effect of \#import bool isFileMultipleIncludeGuarded(const FileEntry *File); - /// Determine whether the given file is known to have ever been \#imported - /// (or if it has been \#included and we've encountered a \#pragma once). + /// Determine whether the given file is known to have ever been \#imported. bool hasFileBeenImported(const FileEntry *File) { const HeaderFileInfo *FI = getExistingFileInfo(File); return FI && FI->isImport; } + /// Determine which HeaderSearchOptions::UserEntries have been successfully + /// used so far and mark their index with 'true' in the resulting bit vector. + std::vector<bool> computeUserEntryUsage() const; + /// This method returns a HeaderMap for the specified /// FileEntry, uniquing them through the 'HeaderMaps' datastructure. const HeaderMap *CreateHeaderMap(const FileEntry *FE); @@ -562,6 +561,8 @@ public: /// /// \param ModuleName The name of the module we're looking for. /// + /// \param ImportLoc Location of the module include/import. + /// /// \param AllowSearch Whether we are allowed to search in the various /// search directories to produce a module definition. If not, this lookup /// will only return an already-known module. @@ -570,7 +571,9 @@ public: /// in subdirectories. /// /// \returns The module with the given name. - Module *lookupModule(StringRef ModuleName, bool AllowSearch = true, + Module *lookupModule(StringRef ModuleName, + SourceLocation ImportLoc = SourceLocation(), + bool AllowSearch = true, bool AllowExtraModuleMapSearch = false); /// Try to find a module map file in the given directory, returning @@ -640,11 +643,14 @@ private: /// but for compatibility with some buggy frameworks, additional attempts /// may be made to find the module under a related-but-different search-name. /// + /// \param ImportLoc Location of the module include/import. + /// /// \param AllowExtraModuleMapSearch Whether we allow to search modulemaps /// in subdirectories. /// /// \returns The module named ModuleName. Module *lookupModule(StringRef ModuleName, StringRef SearchName, + SourceLocation ImportLoc, bool AllowExtraModuleMapSearch = false); /// Retrieve the name of the (to-be-)cached module file that should @@ -709,6 +715,14 @@ private: Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule); + /// Cache the result of a successful lookup at the given include location + /// using the search path at index `HitIdx`. + void cacheLookupSuccess(LookupFileCacheInfo &CacheLookup, unsigned HitIdx, + SourceLocation IncludeLoc); + /// Note that a lookup at the given include location was successful using the + /// search path at index `HitIdx`. + void noteLookupUsage(unsigned HitIdx, SourceLocation IncludeLoc); + public: /// Retrieve the module map. ModuleMap &getModuleMap() { return ModMap; } @@ -758,6 +772,9 @@ public: search_dir_iterator system_dir_end() const { return SearchDirs.end(); } + /// Get the index of the given search directory. + Optional<unsigned> searchDirIdx(const DirectoryLookup &DL) const; + /// Retrieve a uniqued framework name. StringRef getUniqueFrameworkName(StringRef Framework); diff --git a/contrib/llvm-project/clang/include/clang/Lex/HeaderSearchOptions.h b/contrib/llvm-project/clang/include/clang/Lex/HeaderSearchOptions.h index 42f3cff8c57a..4efdfc26c3c6 100644 --- a/contrib/llvm-project/clang/include/clang/Lex/HeaderSearchOptions.h +++ b/contrib/llvm-project/clang/include/clang/Lex/HeaderSearchOptions.h @@ -14,10 +14,11 @@ #include "llvm/ADT/Hashing.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/HashBuilder.h" #include <cstdint> +#include <map> #include <string> #include <vector> -#include <map> namespace clang { @@ -256,11 +257,23 @@ inline llvm::hash_code hash_value(const HeaderSearchOptions::Entry &E) { return llvm::hash_combine(E.Path, E.Group, E.IsFramework, E.IgnoreSysRoot); } +template <typename HasherT, llvm::support::endianness Endianness> +inline void addHash(llvm::HashBuilderImpl<HasherT, Endianness> &HBuilder, + const HeaderSearchOptions::Entry &E) { + HBuilder.add(E.Path, E.Group, E.IsFramework, E.IgnoreSysRoot); +} + inline llvm::hash_code hash_value(const HeaderSearchOptions::SystemHeaderPrefix &SHP) { return llvm::hash_combine(SHP.Prefix, SHP.IsSystemHeader); } +template <typename HasherT, llvm::support::endianness Endianness> +inline void addHash(llvm::HashBuilderImpl<HasherT, Endianness> &HBuilder, + const HeaderSearchOptions::SystemHeaderPrefix &SHP) { + HBuilder.add(SHP.Prefix, SHP.IsSystemHeader); +} + } // namespace clang #endif // LLVM_CLANG_LEX_HEADERSEARCHOPTIONS_H diff --git a/contrib/llvm-project/clang/include/clang/Lex/Lexer.h b/contrib/llvm-project/clang/include/clang/Lex/Lexer.h index a291520ae5ca..ba1706b1d13e 100644 --- a/contrib/llvm-project/clang/include/clang/Lex/Lexer.h +++ b/contrib/llvm-project/clang/include/clang/Lex/Lexer.h @@ -128,6 +128,9 @@ class Lexer : public PreprocessorLexer { bool HasLeadingEmptyMacro; + /// True if this is the first time we're lexing the input file. + bool IsFirstTimeLexingFile; + // NewLinePtr - A pointer to new line character '\n' being lexed. For '\r\n', // it also points to '\n.' const char *NewLinePtr; @@ -142,19 +145,22 @@ public: /// with the specified preprocessor managing the lexing process. This lexer /// assumes that the associated file buffer and Preprocessor objects will /// outlive it, so it doesn't take ownership of either of them. - Lexer(FileID FID, const llvm::MemoryBufferRef &InputFile, Preprocessor &PP); + Lexer(FileID FID, const llvm::MemoryBufferRef &InputFile, Preprocessor &PP, + bool IsFirstIncludeOfFile = true); /// Lexer constructor - Create a new raw lexer object. This object is only /// suitable for calls to 'LexFromRawLexer'. This lexer assumes that the /// text range will outlive it, so it doesn't take ownership of it. Lexer(SourceLocation FileLoc, const LangOptions &LangOpts, - const char *BufStart, const char *BufPtr, const char *BufEnd); + const char *BufStart, const char *BufPtr, const char *BufEnd, + bool IsFirstIncludeOfFile = true); /// Lexer constructor - Create a new raw lexer object. This object is only /// suitable for calls to 'LexFromRawLexer'. This lexer assumes that the /// text range will outlive it, so it doesn't take ownership of it. Lexer(FileID FID, const llvm::MemoryBufferRef &FromFile, - const SourceManager &SM, const LangOptions &LangOpts); + const SourceManager &SM, const LangOptions &LangOpts, + bool IsFirstIncludeOfFile = true); Lexer(const Lexer &) = delete; Lexer &operator=(const Lexer &) = delete; @@ -536,7 +542,8 @@ public: bool SkipTrailingWhitespaceAndNewLine); /// Returns true if the given character could appear in an identifier. - static bool isIdentifierBodyChar(char c, const LangOptions &LangOpts); + static bool isAsciiIdentifierContinueChar(char c, + const LangOptions &LangOpts); /// Checks whether new line pointed by Str is preceded by escape /// sequence. @@ -562,6 +569,9 @@ public: static StringRef getIndentationForLine(SourceLocation Loc, const SourceManager &SM); + /// Check if this is the first time we're lexing the input file. + bool isFirstTimeLexingFile() const { return IsFirstTimeLexingFile; } + private: //===--------------------------------------------------------------------===// // Internal implementation interfaces. @@ -573,10 +583,7 @@ private: bool CheckUnicodeWhitespace(Token &Result, uint32_t C, const char *CurPtr); - /// Given that a token begins with the Unicode character \p C, figure out - /// what kind of token it is and dispatch to the appropriate lexing helper - /// function. - bool LexUnicode(Token &Result, uint32_t C, const char *CurPtr); + bool LexUnicodeIdentifierStart(Token &Result, uint32_t C, const char *CurPtr); /// FormTokenWithChars - When we lex a token, we have identified a span /// starting at BufferPtr, going to TokEnd that forms the token. This method @@ -701,7 +708,11 @@ private: bool IsStringLiteral); // Helper functions to lex the remainder of a token of the specific type. - bool LexIdentifier (Token &Result, const char *CurPtr); + + // This function handles both ASCII and Unicode identifiers after + // the first codepoint of the identifyier has been parsed. + bool LexIdentifierContinue(Token &Result, const char *CurPtr); + bool LexNumericConstant (Token &Result, const char *CurPtr); bool LexStringLiteral (Token &Result, const char *CurPtr, tok::TokenKind Kind); diff --git a/contrib/llvm-project/clang/include/clang/Lex/LiteralSupport.h b/contrib/llvm-project/clang/include/clang/Lex/LiteralSupport.h index f131f045a73e..32471969f596 100644 --- a/contrib/llvm-project/clang/include/clang/Lex/LiteralSupport.h +++ b/contrib/llvm-project/clang/include/clang/Lex/LiteralSupport.h @@ -224,7 +224,7 @@ class StringLiteralParser { unsigned UDSuffixOffset; public: StringLiteralParser(ArrayRef<Token> StringToks, - Preprocessor &PP, bool Complain = true); + Preprocessor &PP); StringLiteralParser(ArrayRef<Token> StringToks, const SourceManager &sm, const LangOptions &features, const TargetInfo &target, diff --git a/contrib/llvm-project/clang/include/clang/Lex/PPCallbacks.h b/contrib/llvm-project/clang/include/clang/Lex/PPCallbacks.h index bcf49c577735..76a74f20cc3b 100644 --- a/contrib/llvm-project/clang/include/clang/Lex/PPCallbacks.h +++ b/contrib/llvm-project/clang/include/clang/Lex/PPCallbacks.h @@ -252,9 +252,20 @@ public: } /// Callback invoked when a \#pragma warning directive is read. - virtual void PragmaWarning(SourceLocation Loc, StringRef WarningSpec, - ArrayRef<int> Ids) { - } + enum PragmaWarningSpecifier { + PWS_Default, + PWS_Disable, + PWS_Error, + PWS_Once, + PWS_Suppress, + PWS_Level1, + PWS_Level2, + PWS_Level3, + PWS_Level4, + }; + virtual void PragmaWarning(SourceLocation Loc, + PragmaWarningSpecifier WarningSpec, + ArrayRef<int> Ids) {} /// Callback invoked when a \#pragma warning(push) directive is read. virtual void PragmaWarningPush(SourceLocation Loc, int Level) { @@ -492,6 +503,11 @@ public: Second->PragmaComment(Loc, Kind, Str); } + void PragmaMark(SourceLocation Loc, StringRef Trivia) override { + First->PragmaMark(Loc, Trivia); + Second->PragmaMark(Loc, Trivia); + } + void PragmaDetectMismatch(SourceLocation Loc, StringRef Name, StringRef Value) override { First->PragmaDetectMismatch(Loc, Name, Value); @@ -535,7 +551,7 @@ public: Second->PragmaOpenCLExtension(NameLoc, Name, StateLoc, State); } - void PragmaWarning(SourceLocation Loc, StringRef WarningSpec, + void PragmaWarning(SourceLocation Loc, PragmaWarningSpecifier WarningSpec, ArrayRef<int> Ids) override { First->PragmaWarning(Loc, WarningSpec, Ids); Second->PragmaWarning(Loc, WarningSpec, Ids); diff --git a/contrib/llvm-project/clang/include/clang/Lex/Preprocessor.h b/contrib/llvm-project/clang/include/clang/Lex/Preprocessor.h index fe2327f0a480..ea96bb12bec6 100644 --- a/contrib/llvm-project/clang/include/clang/Lex/Preprocessor.h +++ b/contrib/llvm-project/clang/include/clang/Lex/Preprocessor.h @@ -15,6 +15,7 @@ #define LLVM_CLANG_LEX_PREPROCESSOR_H #include "clang/Basic/Diagnostic.h" +#include "clang/Basic/DiagnosticIDs.h" #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/LangOptions.h" @@ -786,6 +787,42 @@ private: using WarnUnusedMacroLocsTy = llvm::SmallDenseSet<SourceLocation, 32>; WarnUnusedMacroLocsTy WarnUnusedMacroLocs; + /// This is a pair of an optional message and source location used for pragmas + /// that annotate macros like pragma clang restrict_expansion and pragma clang + /// deprecated. This pair stores the optional message and the location of the + /// annotation pragma for use producing diagnostics and notes. + using MsgLocationPair = std::pair<std::string, SourceLocation>; + + struct MacroAnnotationInfo { + SourceLocation Location; + std::string Message; + }; + + struct MacroAnnotations { + llvm::Optional<MacroAnnotationInfo> DeprecationInfo; + llvm::Optional<MacroAnnotationInfo> RestrictExpansionInfo; + llvm::Optional<SourceLocation> FinalAnnotationLoc; + + static MacroAnnotations makeDeprecation(SourceLocation Loc, + std::string Msg) { + return MacroAnnotations{MacroAnnotationInfo{Loc, std::move(Msg)}, + llvm::None, llvm::None}; + } + + static MacroAnnotations makeRestrictExpansion(SourceLocation Loc, + std::string Msg) { + return MacroAnnotations{ + llvm::None, MacroAnnotationInfo{Loc, std::move(Msg)}, llvm::None}; + } + + static MacroAnnotations makeFinal(SourceLocation Loc) { + return MacroAnnotations{llvm::None, llvm::None, Loc}; + } + }; + + /// Warning information for macro annotations. + llvm::DenseMap<const IdentifierInfo *, MacroAnnotations> AnnotationInfos; + /// A "freelist" of MacroArg objects that can be /// reused for quick allocation. MacroArgs *MacroArgCache = nullptr; @@ -1331,7 +1368,7 @@ public: /// /// Emits a diagnostic, doesn't enter the file, and returns true on error. bool EnterSourceFile(FileID FID, const DirectoryLookup *Dir, - SourceLocation Loc); + SourceLocation Loc, bool IsFirstIncludeOfFile = true); /// Add a Macro to the top of the include stack and start lexing /// tokens from it instead of the current buffer. @@ -2388,7 +2425,57 @@ public: /// warnings. void markMacroAsUsed(MacroInfo *MI); + void addMacroDeprecationMsg(const IdentifierInfo *II, std::string Msg, + SourceLocation AnnotationLoc) { + auto Annotations = AnnotationInfos.find(II); + if (Annotations == AnnotationInfos.end()) + AnnotationInfos.insert(std::make_pair( + II, + MacroAnnotations::makeDeprecation(AnnotationLoc, std::move(Msg)))); + else + Annotations->second.DeprecationInfo = + MacroAnnotationInfo{AnnotationLoc, std::move(Msg)}; + } + + void addRestrictExpansionMsg(const IdentifierInfo *II, std::string Msg, + SourceLocation AnnotationLoc) { + auto Annotations = AnnotationInfos.find(II); + if (Annotations == AnnotationInfos.end()) + AnnotationInfos.insert( + std::make_pair(II, MacroAnnotations::makeRestrictExpansion( + AnnotationLoc, std::move(Msg)))); + else + Annotations->second.RestrictExpansionInfo = + MacroAnnotationInfo{AnnotationLoc, std::move(Msg)}; + } + + void addFinalLoc(const IdentifierInfo *II, SourceLocation AnnotationLoc) { + auto Annotations = AnnotationInfos.find(II); + if (Annotations == AnnotationInfos.end()) + AnnotationInfos.insert( + std::make_pair(II, MacroAnnotations::makeFinal(AnnotationLoc))); + else + Annotations->second.FinalAnnotationLoc = AnnotationLoc; + } + + const MacroAnnotations &getMacroAnnotations(const IdentifierInfo *II) const { + return AnnotationInfos.find(II)->second; + } + + void emitMacroExpansionWarnings(const Token &Identifier) const { + if (Identifier.getIdentifierInfo()->isDeprecatedMacro()) + emitMacroDeprecationWarning(Identifier); + + if (Identifier.getIdentifierInfo()->isRestrictExpansion() && + !SourceMgr.isInMainFile(Identifier.getLocation())) + emitRestrictExpansionWarning(Identifier); + } + private: + void emitMacroDeprecationWarning(const Token &Identifier) const; + void emitRestrictExpansionWarning(const Token &Identifier) const; + void emitFinalMacroWarning(const Token &Identifier, bool IsUndef) const; + Optional<unsigned> getSkippedRangeForExcludedConditionalBlock(SourceLocation HashLoc); diff --git a/contrib/llvm-project/clang/include/clang/Parse/Parser.h b/contrib/llvm-project/clang/include/clang/Parse/Parser.h index 8eb3f9029d9d..92a703b42173 100644 --- a/contrib/llvm-project/clang/include/clang/Parse/Parser.h +++ b/contrib/llvm-project/clang/include/clang/Parse/Parser.h @@ -196,6 +196,7 @@ class Parser : public CodeCompletionHandler { std::unique_ptr<PragmaHandler> MSRuntimeChecks; std::unique_ptr<PragmaHandler> MSIntrinsic; std::unique_ptr<PragmaHandler> MSOptimize; + std::unique_ptr<PragmaHandler> MSFenvAccess; std::unique_ptr<PragmaHandler> CUDAForceHostDeviceHandler; std::unique_ptr<PragmaHandler> OptimizeHandler; std::unique_ptr<PragmaHandler> LoopHintHandler; @@ -1977,6 +1978,9 @@ private: Sema::ConditionKind CK, ForRangeInfo *FRI = nullptr, bool EnterForConditionScope = false); + DeclGroupPtrTy + ParseAliasDeclarationInInitStatement(DeclaratorContext Context, + ParsedAttributesWithRange &Attrs); //===--------------------------------------------------------------------===// // C++ Coroutines @@ -2396,7 +2400,8 @@ private: if (getLangOpts().OpenMP) Actions.startOpenMPLoop(); if (getLangOpts().CPlusPlus) - return isCXXSimpleDeclaration(/*AllowForRangeDecl=*/true); + return Tok.is(tok::kw_using) || + isCXXSimpleDeclaration(/*AllowForRangeDecl=*/true); return isDeclarationSpecifier(true); } @@ -2834,7 +2839,10 @@ private: SourceLocation ScopeLoc, CachedTokens &OpenMPTokens); - IdentifierInfo *TryParseCXX11AttributeIdentifier(SourceLocation &Loc); + IdentifierInfo *TryParseCXX11AttributeIdentifier( + SourceLocation &Loc, + Sema::AttributeCompletion Completion = Sema::AttributeCompletion::None, + const IdentifierInfo *EnclosingScope = nullptr); void MaybeParseMicrosoftAttributes(ParsedAttributes &attrs, SourceLocation *endLoc = nullptr) { @@ -3197,6 +3205,10 @@ private: /// Parses OpenMP context selectors. bool parseOMPContextSelectors(SourceLocation Loc, OMPTraitInfo &TI); + /// Parse an 'append_args' clause for '#pragma omp declare variant'. + bool parseOpenMPAppendArgs( + SmallVectorImpl<OMPDeclareVariantAttr::InteropType> &InterOpTypes); + /// Parse a `match` clause for an '#pragma omp declare variant'. Return true /// if there was an error. bool parseOMPDeclareVariantMatchClause(SourceLocation Loc, OMPTraitInfo &TI, diff --git a/contrib/llvm-project/clang/include/clang/Sema/CodeCompleteConsumer.h b/contrib/llvm-project/clang/include/clang/Sema/CodeCompleteConsumer.h index 87646ab95025..6b37e3c50dba 100644 --- a/contrib/llvm-project/clang/include/clang/Sema/CodeCompleteConsumer.h +++ b/contrib/llvm-project/clang/include/clang/Sema/CodeCompleteConsumer.h @@ -329,6 +329,9 @@ public: /// Code completion inside the filename part of a #include directive. CCC_IncludedFile, + /// Code completion of an attribute name. + CCC_Attribute, + /// An unknown context, in which we are recovering from a parsing /// error and don't know which completions we should give. CCC_Recovery diff --git a/contrib/llvm-project/clang/include/clang/Sema/DeclSpec.h b/contrib/llvm-project/clang/include/clang/Sema/DeclSpec.h index 423f4f4ee7b7..ed5be2da3acd 100644 --- a/contrib/llvm-project/clang/include/clang/Sema/DeclSpec.h +++ b/contrib/llvm-project/clang/include/clang/Sema/DeclSpec.h @@ -275,6 +275,7 @@ public: static const TST TST_accum = clang::TST_Accum; static const TST TST_fract = clang::TST_Fract; static const TST TST_float128 = clang::TST_float128; + static const TST TST_ibm128 = clang::TST_ibm128; static const TST TST_bool = clang::TST_bool; static const TST TST_decimal32 = clang::TST_decimal32; static const TST TST_decimal64 = clang::TST_decimal64; diff --git a/contrib/llvm-project/clang/include/clang/Sema/Initialization.h b/contrib/llvm-project/clang/include/clang/Sema/Initialization.h index 420803f8e33c..679e12ee22d4 100644 --- a/contrib/llvm-project/clang/include/clang/Sema/Initialization.h +++ b/contrib/llvm-project/clang/include/clang/Sema/Initialization.h @@ -335,8 +335,15 @@ public: } /// Create the initialization entity for a temporary. - static InitializedEntity InitializeTemporary(TypeSourceInfo *TypeInfo) { - return InitializeTemporary(TypeInfo, TypeInfo->getType()); + static InitializedEntity InitializeTemporary(ASTContext &Context, + TypeSourceInfo *TypeInfo) { + QualType Type = TypeInfo->getType(); + if (Context.getLangOpts().OpenCLCPlusPlus) { + assert(!Type.hasAddressSpace() && "Temporary already has address space!"); + Type = Context.getAddrSpaceQualType(Type, LangAS::opencl_private); + } + + return InitializeTemporary(TypeInfo, Type); } /// Create the initialization entity for a temporary. @@ -481,7 +488,7 @@ public: /// Determine whether this is an array new with an unknown bound. bool isVariableLengthArrayNew() const { - return getKind() == EK_New && dyn_cast_or_null<IncompleteArrayType>( + return getKind() == EK_New && isa_and_nonnull<IncompleteArrayType>( getType()->getAsArrayTypeUnsafe()); } diff --git a/contrib/llvm-project/clang/include/clang/Sema/Overload.h b/contrib/llvm-project/clang/include/clang/Sema/Overload.h index 82661cb3d12a..88405a63b735 100644 --- a/contrib/llvm-project/clang/include/clang/Sema/Overload.h +++ b/contrib/llvm-project/clang/include/clang/Sema/Overload.h @@ -469,7 +469,9 @@ class Sema; unrelated_class, bad_qualifiers, lvalue_ref_to_rvalue, - rvalue_ref_to_lvalue + rvalue_ref_to_lvalue, + too_few_initializers, + too_many_initializers, }; // This can be null, e.g. for implicit object arguments. @@ -533,11 +535,17 @@ class Sema; }; /// ConversionKind - The kind of implicit conversion sequence. - unsigned ConversionKind : 30; + unsigned ConversionKind : 31; - /// Whether the target is really a std::initializer_list, and the - /// sequence only represents the worst element conversion. - unsigned StdInitializerListElement : 1; + // Whether the initializer list was of an incomplete array. + unsigned InitializerListOfIncompleteArray : 1; + + /// When initializing an array or std::initializer_list from an + /// initializer-list, this is the array or std::initializer_list type being + /// initialized. The remainder of the conversion sequence, including ToType, + /// describe the worst conversion of an initializer to an element of the + /// array or std::initializer_list. (Note, 'worst' is not well defined.) + QualType InitializerListContainerType; void setKind(Kind K) { destruct(); @@ -568,13 +576,17 @@ class Sema; }; ImplicitConversionSequence() - : ConversionKind(Uninitialized), StdInitializerListElement(false) { + : ConversionKind(Uninitialized), + InitializerListOfIncompleteArray(false), + InitializerListContainerType() { Standard.setAsIdentityConversion(); } ImplicitConversionSequence(const ImplicitConversionSequence &Other) : ConversionKind(Other.ConversionKind), - StdInitializerListElement(Other.StdInitializerListElement) { + InitializerListOfIncompleteArray( + Other.InitializerListOfIncompleteArray), + InitializerListContainerType(Other.InitializerListContainerType) { switch (ConversionKind) { case Uninitialized: break; case StandardConversion: Standard = Other.Standard; break; @@ -670,14 +682,22 @@ class Sema; Standard.setAllToTypes(T); } - /// Whether the target is really a std::initializer_list, and the - /// sequence only represents the worst element conversion. - bool isStdInitializerListElement() const { - return StdInitializerListElement; + // True iff this is a conversion sequence from an initializer list to an + // array or std::initializer. + bool hasInitializerListContainerType() const { + return !InitializerListContainerType.isNull(); } - - void setStdInitializerListElement(bool V = true) { - StdInitializerListElement = V; + void setInitializerListContainerType(QualType T, bool IA) { + InitializerListContainerType = T; + InitializerListOfIncompleteArray = IA; + } + bool isInitializerListOfIncompleteArray() const { + return InitializerListOfIncompleteArray; + } + QualType getInitializerListContainerType() const { + assert(hasInitializerListContainerType() && + "not initializer list container"); + return InitializerListContainerType; } /// Form an "implicit" conversion sequence from nullptr_t to bool, for a @@ -1184,6 +1204,20 @@ class Sema; return Info; } + // Returns false if signature help is relevant despite number of arguments + // exceeding parameters. Specifically, it returns false when + // PartialOverloading is true and one of the following: + // * Function is variadic + // * Function is template variadic + // * Function is an instantiation of template variadic function + // The last case may seem strange. The idea is that if we added one more + // argument, we'd end up with a function similar to Function. Since, in the + // context of signature help and/or code completion, we do not know what the + // type of the next argument (that the user is typing) will be, this is as + // good candidate as we can get, despite the fact that it takes one less + // parameter. + bool shouldEnforceArgLimit(bool PartialOverloading, FunctionDecl *Function); + } // namespace clang #endif // LLVM_CLANG_SEMA_OVERLOAD_H diff --git a/contrib/llvm-project/clang/include/clang/Sema/ParsedAttr.h b/contrib/llvm-project/clang/include/clang/Sema/ParsedAttr.h index f47f557adeb1..ff2303c84bd2 100644 --- a/contrib/llvm-project/clang/include/clang/Sema/ParsedAttr.h +++ b/contrib/llvm-project/clang/include/clang/Sema/ParsedAttr.h @@ -67,6 +67,8 @@ struct ParsedAttrInfo { const char *NormalizedFullName; }; ArrayRef<Spelling> Spellings; + // The names of the known arguments of this attribute. + ArrayRef<const char *> ArgNames; ParsedAttrInfo(AttributeCommonInfo::Kind AttrKind = AttributeCommonInfo::NoSemaHandlerAttribute) @@ -92,11 +94,9 @@ struct ParsedAttrInfo { const Decl *D) const { return true; } - /// Check if this attribute is allowed by the language we are compiling, and - /// issue a diagnostic if not. - virtual bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const { - return true; - } + /// Check if this attribute is allowed by the language we are compiling. + virtual bool acceptsLangOpts(const LangOptions &LO) const { return true; } + /// Check if this attribute is allowed when compiling for the given target. virtual bool existsInTarget(const TargetInfo &Target) const { return true; @@ -125,6 +125,7 @@ struct ParsedAttrInfo { } static const ParsedAttrInfo &get(const AttributeCommonInfo &A); + static ArrayRef<const ParsedAttrInfo *> getAllBuiltin(); }; typedef llvm::Registry<ParsedAttrInfo> ParsedAttrInfoRegistry; @@ -628,7 +629,7 @@ public: /// a Spelling enumeration, the value UINT_MAX is returned. unsigned getSemanticSpelling() const; - /// If this is an OpenCL address space attribute returns its representation + /// If this is an OpenCL address space attribute, returns its representation /// in LangAS, otherwise returns default address space. LangAS asOpenCLLangAS() const { switch (getParsedKind()) { @@ -651,7 +652,7 @@ public: } } - /// If this is an OpenCL address space attribute returns its SYCL + /// If this is an OpenCL address space attribute, returns its SYCL /// representation in LangAS, otherwise returns default address space. LangAS asSYCLLangAS() const { switch (getKind()) { @@ -893,7 +894,7 @@ public: ParsedAttr> { iterator() : iterator_adaptor_base(nullptr) {} iterator(VecTy::iterator I) : iterator_adaptor_base(I) {} - reference operator*() { return **I; } + reference operator*() const { return **I; } friend class ParsedAttributesView; }; struct const_iterator @@ -1118,14 +1119,14 @@ enum AttributeDeclKind { inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB, const ParsedAttr &At) { - DB.AddTaggedVal(reinterpret_cast<intptr_t>(At.getAttrName()), + DB.AddTaggedVal(reinterpret_cast<uint64_t>(At.getAttrName()), DiagnosticsEngine::ak_identifierinfo); return DB; } inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB, const ParsedAttr *At) { - DB.AddTaggedVal(reinterpret_cast<intptr_t>(At->getAttrName()), + DB.AddTaggedVal(reinterpret_cast<uint64_t>(At->getAttrName()), DiagnosticsEngine::ak_identifierinfo); return DB; } @@ -1140,7 +1141,7 @@ template <typename ACI, std::is_same<ACI, AttributeCommonInfo>::value, int> = 0> inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB, const ACI &CI) { - DB.AddTaggedVal(reinterpret_cast<intptr_t>(CI.getAttrName()), + DB.AddTaggedVal(reinterpret_cast<uint64_t>(CI.getAttrName()), DiagnosticsEngine::ak_identifierinfo); return DB; } @@ -1150,7 +1151,7 @@ template <typename ACI, std::is_same<ACI, AttributeCommonInfo>::value, int> = 0> inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB, const ACI* CI) { - DB.AddTaggedVal(reinterpret_cast<intptr_t>(CI->getAttrName()), + DB.AddTaggedVal(reinterpret_cast<uint64_t>(CI->getAttrName()), DiagnosticsEngine::ak_identifierinfo); return DB; } diff --git a/contrib/llvm-project/clang/include/clang/Sema/Scope.h b/contrib/llvm-project/clang/include/clang/Sema/Scope.h index b499ba1e7c2a..872951a0829b 100644 --- a/contrib/llvm-project/clang/include/clang/Sema/Scope.h +++ b/contrib/llvm-project/clang/include/clang/Sema/Scope.h @@ -337,7 +337,7 @@ public: /// isDeclScope - Return true if this is the scope that the specified decl is /// declared in. - bool isDeclScope(const Decl *D) const { return DeclsInScope.count(D) != 0; } + bool isDeclScope(const Decl *D) const { return DeclsInScope.contains(D); } /// Get the entity corresponding to this scope. DeclContext *getEntity() const { diff --git a/contrib/llvm-project/clang/include/clang/Sema/ScopeInfo.h b/contrib/llvm-project/clang/include/clang/Sema/ScopeInfo.h index 98ed75acd9d2..ccd15ea6a818 100644 --- a/contrib/llvm-project/clang/include/clang/Sema/ScopeInfo.h +++ b/contrib/llvm-project/clang/include/clang/Sema/ScopeInfo.h @@ -175,8 +175,9 @@ public: /// First 'return' statement in the current function. SourceLocation FirstReturnLoc; - /// First C++ 'try' statement in the current function. - SourceLocation FirstCXXTryLoc; + /// First C++ 'try' or ObjC @try statement in the current function. + SourceLocation FirstCXXOrObjCTryLoc; + enum { TryLocIsCXX, TryLocIsObjC, Unknown } FirstTryType = Unknown; /// First SEH '__try' statement in the current function. SourceLocation FirstSEHTryLoc; @@ -446,7 +447,14 @@ public: void setHasCXXTry(SourceLocation TryLoc) { setHasBranchProtectedScope(); - FirstCXXTryLoc = TryLoc; + FirstCXXOrObjCTryLoc = TryLoc; + FirstTryType = TryLocIsCXX; + } + + void setHasObjCTry(SourceLocation TryLoc) { + setHasBranchProtectedScope(); + FirstCXXOrObjCTryLoc = TryLoc; + FirstTryType = TryLocIsObjC; } void setHasSEHTry(SourceLocation TryLoc) { @@ -1001,10 +1009,7 @@ public: return NonODRUsedCapturingExprs.count(CapturingVarExpr); } void removePotentialCapture(Expr *E) { - PotentiallyCapturingExprs.erase( - std::remove(PotentiallyCapturingExprs.begin(), - PotentiallyCapturingExprs.end(), E), - PotentiallyCapturingExprs.end()); + llvm::erase_value(PotentiallyCapturingExprs, E); } void clearPotentialCaptures() { PotentiallyCapturingExprs.clear(); diff --git a/contrib/llvm-project/clang/include/clang/Sema/Sema.h b/contrib/llvm-project/clang/include/clang/Sema/Sema.h index d8b2546b81a3..43ce5d983217 100644 --- a/contrib/llvm-project/clang/include/clang/Sema/Sema.h +++ b/contrib/llvm-project/clang/include/clang/Sema/Sema.h @@ -74,7 +74,6 @@ namespace llvm { class APSInt; - template <typename ValueT> struct DenseMapInfo; template <typename ValueT, typename ValueInfoT> class DenseSet; class SmallBitVector; struct InlineAsmIdentifierInfo; @@ -396,8 +395,8 @@ public: /// /// This is the greatest alignment value supported by load, store, and alloca /// instructions, and global values. - static const unsigned MaxAlignmentExponent = 29; - static const unsigned MaximumAlignment = 1u << MaxAlignmentExponent; + static const unsigned MaxAlignmentExponent = 32; + static const uint64_t MaximumAlignment = 1ull << MaxAlignmentExponent; typedef OpaquePtr<DeclGroupRef> DeclGroupPtrTy; typedef OpaquePtr<TemplateName> TemplateTy; @@ -914,10 +913,6 @@ public: OpaqueParser = P; } - // Does the work necessary to deal with a SYCL kernel lambda. At the moment, - // this just marks the list of lambdas required to name the kernel. - void AddSYCLKernelLambda(const FunctionDecl *FD); - class DelayedDiagnostics; class DelayedDiagnosticsState { @@ -1128,6 +1123,10 @@ public: /// The C++ "std::coroutine_traits" template, which is defined in /// \<coroutine_traits> ClassTemplateDecl *StdCoroutineTraitsCache; + /// The namespace where coroutine components are defined. In standard, + /// they are defined in std namespace. And in the previous implementation, + /// they are defined in std::experimental namespace. + NamespaceDecl *CoroTraitsNamespaceCache; /// The C++ "type_info" declaration, which is defined in \<typeinfo>. RecordDecl *CXXTypeInfoDecl; @@ -1218,6 +1217,11 @@ public: /// cases in a switch statement). ConstantEvaluated, + /// In addition of being constant evaluated, the current expression + /// occurs in an immediate function context - either a consteval function + /// or a consteval if function. + ImmediateFunctionContext, + /// The current expression is potentially evaluated at run time, /// which means that code may be generated to evaluate the value of the /// expression at run time. @@ -1306,8 +1310,14 @@ public: Context == ExpressionEvaluationContext::UnevaluatedAbstract || Context == ExpressionEvaluationContext::UnevaluatedList; } + bool isConstantEvaluated() const { - return Context == ExpressionEvaluationContext::ConstantEvaluated; + return Context == ExpressionEvaluationContext::ConstantEvaluated || + Context == ExpressionEvaluationContext::ImmediateFunctionContext; + } + + bool isImmediateFunctionContext() const { + return Context == ExpressionEvaluationContext::ImmediateFunctionContext; } }; @@ -1419,8 +1429,22 @@ public: const llvm::MapVector<FieldDecl *, DeleteLocs> & getMismatchingDeleteExpressions() const; - typedef std::pair<ObjCMethodList, ObjCMethodList> GlobalMethods; - typedef llvm::DenseMap<Selector, GlobalMethods> GlobalMethodPool; + class GlobalMethodPool { + public: + using Lists = std::pair<ObjCMethodList, ObjCMethodList>; + using iterator = llvm::DenseMap<Selector, Lists>::iterator; + iterator begin() { return Methods.begin(); } + iterator end() { return Methods.end(); } + iterator find(Selector Sel) { return Methods.find(Sel); } + std::pair<iterator, bool> insert(std::pair<Selector, Lists> &&Val) { + return Methods.insert(Val); + } + int count(Selector Sel) const { return Methods.count(Sel); } + bool empty() const { return Methods.empty(); } + + private: + llvm::DenseMap<Selector, Lists> Methods; + }; /// Method Pool - allows efficient lookup when typechecking messages to "id". /// We need to maintain a list, since selectors can have differing signatures @@ -2334,12 +2358,13 @@ public: const CXXScopeSpec &SS, QualType T, TagDecl *OwnedTagDecl = nullptr); - QualType getDecltypeForParenthesizedExpr(Expr *E); - QualType BuildTypeofExprType(Expr *E, SourceLocation Loc); + // Returns the underlying type of a decltype with the given expression. + QualType getDecltypeForExpr(Expr *E); + + QualType BuildTypeofExprType(Expr *E); /// If AsUnevaluated is false, E is treated as though it were an evaluated /// context, such as when building a type for decltype(auto). - QualType BuildDecltypeType(Expr *E, SourceLocation Loc, - bool AsUnevaluated = true); + QualType BuildDecltypeType(Expr *E, bool AsUnevaluated = true); QualType BuildUnaryTransformType(QualType BaseType, UnaryTransformType::UTTKind UKind, SourceLocation Loc); @@ -3343,6 +3368,8 @@ public: const AttributeCommonInfo &CI, bool BestCase, MSInheritanceModel Model); + ErrorAttr *mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI, + StringRef NewUserDiagnostic); FormatAttr *mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Format, int FormatIdx, int FirstArg); @@ -3368,6 +3395,7 @@ public: EnforceTCBAttr *mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL); EnforceTCBLeafAttr *mergeEnforceTCBLeafAttr(Decl *D, const EnforceTCBLeafAttr &AL); + BTFDeclTagAttr *mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL); void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK = AMK_Redeclaration); @@ -3475,7 +3503,7 @@ public: bool IsFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy); bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType); - bool isSameOrCompatibleFunctionType(CanQualType Param, CanQualType Arg); + bool isSameOrCompatibleFunctionType(QualType Param, QualType Arg); bool CanPerformAggregateInitializationForOverloadResolution( const InitializedEntity &Entity, InitListExpr *From); @@ -3504,11 +3532,12 @@ public: /// Contexts in which a converted constant expression is required. enum CCEKind { - CCEK_CaseValue, ///< Expression in a case label. - CCEK_Enumerator, ///< Enumerator value with fixed underlying type. - CCEK_TemplateArg, ///< Value of a non-type template parameter. - CCEK_ArrayBound, ///< Array bound in array declarator or new-expression. - CCEK_ExplicitBool ///< Condition in an explicit(bool) specifier. + CCEK_CaseValue, ///< Expression in a case label. + CCEK_Enumerator, ///< Enumerator value with fixed underlying type. + CCEK_TemplateArg, ///< Value of a non-type template parameter. + CCEK_ArrayBound, ///< Array bound in array declarator or new-expression. + CCEK_ExplicitBool, ///< Condition in an explicit(bool) specifier. + CCEK_Noexcept ///< Condition in a noexcept(bool) specifier. }; ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE); @@ -3888,6 +3917,8 @@ public: SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, + Expr *ExecConfig = nullptr, + bool IsExecConfig = false, bool AllowRecovery = false); ExprResult BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc, @@ -4690,11 +4721,12 @@ public: Stmt *SubStmt); class ConditionResult; - StmtResult ActOnIfStmt(SourceLocation IfLoc, bool IsConstexpr, + + StmtResult ActOnIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal); - StmtResult BuildIfStmt(SourceLocation IfLoc, bool IsConstexpr, + StmtResult BuildIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal); @@ -4893,7 +4925,7 @@ public: /// DiagnoseUnusedExprResult - If the statement passed in is an expression /// whose result is unused, warn. - void DiagnoseUnusedExprResult(const Stmt *S); + void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID); void DiagnoseUnusedNestedTypedefs(const RecordDecl *D); void DiagnoseUnusedDecl(const NamedDecl *ND); @@ -5082,7 +5114,8 @@ public: /// type -- entities referenced by the type are now referenced. void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T); void MarkDeclarationsReferencedInExpr(Expr *E, - bool SkipLocalVariables = false); + bool SkipLocalVariables = false, + ArrayRef<const Expr *> StopAt = None); /// Try to recover by turning the given expression into a /// call. Returns true if recovery was attempted or an error was @@ -5099,6 +5132,16 @@ public: /// conversion. ExprResult tryConvertExprToType(Expr *E, QualType Ty); + /// Conditionally issue a diagnostic based on the statements's reachability + /// analysis. + /// + /// \param Stmts If Stmts is non-empty, delay reporting the diagnostic until + /// the function body is parsed, and then do a basic reachability analysis to + /// determine if the statement is reachable. If it is unreachable, the + /// diagnostic will not be emitted. + bool DiagIfReachable(SourceLocation Loc, ArrayRef<const Stmt *> Stmts, + const PartialDiagnostic &PD); + /// Conditionally issue a diagnostic based on the current /// evaluation context. /// @@ -5659,6 +5702,7 @@ public: NamespaceDecl *getOrCreateStdNamespace(); NamespaceDecl *lookupStdExperimentalNamespace(); + NamespaceDecl *getCachedCoroNamespace() { return CoroTraitsNamespaceCache; } CXXRecordDecl *getStdBadAlloc() const; EnumDecl *getStdAlignValT() const; @@ -5909,7 +5953,7 @@ public: /// Check the given noexcept-specifier, convert its expression, and compute /// the appropriate ExceptionSpecificationType. - ExprResult ActOnNoexceptSpec(SourceLocation NoexceptLoc, Expr *NoexceptExpr, + ExprResult ActOnNoexceptSpec(Expr *NoexceptExpr, ExceptionSpecificationType &EST); /// Check the given exception-specification and update the @@ -6105,6 +6149,13 @@ public: // AltiVecPixel and AltiVecBool when -faltivec-src-compat=xl is specified. bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy); + // Checks if the -faltivec-src-compat=gcc option is specified. + // If so, AltiVecVector, AltiVecBool and AltiVecPixel types are + // treated the same way as they are when trying to initialize + // these vectors on gcc (an error is emitted). + bool CheckAltivecInitFromScalar(SourceRange R, QualType VecTy, + QualType SrcTy); + /// ActOnCXXNamedCast - Parse /// {dynamic,static,reinterpret,const,addrspace}_cast's. ExprResult ActOnCXXNamedCast(SourceLocation OpLoc, @@ -8516,6 +8567,14 @@ public: /// Substitute Replacement for auto in TypeWithAuto TypeSourceInfo* SubstAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto, QualType Replacement); + + // Substitute auto in TypeWithAuto for a Dependent auto type + QualType SubstAutoTypeDependent(QualType TypeWithAuto); + + // Substitute auto in TypeWithAuto for a Dependent auto type + TypeSourceInfo * + SubstAutoTypeSourceInfoDependent(TypeSourceInfo *TypeWithAuto); + /// Completely replace the \c auto in \p TypeWithAuto by /// \p Replacement. This does not retain any \c auto type sugar. QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement); @@ -9088,6 +9147,19 @@ public: return ExprEvalContexts.back().isUnevaluated(); } + bool isImmediateFunctionContext() const { + assert(!ExprEvalContexts.empty() && + "Must be in an expression evaluation context"); + for (const ExpressionEvaluationContextRecord &context : + llvm::reverse(ExprEvalContexts)) { + if (context.isImmediateFunctionContext()) + return true; + if (context.isUnevaluated()) + return false; + } + return false; + } + /// RAII class used to determine whether SFINAE has /// trapped any errors that occur during template argument /// deduction. @@ -9451,9 +9523,9 @@ public: SubstTemplateName(NestedNameSpecifierLoc QualifierLoc, TemplateName Name, SourceLocation Loc, const MultiLevelTemplateArgumentList &TemplateArgs); - bool Subst(const TemplateArgumentLoc *Args, unsigned NumArgs, - TemplateArgumentListInfo &Result, - const MultiLevelTemplateArgumentList &TemplateArgs); + + bool SubstTypeConstraint(TemplateTypeParmDecl *Inst, const TypeConstraint *TC, + const MultiLevelTemplateArgumentList &TemplateArgs); bool InstantiateDefaultArgument(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param); @@ -10208,8 +10280,11 @@ public: bool buildCoroutineParameterMoves(SourceLocation Loc); VarDecl *buildCoroutinePromise(SourceLocation Loc); void CheckCompletedCoroutineBody(FunctionDecl *FD, Stmt *&Body); + /// Lookup 'coroutine_traits' in std namespace and std::experimental + /// namespace. The namespace found is recorded in Namespace. ClassTemplateDecl *lookupCoroutineTraits(SourceLocation KwLoc, - SourceLocation FuncLoc); + SourceLocation FuncLoc, + NamespaceDecl *&Namespace); /// Check that the expression co_await promise.final_suspend() shall not be /// potentially-throwing. bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend); @@ -10430,6 +10505,12 @@ public: /// \param Init First part of the for loop. void ActOnOpenMPLoopInitialization(SourceLocation ForLoc, Stmt *Init); + /// Called on well-formed '\#pragma omp metadirective' after parsing + /// of the associated statement. + StmtResult ActOnOpenMPMetaDirective(ArrayRef<OMPClause *> Clauses, + Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc); + // OpenMP directives and clauses. /// Called on correct id-expression from the '#pragma omp /// threadprivate'. @@ -10452,7 +10533,7 @@ public: /// Called on well-formed '#pragma omp [begin] assume[s]'. void ActOnOpenMPAssumesDirective(SourceLocation Loc, OpenMPDirectiveKind DKind, - ArrayRef<StringRef> Assumptions, + ArrayRef<std::string> Assumptions, bool SkippedClauses); /// Check if there is an active global `omp begin assumes` directive. @@ -10562,6 +10643,11 @@ public: /// an OpenMP loop directive. StmtResult ActOnOpenMPCanonicalLoop(Stmt *AStmt); + /// Process a canonical OpenMP loop nest that can either be a canonical + /// literal loop (ForStmt or CXXForRangeStmt), or the generated loop of an + /// OpenMP loop transformation construct. + StmtResult ActOnOpenMPLoopnest(Stmt *AStmt); + /// End of OpenMP region. /// /// \param S Statement associated with the current OpenMP region. @@ -10667,7 +10753,8 @@ public: StmtResult ActOnOpenMPBarrierDirective(SourceLocation StartLoc, SourceLocation EndLoc); /// Called on well-formed '\#pragma omp taskwait'. - StmtResult ActOnOpenMPTaskwaitDirective(SourceLocation StartLoc, + StmtResult ActOnOpenMPTaskwaitDirective(ArrayRef<OMPClause *> Clauses, + SourceLocation StartLoc, SourceLocation EndLoc); /// Called on well-formed '\#pragma omp taskgroup'. StmtResult ActOnOpenMPTaskgroupDirective(ArrayRef<OMPClause *> Clauses, @@ -10872,6 +10959,12 @@ public: Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc); + /// Called on well-formed '\#pragma omp loop' after parsing of the + /// associated statement. + StmtResult ActOnOpenMPGenericLoopDirective( + ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); + /// Checks correctness of linear modifiers. bool CheckOpenMPLinearModifier(OpenMPLinearClauseKind LinKind, SourceLocation LinLoc); @@ -10896,11 +10989,14 @@ public: /// \param VariantRef Expression that references the variant function, which /// must be used instead of the original one, specified in \p DG. /// \param TI The trait info object representing the match clause. + /// \param NumAppendArgs The number of omp_interop_t arguments to account for + /// in checking. /// \returns None, if the function/variant function are not compatible with /// the pragma, pair of original function/variant ref expression otherwise. Optional<std::pair<FunctionDecl *, Expr *>> checkOpenMPDeclareVariantFunction(DeclGroupPtrTy DG, Expr *VariantRef, - OMPTraitInfo &TI, SourceRange SR); + OMPTraitInfo &TI, unsigned NumAppendArgs, + SourceRange SR); /// Called on well-formed '\#pragma omp declare variant' after parsing of /// the associated method/function. @@ -10909,8 +11005,19 @@ public: /// \param VariantRef Expression that references the variant function, which /// must be used instead of the original one, specified in \p DG. /// \param TI The context traits associated with the function variant. - void ActOnOpenMPDeclareVariantDirective(FunctionDecl *FD, Expr *VariantRef, - OMPTraitInfo &TI, SourceRange SR); + /// \param AdjustArgsNothing The list of 'nothing' arguments. + /// \param AdjustArgsNeedDevicePtr The list of 'need_device_ptr' arguments. + /// \param AppendArgs The list of 'append_args' arguments. + /// \param AdjustArgsLoc The Location of an 'adjust_args' clause. + /// \param AppendArgsLoc The Location of an 'append_args' clause. + /// \param SR The SourceRange of the 'declare variant' directive. + void ActOnOpenMPDeclareVariantDirective( + FunctionDecl *FD, Expr *VariantRef, OMPTraitInfo &TI, + ArrayRef<Expr *> AdjustArgsNothing, + ArrayRef<Expr *> AdjustArgsNeedDevicePtr, + ArrayRef<OMPDeclareVariantAttr::InteropType> AppendArgs, + SourceLocation AdjustArgsLoc, SourceLocation AppendArgsLoc, + SourceRange SR); OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr, @@ -10938,6 +11045,10 @@ public: SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc); + /// Called on well-formed 'align' clause. + OMPClause *ActOnOpenMPAlignClause(Expr *Alignment, SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc); /// Called on well-formed 'safelen' clause. OMPClause *ActOnOpenMPSafelenClause(Expr *Length, SourceLocation StartLoc, @@ -10992,6 +11103,10 @@ public: SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc); + /// Called on well-formed 'when' clause. + OMPClause *ActOnOpenMPWhenClause(OMPTraitInfo &TI, SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc); /// Called on well-formed 'default' clause. OMPClause *ActOnOpenMPDefaultClause(llvm::omp::DefaultKind Kind, SourceLocation KindLoc, @@ -11242,15 +11357,14 @@ public: SourceLocation ModifierLoc, SourceLocation EndLoc); /// Called on well-formed 'map' clause. - OMPClause * - ActOnOpenMPMapClause(ArrayRef<OpenMPMapModifierKind> MapTypeModifiers, - ArrayRef<SourceLocation> MapTypeModifiersLoc, - CXXScopeSpec &MapperIdScopeSpec, - DeclarationNameInfo &MapperId, - OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, - SourceLocation MapLoc, SourceLocation ColonLoc, - ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs, - ArrayRef<Expr *> UnresolvedMappers = llvm::None); + OMPClause *ActOnOpenMPMapClause( + ArrayRef<OpenMPMapModifierKind> MapTypeModifiers, + ArrayRef<SourceLocation> MapTypeModifiersLoc, + CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, + OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, + SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VarList, + const OMPVarListLocTy &Locs, bool NoDiagnose = false, + ArrayRef<Expr *> UnresolvedMappers = llvm::None); /// Called on well-formed 'num_teams' clause. OMPClause *ActOnOpenMPNumTeamsClause(Expr *NumTeams, SourceLocation StartLoc, SourceLocation LParenLoc, @@ -11325,6 +11439,12 @@ public: SourceLocation ColonLoc, SourceLocation EndLoc, Expr *Modifier, ArrayRef<Expr *> Locators); + /// Called on a well-formed 'bind' clause. + OMPClause *ActOnOpenMPBindClause(OpenMPBindClauseKind Kind, + SourceLocation KindLoc, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc); /// The kind of conversion being performed. enum CheckedConversionKind { @@ -12146,9 +12266,9 @@ public: return targetDiag(Loc, PD.getDiagID(), FD) << PD; } - /// Check if the expression is allowed to be used in expressions for the - /// offloading devices. - void checkDeviceDecl(ValueDecl *D, SourceLocation Loc); + /// Check if the type is allowed to be used for the current target. + void checkTypeSupport(QualType Ty, SourceLocation Loc, + ValueDecl *D = nullptr); enum CUDAFunctionTarget { CFT_Device, @@ -12374,6 +12494,15 @@ public: const VirtSpecifiers *VS = nullptr); void CodeCompleteBracketDeclarator(Scope *S); void CodeCompleteCase(Scope *S); + enum class AttributeCompletion { + Attribute, + Scope, + None, + }; + void CodeCompleteAttribute( + AttributeCommonInfo::Syntax Syntax, + AttributeCompletion Completion = AttributeCompletion::Attribute, + const IdentifierInfo *Scope = nullptr); /// Determines the preferred type of the current function argument, by /// examining the signatures of all possible overloads. /// Returns null if unknown or ambiguous, or if code completion is off. @@ -12625,10 +12754,15 @@ private: int ArgNum, unsigned ExpectedFieldNum, bool AllowName); bool SemaBuiltinARMMemoryTaggingCall(unsigned BuiltinID, CallExpr *TheCall); - bool SemaBuiltinPPCMMACall(CallExpr *TheCall, const char *TypeDesc); + bool SemaBuiltinPPCMMACall(CallExpr *TheCall, unsigned BuiltinID, + const char *TypeDesc); bool CheckPPCMMAType(QualType Type, SourceLocation TypeLoc); + bool SemaBuiltinElementwiseMath(CallExpr *TheCall); + bool SemaBuiltinElementwiseMathOneArg(CallExpr *TheCall); + bool SemaBuiltinReduceMath(CallExpr *TheCall); + // Matrix builtin handling. ExprResult SemaBuiltinMatrixTranspose(CallExpr *TheCall, ExprResult CallResult); diff --git a/contrib/llvm-project/clang/include/clang/Sema/SemaConcept.h b/contrib/llvm-project/clang/include/clang/Sema/SemaConcept.h index c5f9fc45612a..dc5f0ec97e85 100644 --- a/contrib/llvm-project/clang/include/clang/Sema/SemaConcept.h +++ b/contrib/llvm-project/clang/include/clang/Sema/SemaConcept.h @@ -1,9 +1,8 @@ //===-- SemaConcept.h - Semantic Analysis for Constraints and Concepts ----===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// /// diff --git a/contrib/llvm-project/clang/include/clang/Serialization/ASTBitCodes.h b/contrib/llvm-project/clang/include/clang/Serialization/ASTBitCodes.h index 027a981df22c..341da5bd1d62 100644 --- a/contrib/llvm-project/clang/include/clang/Serialization/ASTBitCodes.h +++ b/contrib/llvm-project/clang/include/clang/Serialization/ASTBitCodes.h @@ -402,6 +402,9 @@ enum UnhashedControlBlockRecordTypes { /// Record code for \#pragma diagnostic mappings. DIAG_PRAGMA_MAPPINGS, + + /// Record code for the indices of used header search entries. + HEADER_SEARCH_ENTRY_USAGE, }; /// Record code for extension blocks. @@ -1064,6 +1067,9 @@ enum PredefinedTypeIDs { /// \brief The '__bf16' type PREDEF_TYPE_BFLOAT16_ID = 73, + /// \brief The '__ibm128' type + PREDEF_TYPE_IBM128_ID = 74, + /// OpenCL image types with auto numeration #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ PREDEF_TYPE_##Id##_ID, @@ -1890,6 +1896,7 @@ enum StmtCode { STMT_SEH_TRY, // SEHTryStmt // OpenMP directives + STMT_OMP_META_DIRECTIVE, STMT_OMP_CANONICAL_LOOP, STMT_OMP_PARALLEL_DIRECTIVE, STMT_OMP_SIMD_DIRECTIVE, @@ -1950,6 +1957,7 @@ enum StmtCode { STMT_OMP_INTEROP_DIRECTIVE, STMT_OMP_DISPATCH_DIRECTIVE, STMT_OMP_MASKED_DIRECTIVE, + STMT_OMP_GENERIC_LOOP_DIRECTIVE, EXPR_OMP_ARRAY_SECTION, EXPR_OMP_ARRAY_SHAPING, EXPR_OMP_ITERATOR, diff --git a/contrib/llvm-project/clang/include/clang/Serialization/ASTReader.h b/contrib/llvm-project/clang/include/clang/Serialization/ASTReader.h index 242b75baca6c..f24ccf579aa8 100644 --- a/contrib/llvm-project/clang/include/clang/Serialization/ASTReader.h +++ b/contrib/llvm-project/clang/include/clang/Serialization/ASTReader.h @@ -1162,6 +1162,10 @@ private: /// definitions. Only populated when using modules in C++. llvm::DenseMap<EnumDecl *, EnumDecl *> EnumDefinitions; + /// A mapping from canonical declarations of records to their canonical + /// definitions. Doesn't cover CXXRecordDecl. + llvm::DenseMap<RecordDecl *, RecordDecl *> RecordDefinitions; + /// When reading a Stmt tree, Stmt operands are placed in this stack. SmallVector<Stmt *, 16> StmtStack; @@ -1320,18 +1324,18 @@ private: ASTReaderListener *Listener, bool ValidateDiagnosticOptions); - ASTReadResult ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities); - ASTReadResult ReadExtensionBlock(ModuleFile &F); + llvm::Error ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities); + llvm::Error ReadExtensionBlock(ModuleFile &F); void ReadModuleOffsetMap(ModuleFile &F) const; - bool ParseLineTable(ModuleFile &F, const RecordData &Record); - bool ReadSourceManagerBlock(ModuleFile &F); + void ParseLineTable(ModuleFile &F, const RecordData &Record); + llvm::Error ReadSourceManagerBlock(ModuleFile &F); llvm::BitstreamCursor &SLocCursorForID(int ID); SourceLocation getImportLocation(ModuleFile *F); ASTReadResult ReadModuleMapFileBlock(RecordData &Record, ModuleFile &F, const ModuleFile *ImportedBy, unsigned ClientLoadCapabilities); - ASTReadResult ReadSubmoduleBlock(ModuleFile &F, - unsigned ClientLoadCapabilities); + llvm::Error ReadSubmoduleBlock(ModuleFile &F, + unsigned ClientLoadCapabilities); static bool ParseLanguageOptions(const RecordData &Record, bool Complain, ASTReaderListener &Listener, bool AllowCompatibleDifferences); @@ -1904,8 +1908,9 @@ public: /// ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the /// specified cursor. Read the abbreviations that are at the top of the block /// and then leave the cursor pointing into the block. - static bool ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID, - uint64_t *StartOfBlockOffset = nullptr); + static llvm::Error ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, + unsigned BlockID, + uint64_t *StartOfBlockOffset = nullptr); /// Finds all the visible declarations with a given name. /// The current implementation of this method just loads the entire diff --git a/contrib/llvm-project/clang/include/clang/Serialization/ASTRecordReader.h b/contrib/llvm-project/clang/include/clang/Serialization/ASTRecordReader.h index b85609bf4e05..36179ec23408 100644 --- a/contrib/llvm-project/clang/include/clang/Serialization/ASTRecordReader.h +++ b/contrib/llvm-project/clang/include/clang/Serialization/ASTRecordReader.h @@ -350,7 +350,7 @@ struct SavedStreamPosition { ~SavedStreamPosition() { if (llvm::Error Err = Cursor.JumpToBit(Offset)) llvm::report_fatal_error( - "Cursor should always be able to go back, failed: " + + llvm::Twine("Cursor should always be able to go back, failed: ") + toString(std::move(Err))); } diff --git a/contrib/llvm-project/clang/include/clang/Serialization/ASTWriter.h b/contrib/llvm-project/clang/include/clang/Serialization/ASTWriter.h index ac88cb0a3177..978f6d86ea5c 100644 --- a/contrib/llvm-project/clang/include/clang/Serialization/ASTWriter.h +++ b/contrib/llvm-project/clang/include/clang/Serialization/ASTWriter.h @@ -456,6 +456,9 @@ private: std::vector<std::unique_ptr<ModuleFileExtensionWriter>> ModuleFileExtensionWriters; + /// User ModuleMaps skipped when writing control block. + std::set<const FileEntry *> SkippedModuleMaps; + /// Retrieve or create a submodule ID for this module. unsigned getSubmoduleID(Module *Mod); @@ -475,7 +478,7 @@ private: createSignature(StringRef AllBytes, StringRef ASTBlockBytes); void WriteInputFiles(SourceManager &SourceMgr, HeaderSearchOptions &HSOpts, - bool Modules); + std::set<const FileEntry *> &AffectingModuleMaps); void WriteSourceManagerBlock(SourceManager &SourceMgr, const Preprocessor &PP); void WritePreprocessor(const Preprocessor &PP, bool IsModule); diff --git a/contrib/llvm-project/clang/include/clang/Serialization/ModuleFile.h b/contrib/llvm-project/clang/include/clang/Serialization/ModuleFile.h index b1c8a8c8e72b..b275f8b8db5d 100644 --- a/contrib/llvm-project/clang/include/clang/Serialization/ModuleFile.h +++ b/contrib/llvm-project/clang/include/clang/Serialization/ModuleFile.h @@ -20,6 +20,7 @@ #include "clang/Serialization/ASTBitCodes.h" #include "clang/Serialization/ContinuousRangeMap.h" #include "clang/Serialization/ModuleFileExtension.h" +#include "llvm/ADT/BitVector.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/SetVector.h" @@ -173,6 +174,9 @@ public: /// unique module files based on AST contents. ASTFileSignature ASTBlockHash; + /// The bit vector denoting usage of each header search entry (true = used). + llvm::BitVector SearchPathUsage; + /// Whether this module has been directly imported by the /// user. bool DirectlyImported = false; diff --git a/contrib/llvm-project/clang/include/clang/Serialization/ModuleFileExtension.h b/contrib/llvm-project/clang/include/clang/Serialization/ModuleFileExtension.h index 34ea870724a4..3e84a65c4b80 100644 --- a/contrib/llvm-project/clang/include/clang/Serialization/ModuleFileExtension.h +++ b/contrib/llvm-project/clang/include/clang/Serialization/ModuleFileExtension.h @@ -11,13 +11,14 @@ #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/Support/ExtensibleRTTI.h" +#include "llvm/Support/HashBuilder.h" +#include "llvm/Support/MD5.h" #include <memory> #include <string> namespace llvm { class BitstreamCursor; class BitstreamWriter; -class hash_code; class raw_ostream; } @@ -74,19 +75,20 @@ public: virtual ModuleFileExtensionMetadata getExtensionMetadata() const = 0; /// Hash information about the presence of this extension into the - /// module hash code. + /// module hash. /// - /// The module hash code is used to distinguish different variants - /// of a module that are incompatible. If the presence, absence, or - /// version of the module file extension should force the creation - /// of a separate set of module files, override this method to - /// combine that distinguishing information into the module hash - /// code. + /// The module hash is used to distinguish different variants of a module that + /// are incompatible. If the presence, absence, or version of the module file + /// extension should force the creation of a separate set of module files, + /// override this method to combine that distinguishing information into the + /// module hash. /// - /// The default implementation of this function simply returns the - /// hash code as given, so the presence/absence of this extension - /// does not distinguish module files. - virtual llvm::hash_code hashExtension(llvm::hash_code c) const; + /// The default implementation of this function simply does nothing, so the + /// presence/absence of this extension does not distinguish module files. + using ExtensionHashBuilder = + llvm::HashBuilderImpl<llvm::MD5, + llvm::support::endian::system_endianness()>; + virtual void hashExtension(ExtensionHashBuilder &HBuilder) const; /// Create a new module file extension writer, which will be /// responsible for writing the extension contents into a particular diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td index 444b00d73f0b..bd21d7778f93 100644 --- a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td +++ b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td @@ -73,6 +73,7 @@ def Taint : Package<"taint">, ParentPackage<SecurityAlpha>; def CERT : Package<"cert">, ParentPackage<SecurityAlpha>; def POS : Package<"pos">, ParentPackage<CERT>; +def ENV : Package<"env">, ParentPackage<CERT>; def Unix : Package<"unix">; def UnixAlpha : Package<"unix">, ParentPackage<Alpha>; @@ -485,7 +486,17 @@ def DynamicMemoryModeling: Checker<"DynamicMemoryModeling">, "allocating and deallocating functions are annotated with " "ownership_holds, ownership_takes and ownership_returns.", "false", - InAlpha> + InAlpha>, + CmdLineOption<Boolean, + "AddNoOwnershipChangeNotes", + "Add an additional note to the bug report for leak-like " + "bugs. Dynamically allocated objects passed to functions " + "that neither deallocated it, or have taken responsibility " + "of the ownership are noted, similarly to " + "NoStoreFuncVisitor.", + "true", + Released, + Hide> ]>, Dependencies<[CStringModeling]>, Documentation<NotDocumented>, @@ -592,6 +603,10 @@ def SmartPtrModeling: Checker<"SmartPtrModeling">, ]>, Hidden; +def StringChecker: Checker<"StringChecker">, + HelpText<"Checks C++ std::string bugs">, + Documentation<HasDocumentation>; + def MoveChecker: Checker<"Move">, HelpText<"Find use-after-move bugs in C++">, CheckerOptions<[ @@ -937,6 +952,14 @@ let ParentPackage = POS in { } // end "alpha.cert.pos" +let ParentPackage = ENV in { + + def InvalidPtrChecker : Checker<"InvalidPtr">, + HelpText<"Finds usages of possibly invalidated pointers">, + Documentation<HasDocumentation>; + +} // end "alpha.cert.env" + let ParentPackage = SecurityAlpha in { def ArrayBoundChecker : Checker<"ArrayBound">, diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def index f0359d2dbb3c..aab8e1284bf6 100644 --- a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def +++ b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def @@ -190,7 +190,13 @@ ANALYZER_OPTION(bool, ShouldReportIssuesInMainSourceFile, false) ANALYZER_OPTION(bool, ShouldWriteStableReportFilename, "stable-report-filename", - "Whether or not the report filename should be random or not.", + "Deprecated: report filenames are now always stable. " + "See also 'verbose-report-filename'.", + false) + +ANALYZER_OPTION(bool, ShouldWriteVerboseReportFilename, "verbose-report-filename", + "Whether or not the report filename should contain extra " + "information about the issue.", false) ANALYZER_OPTION( @@ -314,6 +320,22 @@ ANALYZER_OPTION(bool, ShouldDisplayCheckerNameForText, "display-checker-name", "Display the checker name for textual outputs", true) +ANALYZER_OPTION( + bool, ShouldConsiderSingleElementArraysAsFlexibleArrayMembers, + "consider-single-element-arrays-as-flexible-array-members", + "Consider single element arrays as flexible array member candidates. " + "This will prevent the analyzer from assuming that a single element array " + "holds a single element.", + false) + +ANALYZER_OPTION( + bool, ShouldAssumeControlledEnvironment, "assume-controlled-environment", + "Whether the analyzed application runs in a controlled environment. " + "We will assume that environment variables exist in queries and they hold " + "no malicious data. For instance, if this option is enabled, 'getenv()' " + "might be modeled by the analyzer to never return NULL.", + false) + //===----------------------------------------------------------------------===// // Unsigned analyzer options. //===----------------------------------------------------------------------===// diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h index ccf35e0a81ec..7514eee7244f 100644 --- a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h +++ b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h @@ -395,7 +395,11 @@ public: return {FullCompilerInvocation, ShouldDisplayMacroExpansions, ShouldSerializeStats, - ShouldWriteStableReportFilename, + // The stable report filename option is deprecated because + // file names are now always stable. Now the old option acts as + // an alias to the new verbose filename option because this + // closely mimics the behavior under the old option. + ShouldWriteStableReportFilename || ShouldWriteVerboseReportFilename, AnalyzerWerror, ShouldApplyFixIts, ShouldDisplayCheckerNameForText}; diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h index 24cae12af24a..c42521376af9 100644 --- a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h +++ b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h @@ -21,6 +21,7 @@ #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/StringRef.h" #include <list> #include <memory> @@ -622,8 +623,118 @@ public: PathSensitiveBugReport &R) override; }; -} // namespace ento +class ObjCMethodCall; +class CXXConstructorCall; + +/// Put a diagnostic on return statement (or on } in its absence) of all inlined +/// functions for which some property remained unchanged. +/// Resulting diagnostics may read such as "Returning without writing to X". +/// +/// Descendants can define what a "state change is", like a change of value +/// to a memory region, liveness, etc. For function calls where the state did +/// not change as defined, a custom note may be constructed. +/// +/// For a minimal example, check out +/// clang/unittests/StaticAnalyzer/NoStateChangeFuncVisitorTest.cpp. +class NoStateChangeFuncVisitor : public BugReporterVisitor { +private: + /// Frames modifying the state as defined in \c wasModifiedBeforeCallExit. + /// This visitor generates a note only if a function does *not* change the + /// state that way. This information is not immediately available + /// by looking at the node associated with the exit from the function + /// (usually the return statement). To avoid recomputing the same information + /// many times (going up the path for each node and checking whether the + /// region was written into) we instead lazily compute the stack frames + /// along the path. + // TODO: Can't we just use a map instead? This is likely not as cheap as it + // makes the code difficult to read. + llvm::SmallPtrSet<const StackFrameContext *, 32> FramesModifying; + llvm::SmallPtrSet<const StackFrameContext *, 32> FramesModifyingCalculated; + + /// Check and lazily calculate whether the state is modified in the stack + /// frame to which \p CallExitBeginN belongs. + /// The calculation is cached in FramesModifying. + bool isModifiedInFrame(const ExplodedNode *CallExitBeginN); + + void markFrameAsModifying(const StackFrameContext *SCtx); + + /// Write to \c FramesModifying all stack frames along the path in the current + /// stack frame which modifies the state. + void findModifyingFrames(const ExplodedNode *const CallExitBeginN); +protected: + bugreporter::TrackingKind TKind; + + /// \return Whether the state was modified from the current node, \p CurrN, to + /// the end of the stack frame, at \p CallExitBeginN. \p CurrN and + /// \p CallExitBeginN are always in the same stack frame. + /// Clients should override this callback when a state change is important + /// not only on the entire function call, but inside of it as well. + /// Example: we may want to leave a note about the lack of locking/unlocking + /// on a particular mutex, but not if inside the function its state was + /// changed, but also restored. wasModifiedInFunction() wouldn't know of this + /// change. + virtual bool wasModifiedBeforeCallExit(const ExplodedNode *CurrN, + const ExplodedNode *CallExitBeginN) { + return false; + } + + /// \return Whether the state was modified in the inlined function call in + /// between \p CallEnterN and \p CallExitEndN. Mind that the stack frame + /// retrieved from a CallEnterN and CallExitEndN is the *caller's* stack + /// frame! The inlined function's stack should be retrieved from either the + /// immediate successor to \p CallEnterN or immediate predecessor to + /// \p CallExitEndN. + /// Clients should override this function if a state changes local to the + /// inlined function are not interesting, only the change occuring as a + /// result of it. + /// Example: we want to leave a not about a leaked resource object not being + /// deallocated / its ownership changed inside a function, and we don't care + /// if it was assigned to a local variable (its change in ownership is + /// inconsequential). + virtual bool wasModifiedInFunction(const ExplodedNode *CallEnterN, + const ExplodedNode *CallExitEndN) { + return false; + } + + /// Consume the information on the non-modifying stack frame in order to + /// either emit a note or not. May suppress the report entirely. + /// \return Diagnostics piece for the unmodified state in the current + /// function, if it decides to emit one. A good description might start with + /// "Returning without...". + virtual PathDiagnosticPieceRef + maybeEmitNoteForObjCSelf(PathSensitiveBugReport &R, + const ObjCMethodCall &Call, + const ExplodedNode *N) = 0; + + /// Consume the information on the non-modifying stack frame in order to + /// either emit a note or not. May suppress the report entirely. + /// \return Diagnostics piece for the unmodified state in the current + /// function, if it decides to emit one. A good description might start with + /// "Returning without...". + virtual PathDiagnosticPieceRef + maybeEmitNoteForCXXThis(PathSensitiveBugReport &R, + const CXXConstructorCall &Call, + const ExplodedNode *N) = 0; + + /// Consume the information on the non-modifying stack frame in order to + /// either emit a note or not. May suppress the report entirely. + /// \return Diagnostics piece for the unmodified state in the current + /// function, if it decides to emit one. A good description might start with + /// "Returning without...". + virtual PathDiagnosticPieceRef + maybeEmitNoteForParameters(PathSensitiveBugReport &R, const CallEvent &Call, + const ExplodedNode *N) = 0; + +public: + NoStateChangeFuncVisitor(bugreporter::TrackingKind TKind) : TKind(TKind) {} + + PathDiagnosticPieceRef VisitNode(const ExplodedNode *N, + BugReporterContext &BR, + PathSensitiveBugReport &R) override final; +}; + +} // namespace ento } // namespace clang #endif // LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGREPORTERVISITORS_H diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h new file mode 100644 index 000000000000..396c9a4de440 --- /dev/null +++ b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h @@ -0,0 +1,173 @@ +//===- CallDescription.h - function/method call matching --*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +/// \file This file defines a generic mechanism for matching for function and +/// method calls of C, C++, and Objective-C languages. Instances of these +/// classes are frequently used together with the CallEvent classes. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CALLDESCRIPTION_H +#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CALLDESCRIPTION_H + +#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/Optional.h" +#include "llvm/Support/Compiler.h" +#include <vector> + +namespace clang { +class IdentifierInfo; +} // namespace clang + +namespace clang { +namespace ento { + +enum CallDescriptionFlags : unsigned { + CDF_None = 0, + + /// Describes a C standard function that is sometimes implemented as a macro + /// that expands to a compiler builtin with some __builtin prefix. + /// The builtin may as well have a few extra arguments on top of the requested + /// number of arguments. + CDF_MaybeBuiltin = 1 << 0, +}; + +/// This class represents a description of a function call using the number of +/// arguments and the name of the function. +class CallDescription { + friend class CallEvent; + using MaybeCount = Optional<unsigned>; + + mutable Optional<const IdentifierInfo *> II; + // The list of the qualified names used to identify the specified CallEvent, + // e.g. "{a, b}" represent the qualified names, like "a::b". + std::vector<std::string> QualifiedName; + MaybeCount RequiredArgs; + MaybeCount RequiredParams; + int Flags; + +public: + /// Constructs a CallDescription object. + /// + /// @param QualifiedName The list of the name qualifiers of the function that + /// will be matched. The user is allowed to skip any of the qualifiers. + /// For example, {"std", "basic_string", "c_str"} would match both + /// std::basic_string<...>::c_str() and std::__1::basic_string<...>::c_str(). + /// + /// @param RequiredArgs The number of arguments that is expected to match a + /// call. Omit this parameter to match every occurrence of call with a given + /// name regardless the number of arguments. + CallDescription(CallDescriptionFlags Flags, + ArrayRef<const char *> QualifiedName, + MaybeCount RequiredArgs = None, + MaybeCount RequiredParams = None); + + /// Construct a CallDescription with default flags. + CallDescription(ArrayRef<const char *> QualifiedName, + MaybeCount RequiredArgs = None, + MaybeCount RequiredParams = None); + + CallDescription(std::nullptr_t) = delete; + + /// Get the name of the function that this object matches. + StringRef getFunctionName() const { return QualifiedName.back(); } + + /// Get the qualified name parts in reversed order. + /// E.g. { "std", "vector", "data" } -> "vector", "std" + auto begin_qualified_name_parts() const { + return std::next(QualifiedName.rbegin()); + } + auto end_qualified_name_parts() const { return QualifiedName.rend(); } + + /// It's false, if and only if we expect a single identifier, such as + /// `getenv`. It's true for `std::swap`, or `my::detail::container::data`. + bool hasQualifiedNameParts() const { return QualifiedName.size() > 1; } + + /// @name Matching CallDescriptions against a CallEvent + /// @{ + + /// Returns true if the CallEvent is a call to a function that matches + /// the CallDescription. + /// + /// \note This function is not intended to be used to match Obj-C method + /// calls. + bool matches(const CallEvent &Call) const; + + /// Returns true whether the CallEvent matches on any of the CallDescriptions + /// supplied. + /// + /// \note This function is not intended to be used to match Obj-C method + /// calls. + friend bool matchesAny(const CallEvent &Call, const CallDescription &CD1) { + return CD1.matches(Call); + } + + /// \copydoc clang::ento::matchesAny(const CallEvent &, const CallDescription &) + template <typename... Ts> + friend bool matchesAny(const CallEvent &Call, const CallDescription &CD1, + const Ts &...CDs) { + return CD1.matches(Call) || matchesAny(Call, CDs...); + } + /// @} +}; + +/// An immutable map from CallDescriptions to arbitrary data. Provides a unified +/// way for checkers to react on function calls. +template <typename T> class CallDescriptionMap { + friend class CallDescriptionSet; + + // Some call descriptions aren't easily hashable (eg., the ones with qualified + // names in which some sections are omitted), so let's put them + // in a simple vector and use linear lookup. + // TODO: Implement an actual map for fast lookup for "hashable" call + // descriptions (eg., the ones for C functions that just match the name). + std::vector<std::pair<CallDescription, T>> LinearMap; + +public: + CallDescriptionMap( + std::initializer_list<std::pair<CallDescription, T>> &&List) + : LinearMap(List) {} + + ~CallDescriptionMap() = default; + + // These maps are usually stored once per checker, so let's make sure + // we don't do redundant copies. + CallDescriptionMap(const CallDescriptionMap &) = delete; + CallDescriptionMap &operator=(const CallDescription &) = delete; + + LLVM_NODISCARD const T *lookup(const CallEvent &Call) const { + // Slow path: linear lookup. + // TODO: Implement some sort of fast path. + for (const std::pair<CallDescription, T> &I : LinearMap) + if (I.first.matches(Call)) + return &I.second; + + return nullptr; + } +}; + +/// An immutable set of CallDescriptions. +/// Checkers can efficiently decide if a given CallEvent matches any +/// CallDescription in the set. +class CallDescriptionSet { + CallDescriptionMap<bool /*unused*/> Impl = {}; + +public: + CallDescriptionSet(std::initializer_list<CallDescription> &&List); + + CallDescriptionSet(const CallDescriptionSet &) = delete; + CallDescriptionSet &operator=(const CallDescription &) = delete; + + LLVM_NODISCARD bool contains(const CallEvent &Call) const; +}; + +} // namespace ento +} // namespace clang + +#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CALLDESCRIPTION_H diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h index 060fff1a7407..d135e70dd75d 100644 --- a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h +++ b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h @@ -257,20 +257,6 @@ public: return false; } - /// Returns true if the CallEvent is a call to a function that matches - /// the CallDescription. - /// - /// Note that this function is not intended to be used to match Obj-C method - /// calls. - bool isCalled(const CallDescription &CD) const; - - /// Returns true whether the CallEvent is any of the CallDescriptions supplied - /// as a parameter. - template <typename FirstCallDesc, typename... CallDescs> - bool isCalled(const FirstCallDesc &First, const CallDescs &... Rest) const { - return isCalled(First) || isCalled(Rest...); - } - /// Returns a source range for the entire call, suitable for /// outputting in diagnostics. virtual SourceRange getSourceRange() const { @@ -1225,99 +1211,6 @@ public: } }; -enum CallDescriptionFlags : int { - /// Describes a C standard function that is sometimes implemented as a macro - /// that expands to a compiler builtin with some __builtin prefix. - /// The builtin may as well have a few extra arguments on top of the requested - /// number of arguments. - CDF_MaybeBuiltin = 1 << 0, -}; - -/// This class represents a description of a function call using the number of -/// arguments and the name of the function. -class CallDescription { - friend CallEvent; - - mutable IdentifierInfo *II = nullptr; - mutable bool IsLookupDone = false; - // The list of the qualified names used to identify the specified CallEvent, - // e.g. "{a, b}" represent the qualified names, like "a::b". - std::vector<const char *> QualifiedName; - Optional<unsigned> RequiredArgs; - Optional<size_t> RequiredParams; - int Flags; - - // A constructor helper. - static Optional<size_t> readRequiredParams(Optional<unsigned> RequiredArgs, - Optional<size_t> RequiredParams) { - if (RequiredParams) - return RequiredParams; - if (RequiredArgs) - return static_cast<size_t>(*RequiredArgs); - return None; - } - -public: - /// Constructs a CallDescription object. - /// - /// @param QualifiedName The list of the name qualifiers of the function that - /// will be matched. The user is allowed to skip any of the qualifiers. - /// For example, {"std", "basic_string", "c_str"} would match both - /// std::basic_string<...>::c_str() and std::__1::basic_string<...>::c_str(). - /// - /// @param RequiredArgs The number of arguments that is expected to match a - /// call. Omit this parameter to match every occurrence of call with a given - /// name regardless the number of arguments. - CallDescription(int Flags, ArrayRef<const char *> QualifiedName, - Optional<unsigned> RequiredArgs = None, - Optional<size_t> RequiredParams = None) - : QualifiedName(QualifiedName), RequiredArgs(RequiredArgs), - RequiredParams(readRequiredParams(RequiredArgs, RequiredParams)), - Flags(Flags) {} - - /// Construct a CallDescription with default flags. - CallDescription(ArrayRef<const char *> QualifiedName, - Optional<unsigned> RequiredArgs = None, - Optional<size_t> RequiredParams = None) - : CallDescription(0, QualifiedName, RequiredArgs, RequiredParams) {} - - /// Get the name of the function that this object matches. - StringRef getFunctionName() const { return QualifiedName.back(); } -}; - -/// An immutable map from CallDescriptions to arbitrary data. Provides a unified -/// way for checkers to react on function calls. -template <typename T> class CallDescriptionMap { - // Some call descriptions aren't easily hashable (eg., the ones with qualified - // names in which some sections are omitted), so let's put them - // in a simple vector and use linear lookup. - // TODO: Implement an actual map for fast lookup for "hashable" call - // descriptions (eg., the ones for C functions that just match the name). - std::vector<std::pair<CallDescription, T>> LinearMap; - -public: - CallDescriptionMap( - std::initializer_list<std::pair<CallDescription, T>> &&List) - : LinearMap(List) {} - - ~CallDescriptionMap() = default; - - // These maps are usually stored once per checker, so let's make sure - // we don't do redundant copies. - CallDescriptionMap(const CallDescriptionMap &) = delete; - CallDescriptionMap &operator=(const CallDescription &) = delete; - - const T *lookup(const CallEvent &Call) const { - // Slow path: linear lookup. - // TODO: Implement some sort of fast path. - for (const std::pair<CallDescription, T> &I : LinearMap) - if (Call.isCalled(I.first)) - return &I.second; - - return nullptr; - } -}; - /// Manages the lifetime of CallEvent objects. /// /// CallEventManager provides a way to create arbitrary CallEvents "on the diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h index c67df1e51b4f..a80484610131 100644 --- a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h +++ b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h @@ -48,6 +48,7 @@ public: ID.AddPointer(&To()); } void dump(raw_ostream &OS) const; + void dump() const; // In order to keep non-overlapping ranges sorted, we can compare only From // points. @@ -281,7 +282,27 @@ public: /// where N = size(this) bool contains(llvm::APSInt Point) const { return containsImpl(Point); } + bool containsZero() const { + APSIntType T{getMinValue()}; + return contains(T.getZeroValue()); + } + + /// Test if the range is the [0,0] range. + /// + /// Complexity: O(1) + bool encodesFalseRange() const { + const llvm::APSInt *Constant = getConcreteValue(); + return Constant && Constant->isZero(); + } + + /// Test if the range doesn't contain zero. + /// + /// Complexity: O(logN) + /// where N = size(this) + bool encodesTrueRange() const { return !containsZero(); } + void dump(raw_ostream &OS) const; + void dump() const; bool operator==(const RangeSet &Other) const { return *Impl == *Other.Impl; } bool operator!=(const RangeSet &Other) const { return !(*this == Other); } @@ -387,11 +408,22 @@ private: static void computeAdjustment(SymbolRef &Sym, llvm::APSInt &Adjustment); }; -/// Try to simplify a given symbolic expression's associated value based on the -/// constraints in State. This is needed because the Environment bindings are -/// not getting updated when a new constraint is added to the State. +/// Try to simplify a given symbolic expression based on the constraints in +/// State. This is needed because the Environment bindings are not getting +/// updated when a new constraint is added to the State. If the symbol is +/// simplified to a non-symbol (e.g. to a constant) then the original symbol +/// is returned. We use this function in the family of assumeSymNE/EQ/LT/../GE +/// functions where we can work only with symbols. Use the other function +/// (simplifyToSVal) if you are interested in a simplification that may yield +/// a concrete constant value. SymbolRef simplify(ProgramStateRef State, SymbolRef Sym); +/// Try to simplify a given symbolic expression's associated `SVal` based on the +/// constraints in State. This is very similar to `simplify`, but this function +/// always returns the simplified SVal. The simplified SVal might be a single +/// constant (i.e. `ConcreteInt`). +SVal simplifyToSVal(ProgramStateRef State, SymbolRef Sym); + } // namespace ento } // namespace clang diff --git a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h index 87a49cf4ffe9..61dfdbb0688b 100644 --- a/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h +++ b/contrib/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h @@ -33,6 +33,7 @@ namespace clang { +class AnalyzerOptions; class BlockDecl; class CXXBoolLiteralExpr; class CXXMethodDecl; @@ -66,6 +67,8 @@ protected: ProgramStateManager &StateMgr; + const AnalyzerOptions &AnOpts; + /// The scalar type to use for array indices. const QualType ArrayIndexTy; @@ -96,11 +99,7 @@ protected: public: SValBuilder(llvm::BumpPtrAllocator &alloc, ASTContext &context, - ProgramStateManager &stateMgr) - : Context(context), BasicVals(context, alloc), - SymMgr(context, BasicVals, alloc), MemMgr(context, alloc), - StateMgr(stateMgr), ArrayIndexTy(context.LongLongTy), - ArrayIndexWidth(context.getTypeSize(ArrayIndexTy)) {} + ProgramStateManager &stateMgr); virtual ~SValBuilder() = default; @@ -188,6 +187,8 @@ public: MemRegionManager &getRegionManager() { return MemMgr; } const MemRegionManager &getRegionManager() const { return MemMgr; } + const AnalyzerOptions &getAnalyzerOptions() const { return AnOpts; } + // Forwarding methods to SymbolManager. const SymbolConjured* conjureSymbol(const Stmt *stmt, diff --git a/contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h b/contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h index 76edf150dbee..d58e736ab6a6 100644 --- a/contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h +++ b/contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h @@ -48,7 +48,8 @@ class DependencyScanningService { public: DependencyScanningService(ScanningMode Mode, ScanningOutputFormat Format, bool ReuseFileManager = true, - bool SkipExcludedPPRanges = true); + bool SkipExcludedPPRanges = true, + bool OptimizeArgs = false); ScanningMode getMode() const { return Mode; } @@ -58,6 +59,8 @@ public: bool canSkipExcludedPPRanges() const { return SkipExcludedPPRanges; } + bool canOptimizeArgs() const { return OptimizeArgs; } + DependencyScanningFilesystemSharedCache &getSharedCache() { return SharedCache; } @@ -70,6 +73,8 @@ private: /// ranges by bumping the buffer pointer in the lexer instead of lexing the /// tokens in the range until reaching the corresponding directive. const bool SkipExcludedPPRanges; + /// Whether to optimize the modules' command-line arguments. + const bool OptimizeArgs; /// The global file system cache. DependencyScanningFilesystemSharedCache SharedCache; }; diff --git a/contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h b/contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h index f88dc472c80b..9e2ff82f5614 100644 --- a/contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h +++ b/contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h @@ -77,16 +77,18 @@ public: /// Print out the dependency information into a string using the dependency /// file format that is specified in the options (-MD is the default) and - /// return it. + /// return it. If \p ModuleName isn't empty, this function returns the + /// dependency information of module \p ModuleName. /// /// \returns A \c StringError with the diagnostic output if clang errors /// occurred, dependency file contents otherwise. llvm::Expected<std::string> - getDependencyFile(const tooling::CompilationDatabase &Compilations, - StringRef CWD); + getDependencyFile(const std::vector<std::string> &CommandLine, StringRef CWD, + llvm::Optional<StringRef> ModuleName = None); /// Collect the full module dependency graph for the input, ignoring any - /// modules which have already been seen. + /// modules which have already been seen. If \p ModuleName isn't empty, this + /// function returns the full dependency information of module \p ModuleName. /// /// \param AlreadySeen This stores modules which have previously been /// reported. Use the same instance for all calls to this @@ -97,8 +99,9 @@ public: /// \returns a \c StringError with the diagnostic output if clang errors /// occurred, \c FullDependencies otherwise. llvm::Expected<FullDependenciesResult> - getFullDependencies(const tooling::CompilationDatabase &Compilations, - StringRef CWD, const llvm::StringSet<> &AlreadySeen); + getFullDependencies(const std::vector<std::string> &CommandLine, + StringRef CWD, const llvm::StringSet<> &AlreadySeen, + llvm::Optional<StringRef> ModuleName = None); private: DependencyScanningWorker Worker; diff --git a/contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h b/contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h index 5903ad13c1d8..0f3a5369a021 100644 --- a/contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h +++ b/contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h @@ -14,7 +14,6 @@ #include "clang/Basic/LLVM.h" #include "clang/Frontend/PCHContainerOperations.h" #include "clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h" -#include "clang/Tooling/CompilationDatabase.h" #include "clang/Tooling/DependencyScanning/DependencyScanningService.h" #include "clang/Tooling/DependencyScanning/ModuleDepCollector.h" #include "llvm/Support/Error.h" @@ -56,31 +55,36 @@ class DependencyScanningWorker { public: DependencyScanningWorker(DependencyScanningService &Service); - /// Run the dependency scanning tool for a given clang driver invocation (as - /// specified for the given Input in the CDB), and report the discovered - /// dependencies to the provided consumer. + /// Run the dependency scanning tool for a given clang driver command-line, + /// and report the discovered dependencies to the provided consumer. If \p + /// ModuleName isn't empty, this function reports the dependencies of module + /// \p ModuleName. /// /// \returns A \c StringError with the diagnostic output if clang errors /// occurred, success otherwise. - llvm::Error computeDependencies(const std::string &Input, - StringRef WorkingDirectory, - const CompilationDatabase &CDB, - DependencyConsumer &Consumer); + llvm::Error computeDependencies(StringRef WorkingDirectory, + const std::vector<std::string> &CommandLine, + DependencyConsumer &Consumer, + llvm::Optional<StringRef> ModuleName = None); private: - IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts; std::shared_ptr<PCHContainerOperations> PCHContainerOps; std::unique_ptr<ExcludedPreprocessorDirectiveSkipMapping> PPSkipMappings; + /// The physical filesystem overlaid by `InMemoryFS`. llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> RealFS; + /// The in-memory filesystem laid on top the physical filesystem in `RealFS`. + llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFS; /// The file system that is used by each worker when scanning for - /// dependencies. This filesystem persists accross multiple compiler + /// dependencies. This filesystem persists across multiple compiler /// invocations. llvm::IntrusiveRefCntPtr<DependencyScanningWorkerFilesystem> DepFS; - /// The file manager that is reused accross multiple invocations by this + /// The file manager that is reused across multiple invocations by this /// worker. If null, the file manager will not be reused. llvm::IntrusiveRefCntPtr<FileManager> Files; ScanningOutputFormat Format; + /// Whether to optimize the modules' command-line arguments. + bool OptimizeArgs; }; } // end namespace dependencies diff --git a/contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h b/contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h index a9f2b4d0c6fc..e61147d6f2b0 100644 --- a/contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h +++ b/contrib/llvm-project/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h @@ -1,9 +1,8 @@ //===- ModuleDepCollector.h - Callbacks to collect deps ---------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -102,7 +101,7 @@ struct ModuleDeps { bool ImportedByMainFile = false; /// Compiler invocation that can be used to build this module (without paths). - CompilerInvocation Invocation; + CompilerInvocation BuildInvocation; /// Gets the canonical command line suitable for passing to clang. /// @@ -142,8 +141,7 @@ class ModuleDepCollector; /// \c DependencyConsumer of the parent \c ModuleDepCollector. class ModuleDepCollectorPP final : public PPCallbacks { public: - ModuleDepCollectorPP(CompilerInstance &I, ModuleDepCollector &MDC) - : Instance(I), MDC(MDC) {} + ModuleDepCollectorPP(ModuleDepCollector &MDC) : MDC(MDC) {} void FileChanged(SourceLocation Loc, FileChangeReason Reason, SrcMgr::CharacteristicKind FileType, @@ -160,8 +158,6 @@ public: void EndOfMainFile() override; private: - /// The compiler instance for the current translation unit. - CompilerInstance &Instance; /// The parent dependency collector. ModuleDepCollector &MDC; /// Working set of direct modular dependencies. @@ -173,7 +169,11 @@ private: /// Adds direct modular dependencies that have already been built to the /// ModuleDeps instance. - void addDirectPrebuiltModuleDeps(const Module *M, ModuleDeps &MD); + void + addAllSubmodulePrebuiltDeps(const Module *M, ModuleDeps &MD, + llvm::DenseSet<const Module *> &SeenSubmodules); + void addModulePrebuiltDeps(const Module *M, ModuleDeps &MD, + llvm::DenseSet<const Module *> &SeenSubmodules); /// Traverses the previously collected direct modular dependencies to discover /// transitive modular dependencies and fills the parent \c ModuleDepCollector @@ -190,8 +190,8 @@ private: class ModuleDepCollector final : public DependencyCollector { public: ModuleDepCollector(std::unique_ptr<DependencyOutputOptions> Opts, - CompilerInstance &I, DependencyConsumer &C, - CompilerInvocation &&OriginalCI); + CompilerInstance &ScanInstance, DependencyConsumer &C, + CompilerInvocation &&OriginalCI, bool OptimizeArgs); void attachToPreprocessor(Preprocessor &PP) override; void attachToASTReader(ASTReader &R) override; @@ -199,8 +199,8 @@ public: private: friend ModuleDepCollectorPP; - /// The compiler instance for the current translation unit. - CompilerInstance &Instance; + /// The compiler instance for scanning the current translation unit. + CompilerInstance &ScanInstance; /// The consumer of collected dependency information. DependencyConsumer &Consumer; /// Path to the main source file. @@ -216,6 +216,8 @@ private: std::unique_ptr<DependencyOutputOptions> Opts; /// The original Clang invocation passed to dependency scanner. CompilerInvocation OriginalInvocation; + /// Whether to optimize the modules' command-line arguments. + bool OptimizeArgs; /// Checks whether the module is known as being prebuilt. bool isPrebuiltModule(const Module *M); @@ -223,8 +225,9 @@ private: /// Constructs a CompilerInvocation that can be used to build the given /// module, excluding paths to discovered modular dependencies that are yet to /// be built. - CompilerInvocation - makeInvocationForModuleBuildWithoutPaths(const ModuleDeps &Deps) const; + CompilerInvocation makeInvocationForModuleBuildWithoutPaths( + const ModuleDeps &Deps, + llvm::function_ref<void(CompilerInvocation &)> Optimize) const; }; } // end namespace dependencies diff --git a/contrib/llvm-project/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h b/contrib/llvm-project/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h index 02fb2875671a..c1b7baec7ec5 100644 --- a/contrib/llvm-project/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h +++ b/contrib/llvm-project/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h @@ -84,7 +84,7 @@ private: // An include header quoted with either <> or "". std::string Name; - // The range of the whole line of include directive including any eading + // The range of the whole line of include directive including any leading // whitespaces and trailing comment. tooling::Range R; }; @@ -127,7 +127,6 @@ private: llvm::Regex IncludeRegex; }; - } // namespace tooling } // namespace clang diff --git a/contrib/llvm-project/clang/include/clang/Tooling/Inclusions/IncludeStyle.h b/contrib/llvm-project/clang/include/clang/Tooling/Inclusions/IncludeStyle.h index 4caaf4121f15..d54f8a402e2d 100644 --- a/contrib/llvm-project/clang/include/clang/Tooling/Inclusions/IncludeStyle.h +++ b/contrib/llvm-project/clang/include/clang/Tooling/Inclusions/IncludeStyle.h @@ -50,6 +50,7 @@ struct IncludeStyle { /// Dependent on the value, multiple ``#include`` blocks can be sorted /// as one and divided based on category. + /// \version 7 IncludeBlocksStyle IncludeBlocks; /// See documentation of ``IncludeCategories``. @@ -113,6 +114,7 @@ struct IncludeStyle { /// Priority: 1 /// SortPriority: 0 /// \endcode + /// \version 7 std::vector<IncludeCategory> IncludeCategories; /// Specify a regular expression of suffixes that are allowed in the @@ -126,6 +128,7 @@ struct IncludeStyle { /// /// For example, if configured to "(_test)?$", then a header a.h would be seen /// as the "main" include in both a.cc and a_test.cc. + /// \version 7 std::string IncludeIsMainRegex; /// Specify a regular expression for files being formatted @@ -146,6 +149,7 @@ struct IncludeStyle { /// also being respected in later phase). Without this option set, /// ``ClassImpl.hpp`` would not have the main include file put on top /// before any other include. + /// \version 7 std::string IncludeIsMainSourceRegex; }; diff --git a/contrib/llvm-project/clang/include/clang/Tooling/Tooling.h b/contrib/llvm-project/clang/include/clang/Tooling/Tooling.h index 73d09662562b..c9c6a2ffb7b3 100644 --- a/contrib/llvm-project/clang/include/clang/Tooling/Tooling.h +++ b/contrib/llvm-project/clang/include/clang/Tooling/Tooling.h @@ -115,7 +115,7 @@ public: /// T must derive from clang::FrontendAction. /// /// Example: -/// FrontendActionFactory *Factory = +/// std::unique_ptr<FrontendActionFactory> Factory = /// newFrontendActionFactory<clang::SyntaxOnlyAction>(); template <typename T> std::unique_ptr<FrontendActionFactory> newFrontendActionFactory(); @@ -145,7 +145,7 @@ public: /// /// Example: /// struct ProvidesASTConsumers { -/// clang::ASTConsumer *newASTConsumer(); +/// std::unique_ptr<clang::ASTConsumer> newASTConsumer(); /// } Factory; /// std::unique_ptr<FrontendActionFactory> FactoryAdapter( /// newFrontendActionFactory(&Factory)); @@ -268,11 +268,17 @@ public: ~ToolInvocation(); - /// Set a \c DiagnosticConsumer to use during parsing. + /// Set a \c DiagnosticConsumer to use during driver command-line parsing and + /// the action invocation itself. void setDiagnosticConsumer(DiagnosticConsumer *DiagConsumer) { this->DiagConsumer = DiagConsumer; } + /// Set a \c DiagnosticOptions to use during driver command-line parsing. + void setDiagnosticOptions(DiagnosticOptions *DiagOpts) { + this->DiagOpts = DiagOpts; + } + /// Run the clang invocation. /// /// \returns True if there were no errors during execution. @@ -290,6 +296,7 @@ public: FileManager *Files; std::shared_ptr<PCHContainerOperations> PCHContainerOps; DiagnosticConsumer *DiagConsumer = nullptr; + DiagnosticOptions *DiagOpts = nullptr; }; /// Utility to run a FrontendAction over a set of files. diff --git a/contrib/llvm-project/clang/include/clang/Tooling/Transformer/RangeSelector.h b/contrib/llvm-project/clang/include/clang/Tooling/Transformer/RangeSelector.h index 8ff31f7a0342..38ec24efec65 100644 --- a/contrib/llvm-project/clang/include/clang/Tooling/Transformer/RangeSelector.h +++ b/contrib/llvm-project/clang/include/clang/Tooling/Transformer/RangeSelector.h @@ -50,7 +50,7 @@ inline RangeSelector range(std::string BeginID, std::string EndID) { /// Selects the (empty) range [B,B) when \p Selector selects the range [B,E). RangeSelector before(RangeSelector Selector); -/// Selects the the point immediately following \p Selector. That is, the +/// Selects the point immediately following \p Selector. That is, the /// (empty) range [E,E), when \p Selector selects either /// * the CharRange [B,E) or /// * the TokenRange [B,E'] where the token at E' spans the range [E',E). diff --git a/contrib/llvm-project/clang/include/clang/Tooling/Transformer/Stencil.h b/contrib/llvm-project/clang/include/clang/Tooling/Transformer/Stencil.h index 1b7495eb0262..249f95b7391d 100644 --- a/contrib/llvm-project/clang/include/clang/Tooling/Transformer/Stencil.h +++ b/contrib/llvm-project/clang/include/clang/Tooling/Transformer/Stencil.h @@ -117,6 +117,38 @@ inline Stencil ifBound(llvm::StringRef Id, llvm::StringRef TrueText, detail::makeStencil(FalseText)); } +/// Chooses between multiple stencils, based on the presence of bound nodes. \p +/// CaseStencils takes a vector of (ID, \c Stencil) pairs and checks each ID in +/// order to see if it's bound to a node. If so, the associated \c Stencil is +/// run and all other cases are ignored. An optional \p DefaultStencil can be +/// provided to be run if all cases are exhausted beacause none of the provided +/// IDs are bound. If no default case is provided and all cases are exhausted, +/// the stencil will fail with error `llvm::errc::result_out_of_range`. +/// +/// For example, say one matches a statement's type with: +/// anyOf( +/// qualType(isInteger()).bind("int"), +/// qualType(realFloatingPointType()).bind("float"), +/// qualType(isAnyCharacter()).bind("char"), +/// booleanType().bind("bool")) +/// +/// Then, one can decide in a stencil how to construct a literal. +/// cat("a = ", +/// selectBound( +/// {{"int", cat("0")}, +/// {"float", cat("0.0")}, +/// {"char", cat("'\\0'")}, +/// {"bool", cat("false")}})) +/// +/// In addition, one could supply a default case for all other types: +/// selectBound( +/// {{"int", cat("0")}, +/// ... +/// {"bool", cat("false")}}, +/// cat("{}")) +Stencil selectBound(std::vector<std::pair<std::string, Stencil>> CaseStencils, + Stencil DefaultStencil = nullptr); + /// Wraps a \c MatchConsumer in a \c Stencil, so that it can be used in a \c /// Stencil. This supports user-defined extensions to the \c Stencil language. Stencil run(MatchConsumer<std::string> C); diff --git a/contrib/llvm-project/clang/include/clang/module.modulemap b/contrib/llvm-project/clang/include/clang/module.modulemap index 33fcf9dc7576..e850a1cd4b9a 100644 --- a/contrib/llvm-project/clang/include/clang/module.modulemap +++ b/contrib/llvm-project/clang/include/clang/module.modulemap @@ -45,6 +45,7 @@ module Clang_Basic { textual header "Basic/BuiltinsNVPTX.def" textual header "Basic/BuiltinsPPC.def" textual header "Basic/BuiltinsRISCV.def" + textual header "Basic/BuiltinsRISCVVector.def" textual header "Basic/BuiltinsSVE.def" textual header "Basic/BuiltinsSystemZ.def" textual header "Basic/BuiltinsWebAssembly.def" @@ -67,7 +68,6 @@ module Clang_Basic { textual header "Basic/Sanitizers.def" textual header "Basic/TargetCXXABI.def" textual header "Basic/TokenKinds.def" - textual header "Basic/X86Target.def" module * { export * } } |