aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/include/clang/AST/ASTContext.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/clang/include/clang/AST/ASTContext.h')
-rw-r--r--contrib/llvm-project/clang/include/clang/AST/ASTContext.h585
1 files changed, 418 insertions, 167 deletions
diff --git a/contrib/llvm-project/clang/include/clang/AST/ASTContext.h b/contrib/llvm-project/clang/include/clang/AST/ASTContext.h
index ae69a68608b7..3e46a5da3fc0 100644
--- a/contrib/llvm-project/clang/include/clang/AST/ASTContext.h
+++ b/contrib/llvm-project/clang/include/clang/AST/ASTContext.h
@@ -14,64 +14,32 @@
#ifndef LLVM_CLANG_AST_ASTCONTEXT_H
#define LLVM_CLANG_AST_ASTCONTEXT_H
-#include "clang/AST/ASTContextAllocate.h"
#include "clang/AST/ASTFwd.h"
#include "clang/AST/CanonicalType.h"
#include "clang/AST/CommentCommandTraits.h"
#include "clang/AST/ComparisonCategories.h"
#include "clang/AST/Decl.h"
-#include "clang/AST/DeclBase.h"
#include "clang/AST/DeclarationName.h"
#include "clang/AST/ExternalASTSource.h"
-#include "clang/AST/NestedNameSpecifier.h"
#include "clang/AST/PrettyPrinter.h"
#include "clang/AST/RawCommentList.h"
#include "clang/AST/TemplateName.h"
-#include "clang/AST/Type.h"
-#include "clang/Basic/AddressSpaces.h"
-#include "clang/Basic/AttrKinds.h"
-#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/LLVM.h"
-#include "clang/Basic/LangOptions.h"
-#include "clang/Basic/Linkage.h"
-#include "clang/Basic/OperatorKinds.h"
#include "clang/Basic/PartialDiagnostic.h"
-#include "clang/Basic/ProfileList.h"
-#include "clang/Basic/SanitizerBlacklist.h"
#include "clang/Basic/SourceLocation.h"
-#include "clang/Basic/Specifiers.h"
-#include "clang/Basic/XRayLists.h"
-#include "llvm/ADT/APSInt.h"
-#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/MapVector.h"
-#include "llvm/ADT/None.h"
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/TinyPtrVector.h"
-#include "llvm/ADT/Triple.h"
-#include "llvm/ADT/iterator_range.h"
-#include "llvm/Support/AlignOf.h"
-#include "llvm/Support/Allocator.h"
-#include "llvm/Support/Casting.h"
-#include "llvm/Support/Compiler.h"
#include "llvm/Support/TypeSize.h"
-#include <cassert>
-#include <cstddef>
-#include <cstdint>
-#include <iterator>
-#include <memory>
-#include <string>
-#include <type_traits>
-#include <utility>
-#include <vector>
+#include <optional>
namespace llvm {
@@ -89,6 +57,7 @@ class ASTMutationListener;
class ASTRecordLayout;
class AtomicExpr;
class BlockExpr;
+struct BlockVarCopyInit;
class BuiltinTemplateDecl;
class CharUnits;
class ConceptDecl;
@@ -97,17 +66,19 @@ class CXXConstructorDecl;
class CXXMethodDecl;
class CXXRecordDecl;
class DiagnosticsEngine;
-class ParentMapContext;
-class DynTypedNode;
class DynTypedNodeList;
class Expr;
+enum class FloatModeKind;
class GlobalDecl;
+class IdentifierTable;
+class LangOptions;
class MangleContext;
class MangleNumberingContext;
-class MaterializeTemporaryExpr;
class MemberSpecializationInfo;
class Module;
struct MSGuidDeclParts;
+class NestedNameSpecifier;
+class NoSanitizeList;
class ObjCCategoryDecl;
class ObjCCategoryImplDecl;
class ObjCContainerDecl;
@@ -121,9 +92,10 @@ class ObjCPropertyImplDecl;
class ObjCProtocolDecl;
class ObjCTypeParamDecl;
class OMPTraitInfo;
+class ParentMapContext;
struct ParsedTargetAttr;
class Preprocessor;
-class Stmt;
+class ProfileList;
class StoredDeclsMap;
class TargetAttr;
class TargetInfo;
@@ -131,11 +103,12 @@ class TemplateDecl;
class TemplateParameterList;
class TemplateTemplateParmDecl;
class TemplateTypeParmDecl;
+class TypeConstraint;
class UnresolvedSetIterator;
class UsingShadowDecl;
class VarTemplateDecl;
class VTableContextBase;
-struct BlockVarCopyInit;
+class XRayFunctionFilter;
namespace Builtin {
@@ -162,24 +135,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
@@ -190,7 +185,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
mutable SmallVector<Type *, 0> Types;
mutable llvm::FoldingSet<ExtQuals> ExtQualNodes;
mutable llvm::FoldingSet<ComplexType> ComplexTypes;
- mutable llvm::FoldingSet<PointerType> PointerTypes;
+ mutable llvm::FoldingSet<PointerType> PointerTypes{GeneralTypesLog2InitSize};
mutable llvm::FoldingSet<AdjustedType> AdjustedTypes;
mutable llvm::FoldingSet<BlockPointerType> BlockPointerTypes;
mutable llvm::FoldingSet<LValueReferenceType> LValueReferenceTypes;
@@ -200,20 +195,25 @@ class ASTContext : public RefCountedBase<ASTContext> {
ConstantArrayTypes;
mutable llvm::FoldingSet<IncompleteArrayType> IncompleteArrayTypes;
mutable std::vector<VariableArrayType*> VariableArrayTypes;
- mutable llvm::FoldingSet<DependentSizedArrayType> DependentSizedArrayTypes;
- mutable llvm::FoldingSet<DependentSizedExtVectorType>
- DependentSizedExtVectorTypes;
- mutable llvm::FoldingSet<DependentAddressSpaceType>
+ mutable llvm::ContextualFoldingSet<DependentSizedArrayType, ASTContext &>
+ DependentSizedArrayTypes;
+ mutable llvm::ContextualFoldingSet<DependentSizedExtVectorType, ASTContext &>
+ DependentSizedExtVectorTypes;
+ mutable llvm::ContextualFoldingSet<DependentAddressSpaceType, ASTContext &>
DependentAddressSpaceTypes;
mutable llvm::FoldingSet<VectorType> VectorTypes;
- mutable llvm::FoldingSet<DependentVectorType> DependentVectorTypes;
+ mutable llvm::ContextualFoldingSet<DependentVectorType, ASTContext &>
+ DependentVectorTypes;
mutable llvm::FoldingSet<ConstantMatrixType> MatrixTypes;
- mutable llvm::FoldingSet<DependentSizedMatrixType> DependentSizedMatrixTypes;
+ mutable llvm::ContextualFoldingSet<DependentSizedMatrixType, ASTContext &>
+ DependentSizedMatrixTypes;
mutable llvm::FoldingSet<FunctionNoProtoType> FunctionNoProtoTypes;
mutable llvm::ContextualFoldingSet<FunctionProtoType, ASTContext&>
FunctionProtoTypes;
- mutable llvm::FoldingSet<DependentTypeOfExprType> DependentTypeOfExprTypes;
- mutable llvm::FoldingSet<DependentDecltypeType> DependentDecltypeTypes;
+ mutable llvm::ContextualFoldingSet<DependentTypeOfExprType, ASTContext &>
+ DependentTypeOfExprTypes;
+ mutable llvm::ContextualFoldingSet<DependentDecltypeType, ASTContext &>
+ DependentDecltypeTypes;
mutable llvm::FoldingSet<TemplateTypeParmType> TemplateTypeParmTypes;
mutable llvm::FoldingSet<ObjCTypeParamType> ObjCTypeParamTypes;
mutable llvm::FoldingSet<SubstTemplateTypeParmType>
@@ -222,8 +222,11 @@ class ASTContext : public RefCountedBase<ASTContext> {
SubstTemplateTypeParmPackTypes;
mutable llvm::ContextualFoldingSet<TemplateSpecializationType, ASTContext&>
TemplateSpecializationTypes;
- mutable llvm::FoldingSet<ParenType> ParenTypes;
- mutable llvm::FoldingSet<ElaboratedType> ElaboratedTypes;
+ mutable llvm::FoldingSet<ParenType> ParenTypes{GeneralTypesLog2InitSize};
+ mutable llvm::FoldingSet<UsingType> UsingTypes;
+ mutable llvm::FoldingSet<TypedefType> TypedefTypes;
+ mutable llvm::FoldingSet<ElaboratedType> ElaboratedTypes{
+ GeneralTypesLog2InitSize};
mutable llvm::FoldingSet<DependentNameType> DependentNameTypes;
mutable llvm::ContextualFoldingSet<DependentTemplateSpecializationType,
ASTContext&>
@@ -237,10 +240,12 @@ class ASTContext : public RefCountedBase<ASTContext> {
mutable llvm::FoldingSet<DeducedTemplateSpecializationType>
DeducedTemplateSpecializationTypes;
mutable llvm::FoldingSet<AtomicType> AtomicTypes;
- llvm::FoldingSet<AttributedType> AttributedTypes;
+ mutable llvm::FoldingSet<AttributedType> AttributedTypes;
mutable llvm::FoldingSet<PipeType> PipeTypes;
- mutable llvm::FoldingSet<ExtIntType> ExtIntTypes;
- mutable llvm::FoldingSet<DependentExtIntType> DependentExtIntTypes;
+ mutable llvm::FoldingSet<BitIntType> BitIntTypes;
+ mutable llvm::ContextualFoldingSet<DependentBitIntType, ASTContext &>
+ DependentBitIntTypes;
+ llvm::FoldingSet<BTFTagAttributedType> BTFTagAttributedTypes;
mutable llvm::FoldingSet<QualifiedTemplateName> QualifiedTemplateNames;
mutable llvm::FoldingSet<DependentTemplateName> DependentTemplateNames;
@@ -290,6 +295,10 @@ class ASTContext : public RefCountedBase<ASTContext> {
/// Mapping from GUIDs to the corresponding MSGuidDecl.
mutable llvm::FoldingSet<MSGuidDecl> MSGuidDecls;
+ /// Mapping from APValues to the corresponding UnnamedGlobalConstantDecl.
+ mutable llvm::FoldingSet<UnnamedGlobalConstantDecl>
+ UnnamedGlobalConstantDecls;
+
/// Mapping from APValues to the corresponding TemplateParamObjects.
mutable llvm::FoldingSet<TemplateParamObjectDecl> TemplateParamObjectDecls;
@@ -299,6 +308,10 @@ class ASTContext : public RefCountedBase<ASTContext> {
/// This is lazily created. This is intentionally not serialized.
mutable llvm::StringMap<StringLiteral *> StringLiteralCache;
+ /// MD5 hash of CUID. It is calculated when first used and cached by this
+ /// data member.
+ mutable std::string CUIDHash;
+
/// Representation of a "canonical" template template parameter that
/// is used in canonical template names.
class CanonicalTemplateTemplateParm : public llvm::FoldingSetNode {
@@ -440,6 +453,13 @@ class ASTContext : public RefCountedBase<ASTContext> {
};
llvm::DenseMap<Module*, PerModuleInitializers*> ModuleInitializers;
+ /// This is the top-level (C++20) Named module we are building.
+ Module *CurrentCXXNamedModule = nullptr;
+
+ static constexpr unsigned ConstantArrayTypesLog2InitSize = 8;
+ static constexpr unsigned GeneralTypesLog2InitSize = 9;
+ static constexpr unsigned FunctionProtoTypesLog2InitSize = 12;
+
ASTContext &this_() { return *this; }
public:
@@ -453,6 +473,7 @@ private:
friend class ASTWriter;
template <class> friend class serialization::AbstractTypeReader;
friend class CXXRecordDecl;
+ friend class IncrementalParser;
/// A mapping to contain the template or declaration that
/// a variable declaration describes or was instantiated from,
@@ -512,6 +533,17 @@ private:
/// B<int> to the UnresolvedUsingDecl in B<T>.
llvm::DenseMap<NamedDecl *, NamedDecl *> InstantiatedFromUsingDecl;
+ /// Like InstantiatedFromUsingDecl, but for using-enum-declarations. Maps
+ /// from the instantiated using-enum to the templated decl from whence it
+ /// came.
+ /// Note that using-enum-declarations cannot be dependent and
+ /// thus will never be instantiated from an "unresolved"
+ /// version thereof (as with using-declarations), so each mapping is from
+ /// a (resolved) UsingEnumDecl to a (resolved) UsingEnumDecl.
+ llvm::DenseMap<UsingEnumDecl *, UsingEnumDecl *>
+ InstantiatedFromUsingEnumDecl;
+
+ /// Simlarly maps instantiated UsingShadowDecls to their origin.
llvm::DenseMap<UsingShadowDecl*, UsingShadowDecl*>
InstantiatedFromUsingShadowDecl;
@@ -550,7 +582,7 @@ private:
ImportDecl *FirstLocalImport = nullptr;
ImportDecl *LastLocalImport = nullptr;
- TranslationUnitDecl *TUDecl;
+ TranslationUnitDecl *TUDecl = nullptr;
mutable ExternCContextDecl *ExternCContext = nullptr;
mutable BuiltinTemplateDecl *MakeIntegerSeqDecl = nullptr;
mutable BuiltinTemplateDecl *TypePackElementDecl = nullptr;
@@ -562,9 +594,9 @@ private:
/// this ASTContext object.
LangOptions &LangOpts;
- /// Blacklist object that is used by sanitizers to decide which
+ /// NoSanitizeList object that is used by sanitizers to decide which
/// entities should not be instrumented.
- std::unique_ptr<SanitizerBlacklist> SanitizerBL;
+ std::unique_ptr<NoSanitizeList> NoSanitizeL;
/// Function filtering mechanism to determine whether a given function
/// should be imbued with the XRay "always" or "never" attributes.
@@ -587,9 +619,6 @@ private:
std::unique_ptr<CXXABI> ABI;
CXXABI *createCXXABI(const TargetInfo &T);
- /// The logical -> physical address space map.
- const LangASMap *AddrSpaceMap = nullptr;
-
/// Address space map mangling must be used with language specific
/// address spaces (e.g. OpenCL/CUDA)
bool AddrSpaceMapMangling;
@@ -600,10 +629,14 @@ private:
std::unique_ptr<interp::Context> InterpContext;
std::unique_ptr<ParentMapContext> ParentMapCtx;
+ /// Keeps track of the deallocated DeclListNodes for future reuse.
+ DeclListNode *ListNodeFreeList = nullptr;
+
public:
IdentifierTable &Idents;
SelectorTable &Selectors;
Builtin::Context &BuiltinInfo;
+ const TranslationUnitKind TUKind;
mutable DeclarationNameTable DeclarationNames;
IntrusiveRefCntPtr<ExternalASTSource> ExternalSource;
ASTMutationListener *Listener = nullptr;
@@ -611,15 +644,40 @@ public:
/// Returns the clang bytecode interpreter context.
interp::Context &getInterpContext();
+ struct CUDAConstantEvalContext {
+ /// Do not allow wrong-sided variables in constant expressions.
+ bool NoWrongSidedVars = false;
+ } CUDAConstantEvalCtx;
+ struct CUDAConstantEvalContextRAII {
+ ASTContext &Ctx;
+ CUDAConstantEvalContext SavedCtx;
+ CUDAConstantEvalContextRAII(ASTContext &Ctx_, bool NoWrongSidedVars)
+ : Ctx(Ctx_), SavedCtx(Ctx_.CUDAConstantEvalCtx) {
+ Ctx_.CUDAConstantEvalCtx.NoWrongSidedVars = NoWrongSidedVars;
+ }
+ ~CUDAConstantEvalContextRAII() { Ctx.CUDAConstantEvalCtx = SavedCtx; }
+ };
+
/// Returns the dynamic AST node parent map context.
ParentMapContext &getParentMapContext();
// A traversal scope limits the parts of the AST visible to certain analyses.
- // RecursiveASTVisitor::TraverseAST will only visit reachable nodes, and
+ // RecursiveASTVisitor only visits specified children of TranslationUnitDecl.
// getParents() will only observe reachable parent edges.
//
- // The scope is defined by a set of "top-level" declarations.
- // Initially, it is the entire TU: {getTranslationUnitDecl()}.
+ // The scope is defined by a set of "top-level" declarations which will be
+ // visible under the TranslationUnitDecl.
+ // Initially, it is the entire TU, represented by {getTranslationUnitDecl()}.
+ //
+ // After setTraversalScope({foo, bar}), the exposed AST looks like:
+ // TranslationUnitDecl
+ // - foo
+ // - ...
+ // - bar
+ // - ...
+ // All other siblings of foo and bar are pruned from the tree.
+ // (However they are still accessible via TranslationUnitDecl->decls())
+ //
// Changing the scope clears the parent cache, which is expensive to rebuild.
std::vector<Decl *> getTraversalScope() const { return TraversalScope; }
void setTraversalScope(const std::vector<Decl *> &);
@@ -639,6 +697,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;
}
@@ -651,6 +715,24 @@ public:
}
void Deallocate(void *Ptr) const {}
+ /// Allocates a \c DeclListNode or returns one from the \c ListNodeFreeList
+ /// pool.
+ DeclListNode *AllocateDeclListNode(clang::NamedDecl *ND) {
+ if (DeclListNode *Alloc = ListNodeFreeList) {
+ ListNodeFreeList = Alloc->Rest.dyn_cast<DeclListNode*>();
+ Alloc->D = ND;
+ Alloc->Rest = nullptr;
+ return Alloc;
+ }
+ return new (*this) DeclListNode(ND);
+ }
+ /// Deallcates a \c DeclListNode by returning it to the \c ListNodeFreeList
+ /// pool.
+ void DeallocateDeclListNode(DeclListNode *N) {
+ N->Rest = ListNodeFreeList;
+ ListNodeFreeList = N;
+ }
+
/// Return the total amount of physical memory allocated for representing
/// AST nodes and type information.
size_t getASTAllocatedMemory() const {
@@ -677,7 +759,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;
@@ -691,9 +774,7 @@ public:
return LangOpts.CPlusPlus || LangOpts.RecoveryAST;
}
- const SanitizerBlacklist &getSanitizerBlacklist() const {
- return *SanitizerBL;
- }
+ const NoSanitizeList &getNoSanitizeList() const { return *NoSanitizeL; }
const XRayFunctionFilter &getXRayFilter() const {
return *XRayFilter;
@@ -707,6 +788,11 @@ public:
return FullSourceLoc(Loc,SourceMgr);
}
+ /// Return the C++ ABI kind that should be used. The C++ ABI can be overriden
+ /// at compile time with `-fc++-abi=`. If this is not provided, we instead use
+ /// the default ABI set by the target.
+ TargetCXXABI::Kind getCXXABIKind() const;
+
/// All comments in this translation unit.
RawCommentList Comments;
@@ -856,30 +942,38 @@ public:
MemberSpecializationInfo *getInstantiatedFromStaticDataMember(
const VarDecl *Var);
- TemplateOrSpecializationInfo
- getTemplateOrSpecializationInfo(const VarDecl *Var);
-
/// Note that the static data member \p Inst is an instantiation of
/// the static data member template \p Tmpl of a class template.
void setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl,
TemplateSpecializationKind TSK,
SourceLocation PointOfInstantiation = SourceLocation());
+ TemplateOrSpecializationInfo
+ getTemplateOrSpecializationInfo(const VarDecl *Var);
+
void setTemplateOrSpecializationInfo(VarDecl *Inst,
TemplateOrSpecializationInfo TSI);
- /// If the given using decl \p Inst is an instantiation of a
- /// (possibly unresolved) using decl from a template instantiation,
- /// return it.
+ /// If the given using decl \p Inst is an instantiation of
+ /// another (possibly unresolved) using decl, return it.
NamedDecl *getInstantiatedFromUsingDecl(NamedDecl *Inst);
/// Remember that the using decl \p Inst is an instantiation
/// of the using decl \p Pattern of a class template.
void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern);
+ /// If the given using-enum decl \p Inst is an instantiation of
+ /// another using-enum decl, return it.
+ UsingEnumDecl *getInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst);
+
+ /// Remember that the using enum decl \p Inst is an instantiation
+ /// of the using enum decl \p Pattern of a class template.
+ void setInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst,
+ UsingEnumDecl *Pattern);
+
+ UsingShadowDecl *getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst);
void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst,
UsingShadowDecl *Pattern);
- UsingShadowDecl *getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst);
FieldDecl *getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field);
@@ -962,7 +1056,24 @@ public:
/// Get the initializations to perform when importing a module, if any.
ArrayRef<Decl*> getModuleInitializers(Module *M);
- TranslationUnitDecl *getTranslationUnitDecl() const { return TUDecl; }
+ /// Set the (C++20) module we are building.
+ void setCurrentNamedModule(Module *M);
+
+ /// Get module under construction, nullptr if this is not a C++20 module.
+ Module *getCurrentNamedModule() const { return CurrentCXXNamedModule; }
+
+ TranslationUnitDecl *getTranslationUnitDecl() const {
+ return TUDecl->getMostRecentDecl();
+ }
+ void addTranslationUnitDecl() {
+ assert(!TUDecl || TUKind == TU_Incremental);
+ TranslationUnitDecl *NewTUDecl = TranslationUnitDecl::Create(*this);
+ if (TraversalScope.empty() || TraversalScope.back() == TUDecl)
+ TraversalScope = {NewTUDecl};
+ if (TUDecl)
+ NewTUDecl->setPreviousDecl(TUDecl);
+ TUDecl = NewTUDecl;
+ }
ExternCContextDecl *getExternCContextDecl() const;
BuiltinTemplateDecl *getMakeIntegerSeqDecl() const;
@@ -981,7 +1092,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;
@@ -996,8 +1107,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;
@@ -1020,6 +1129,11 @@ public:
#define PPC_VECTOR_TYPE(Name, Id, Size) \
CanQualType Id##Ty;
#include "clang/Basic/PPCTypes.def"
+#define RVV_TYPE(Name, Id, SingletonId) \
+ CanQualType SingletonId;
+#include "clang/Basic/RISCVVTypes.def"
+#define WASM_TYPE(Name, Id, SingletonId) CanQualType SingletonId;
+#include "clang/Basic/WebAssemblyReferenceTypes.def"
// Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand.
mutable QualType AutoDeductTy; // Deduction against 'auto'.
@@ -1032,11 +1146,23 @@ public:
// Implicitly-declared type 'struct _GUID'.
mutable TagDecl *MSGuidTagDecl = nullptr;
- /// Keep track of CUDA/HIP static device variables referenced by host code.
- llvm::DenseSet<const VarDecl *> CUDAStaticDeviceVarReferencedByHost;
+ /// Keep track of CUDA/HIP device-side variables ODR-used by host code.
+ /// This does not include extern shared variables used by device host
+ /// functions as addresses of shared variables are per warp, therefore
+ /// cannot be accessed by host code.
+ llvm::DenseSet<const VarDecl *> CUDADeviceVarODRUsedByHost;
+
+ /// Keep track of CUDA/HIP external kernels or device variables ODR-used by
+ /// host code.
+ llvm::DenseSet<const ValueDecl *> CUDAExternalDeviceDeclODRUsedByHost;
+
+ /// Keep track of CUDA/HIP implicit host device functions used on device side
+ /// in device compilation.
+ llvm::DenseSet<const FunctionDecl *> CUDAImplicitHostDeviceFunUsedByDevice;
ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents,
- SelectorTable &sels, Builtin::Context &builtins);
+ SelectorTable &sels, Builtin::Context &builtins,
+ TranslationUnitKind TUKind);
ASTContext(const ASTContext &) = delete;
ASTContext &operator=(const ASTContext &) = delete;
~ASTContext();
@@ -1075,8 +1201,9 @@ public:
/// Create a new implicit TU-level CXXRecordDecl or RecordDecl
/// declaration.
- RecordDecl *buildImplicitRecord(StringRef Name,
- RecordDecl::TagKind TK = TTK_Struct) const;
+ RecordDecl *buildImplicitRecord(
+ StringRef Name,
+ RecordDecl::TagKind TK = RecordDecl::TagKind::Struct) const;
/// Create a new implicit TU-level typedef declaration.
TypedefDecl *buildImplicitTypedef(QualType T, StringRef Name) const;
@@ -1176,11 +1303,11 @@ public:
/// declaration of a function with an exception specification is permitted
/// and preserved. Other type sugar (for instance, typedefs) is not.
QualType getFunctionTypeWithExceptionSpec(
- QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI);
+ QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI) const;
/// Determine whether two function types are the same, ignoring
/// exception specifications in cases where they're part of the type.
- bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U);
+ bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U) const;
/// Change the exception specification on a function once it is
/// delay-parsed, instantiated, or computed.
@@ -1226,6 +1353,9 @@ public:
CanQualType getDecayedType(CanQualType T) const {
return CanQualType::CreateUnsafe(getDecayedType((QualType) T));
}
+ /// Return the uniqued reference to a specified decay from the original
+ /// type to the decayed type.
+ QualType getDecayedType(QualType Orig, QualType Decayed) const;
/// Return the uniqued reference to the atomic type for the specified
/// type.
@@ -1245,13 +1375,13 @@ public:
/// Return a write_only pipe type for the specified type.
QualType getWritePipeType(QualType T) const;
- /// Return an extended integer type with the specified signedness and bit
+ /// Return a bit-precise integer type with the specified signedness and bit
/// count.
- QualType getExtIntType(bool Unsigned, unsigned NumBits) const;
+ QualType getBitIntType(bool Unsigned, unsigned NumBits) const;
- /// Return a dependent extended integer type with the specified signedness and
- /// bit count.
- QualType getDependentExtIntType(bool Unsigned, Expr *BitsExpr) const;
+ /// Return a dependent bit-precise integer type with the specified signedness
+ /// and bit count.
+ QualType getDependentBitIntType(bool Unsigned, Expr *BitsExpr) const;
/// Gets the struct used to keep track of the extended descriptor for
/// pointer to blocks.
@@ -1263,6 +1393,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;
}
@@ -1299,8 +1435,7 @@ public:
/// Return a non-unique reference to the type for a variable array of
/// the specified element type.
QualType getVariableArrayType(QualType EltTy, Expr *NumElts,
- ArrayType::ArraySizeModifier ASM,
- unsigned IndexTypeQuals,
+ ArraySizeModifier ASM, unsigned IndexTypeQuals,
SourceRange Brackets) const;
/// Return a non-unique reference to the type for a dependently-sized
@@ -1309,21 +1444,19 @@ public:
/// FIXME: We will need these to be uniqued, or at least comparable, at some
/// point.
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts,
- ArrayType::ArraySizeModifier ASM,
+ ArraySizeModifier ASM,
unsigned IndexTypeQuals,
SourceRange Brackets) const;
/// Return a unique reference to the type for an incomplete array of
/// the specified element type.
- QualType getIncompleteArrayType(QualType EltTy,
- ArrayType::ArraySizeModifier ASM,
+ QualType getIncompleteArrayType(QualType EltTy, ArraySizeModifier ASM,
unsigned IndexTypeQuals) const;
/// Return the unique reference to the type for a constant array of
/// the specified element type.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize,
- const Expr *SizeExpr,
- ArrayType::ArraySizeModifier ASM,
+ const Expr *SizeExpr, ArraySizeModifier ASM,
unsigned IndexTypeQuals) const;
/// Return a type for a constant array for a string literal of the
@@ -1350,21 +1483,27 @@ public:
/// Return the unique reference to a scalable vector type of the specified
/// element type and scalable number of elements.
+ /// For RISC-V, number of fields is also provided when it fetching for
+ /// tuple type.
///
/// \pre \p EltTy must be a built-in type.
- QualType getScalableVectorType(QualType EltTy, unsigned NumElts) const;
+ QualType getScalableVectorType(QualType EltTy, unsigned NumElts,
+ unsigned NumFields = 1) const;
+
+ /// Return a WebAssembly externref type.
+ QualType getWebAssemblyExternrefType() const;
/// Return the unique reference to a vector type of the specified
/// element type and size.
///
/// \pre \p VectorType must be a built-in type.
QualType getVectorType(QualType VectorType, unsigned NumElts,
- VectorType::VectorKind VecKind) const;
+ VectorKind VecKind) const;
/// Return the unique reference to the type for a dependently sized vector of
/// the specified element type.
QualType getDependentVectorType(QualType VectorType, Expr *SizeExpr,
SourceLocation AttrLoc,
- VectorType::VectorKind VecKind) const;
+ VectorKind VecKind) const;
/// Return the unique reference to an extended vector type
/// of the specified element type and size.
@@ -1420,6 +1559,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
@@ -1438,6 +1583,9 @@ public:
return getTypeDeclTypeSlow(Decl);
}
+ QualType getUsingType(const UsingShadowDecl *Found,
+ QualType Underlying) const;
+
/// Return the unique reference to the type for the specified
/// typedef-name decl.
QualType getTypedefType(const TypedefNameDecl *Decl,
@@ -1447,16 +1595,23 @@ public:
QualType getEnumType(const EnumDecl *Decl) const;
+ QualType
+ getUnresolvedUsingType(const UnresolvedUsingTypenameDecl *Decl) const;
+
QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const;
- QualType getAttributedType(attr::Kind attrKind,
- QualType modifiedType,
- QualType equivalentType);
+ QualType getAttributedType(attr::Kind attrKind, QualType modifiedType,
+ QualType equivalentType) const;
- QualType getSubstTemplateTypeParmType(const TemplateTypeParmType *Replaced,
- QualType Replacement) const;
- QualType getSubstTemplateTypeParmPackType(
- const TemplateTypeParmType *Replaced,
+ QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr,
+ QualType Wrapped);
+
+ QualType
+ getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl,
+ unsigned Index,
+ std::optional<unsigned> PackIndex) const;
+ QualType getSubstTemplateTypeParmPackType(Decl *AssociatedDecl,
+ unsigned Index, bool Final,
const TemplateArgument &ArgPack);
QualType
@@ -1473,7 +1628,7 @@ public:
ArrayRef<TemplateArgument> Args) const;
QualType getTemplateSpecializationType(TemplateName T,
- const TemplateArgumentListInfo &Args,
+ ArrayRef<TemplateArgumentLoc> Args,
QualType Canon = QualType()) const;
TypeSourceInfo *
@@ -1494,10 +1649,9 @@ public:
const IdentifierInfo *Name,
QualType Canon = QualType()) const;
- QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword,
- NestedNameSpecifier *NNS,
- const IdentifierInfo *Name,
- const TemplateArgumentListInfo &Args) const;
+ QualType getDependentTemplateSpecializationType(
+ ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS,
+ const IdentifierInfo *Name, ArrayRef<TemplateArgumentLoc> Args) const;
QualType getDependentTemplateSpecializationType(
ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS,
const IdentifierInfo *Name, ArrayRef<TemplateArgument> Args) const;
@@ -1518,7 +1672,7 @@ public:
/// elsewhere, such as if the pattern contains a placeholder type or
/// if this is the canonical type of another pack expansion type.
QualType getPackExpansionType(QualType Pattern,
- Optional<unsigned> NumExpansions,
+ std::optional<unsigned> NumExpansions,
bool ExpectPackInType = true);
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl,
@@ -1550,9 +1704,11 @@ public:
/// Return a ObjCObjectPointerType type for the given ObjCObjectType.
QualType getObjCObjectPointerType(QualType OIT) const;
- /// GCC extension.
- QualType getTypeOfExprType(Expr *e) const;
- QualType getTypeOfType(QualType t) const;
+ /// C23 feature and GCC extension.
+ QualType getTypeOfExprType(Expr *E, TypeOfKind Kind) const;
+ QualType getTypeOfType(QualType QT, TypeOfKind Kind) const;
+
+ QualType getReferenceQualifiedType(const Expr *e) const;
/// C++11 decltype.
QualType getDecltypeType(Expr *e, QualType UnderlyingType) const;
@@ -1573,6 +1729,10 @@ public:
/// C++11 deduction pattern for 'auto &&' type.
QualType getAutoRRefDeductType() const;
+ /// Remove any type constraints from a template parameter type, for
+ /// equivalence comparison of template parameters.
+ QualType getUnconstrainedType(QualType T) const;
+
/// C++17 deduced class template specialization type.
QualType getDeducedTemplateSpecializationType(TemplateName Template,
QualType DeducedType,
@@ -2029,16 +2189,20 @@ public:
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS,
bool TemplateKeyword,
- TemplateDecl *Template) const;
+ TemplateName Template) const;
TemplateName getDependentTemplateName(NestedNameSpecifier *NNS,
const IdentifierInfo *Name) const;
TemplateName getDependentTemplateName(NestedNameSpecifier *NNS,
OverloadedOperatorKind Operator) const;
- TemplateName getSubstTemplateTemplateParm(TemplateTemplateParmDecl *param,
- TemplateName replacement) const;
- TemplateName getSubstTemplateTemplateParmPack(TemplateTemplateParmDecl *Param,
- const TemplateArgument &ArgPack) const;
+ TemplateName
+ getSubstTemplateTemplateParm(TemplateName replacement, Decl *AssociatedDecl,
+ unsigned Index,
+ std::optional<unsigned> PackIndex) const;
+ TemplateName getSubstTemplateTemplateParmPack(const TemplateArgument &ArgPack,
+ Decl *AssociatedDecl,
+ unsigned Index,
+ bool Final) const;
enum GetBuiltinTypeError {
/// No error
@@ -2102,6 +2266,17 @@ public:
/// false otherwise.
bool areLaxCompatibleSveTypes(QualType FirstType, QualType SecondType);
+ /// Return true if the given types are an RISC-V vector builtin type and a
+ /// VectorType that is a fixed-length representation of the RISC-V vector
+ /// builtin type for a specific vector-length.
+ bool areCompatibleRVVTypes(QualType FirstType, QualType SecondType);
+
+ /// Return true if the given vector types are lax-compatible RISC-V vector
+ /// types as defined by -flax-vector-conversions=, which permits implicit
+ /// conversions between vectors with different number of elements and/or
+ /// incompatible element types, false otherwise.
+ bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType);
+
/// Return true if the type has been explicitly qualified with ObjC ownership.
/// A type may be implicitly qualified with ownership under ObjC ARC, and in
/// some cases the compiler treats these differently.
@@ -2148,13 +2323,13 @@ public:
CharUnits getTypeSizeInChars(QualType T) const;
CharUnits getTypeSizeInChars(const Type *T) const;
- Optional<CharUnits> getTypeSizeInCharsIfKnown(QualType Ty) const {
+ std::optional<CharUnits> getTypeSizeInCharsIfKnown(QualType Ty) const {
if (Ty->isIncompleteType() || Ty->isDependentType())
- return None;
+ return std::nullopt;
return getTypeSizeInChars(Ty);
}
- Optional<CharUnits> getTypeSizeInCharsIfKnown(const Type *Ty) const {
+ std::optional<CharUnits> getTypeSizeInCharsIfKnown(const Type *Ty) const {
return getTypeSizeInCharsIfKnown(QualType(Ty, 0));
}
@@ -2210,6 +2385,9 @@ public:
bool isAlignmentRequired(const Type *T) const;
bool isAlignmentRequired(QualType T) const;
+ /// More type predicates useful for type checking/promotion
+ bool isPromotableIntegerType(QualType T) const; // C99 6.3.1.1p2
+
/// Return the "preferred" alignment of the specified type \p T for
/// the current target, in bits.
///
@@ -2323,6 +2501,12 @@ public:
/// If \p T is null pointer, assume the target in ASTContext.
MangleContext *createMangleContext(const TargetInfo *T = nullptr);
+ /// Creates a device mangle context to correctly mangle lambdas in a mixed
+ /// architecture compile by setting the lambda mangling number source to the
+ /// DeviceLambdaManglingNumber. Currently this asserts that the TargetInfo
+ /// (from the AuxTargetInfo) is a an itanium target.
+ MangleContext *createDeviceMangleContext(const TargetInfo &T);
+
void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass,
SmallVectorImpl<const ObjCIvarDecl*> &Ivars) const;
@@ -2332,7 +2516,9 @@ public:
/// Return true if the specified type has unique object representations
/// according to (C++17 [meta.unary.prop]p9)
- bool hasUniqueObjectRepresentations(QualType Ty) const;
+ bool
+ hasUniqueObjectRepresentations(QualType Ty,
+ bool CheckIfTriviallyCopyable = true) const;
//===--------------------------------------------------------------------===//
// Type Operators
@@ -2369,6 +2555,9 @@ public:
return getCanonicalType(T1) == getCanonicalType(T2);
}
+ /// Determine whether the given expressions \p X and \p Y are equivalent.
+ bool hasSameExpr(const Expr *X, const Expr *Y) const;
+
/// Return this type as a completely-unqualified array type,
/// capturing the qualifiers in \p Quals.
///
@@ -2393,9 +2582,9 @@ public:
bool hasSameNullabilityTypeQualifier(QualType SubT, QualType SuperT,
bool IsParam) const {
- auto SubTnullability = SubT->getNullability(*this);
- auto SuperTnullability = SuperT->getNullability(*this);
- if (SubTnullability.hasValue() == SuperTnullability.hasValue()) {
+ auto SubTnullability = SubT->getNullability();
+ auto SuperTnullability = SuperT->getNullability();
+ if (SubTnullability.has_value() == SuperTnullability.has_value()) {
// Neither has nullability; return true
if (!SubTnullability)
return true;
@@ -2422,8 +2611,10 @@ public:
bool ObjCMethodsAreEqual(const ObjCMethodDecl *MethodDecl,
const ObjCMethodDecl *MethodImp);
- bool UnwrapSimilarTypes(QualType &T1, QualType &T2);
- bool 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
@@ -2486,11 +2677,40 @@ public:
/// template name uses the shortest form of the dependent
/// nested-name-specifier, which itself contains all canonical
/// types, values, and templates.
- TemplateName getCanonicalTemplateName(TemplateName Name) const;
+ TemplateName getCanonicalTemplateName(const TemplateName &Name) const;
/// Determine whether the given template names refer to the same
/// template.
- bool hasSameTemplateName(TemplateName X, TemplateName Y);
+ bool hasSameTemplateName(const TemplateName &X, const TemplateName &Y) const;
+
+ /// Determine whether the two declarations refer to the same entity.
+ bool isSameEntity(const NamedDecl *X, const NamedDecl *Y) const;
+
+ /// Determine whether two template parameter lists are similar enough
+ /// that they may be used in declarations of the same template.
+ bool isSameTemplateParameterList(const TemplateParameterList *X,
+ const TemplateParameterList *Y) const;
+
+ /// Determine whether two template parameters are similar enough
+ /// that they may be used in declarations of the same template.
+ bool isSameTemplateParameter(const NamedDecl *X, const NamedDecl *Y) const;
+
+ /// Determine whether two 'requires' expressions are similar enough that they
+ /// may be used in re-declarations.
+ ///
+ /// Use of 'requires' isn't mandatory, works with constraints expressed in
+ /// other ways too.
+ bool isSameConstraintExpr(const Expr *XCE, const Expr *YCE) const;
+
+ /// Determine whether two type contraint are similar enough that they could
+ /// used in declarations of the same template.
+ bool isSameTypeConstraint(const TypeConstraint *XTC,
+ const TypeConstraint *YTC) const;
+
+ /// Determine whether two default template arguments are similar enough
+ /// that they may be used in declarations of the same template.
+ bool isSameDefaultTemplateArgument(const NamedDecl *X,
+ const NamedDecl *Y) const;
/// Retrieve the "canonical" template argument.
///
@@ -2531,6 +2751,10 @@ public:
/// Return number of constant array elements.
uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const;
+ /// Return number of elements initialized in an ArrayInitLoopExpr.
+ uint64_t
+ getArrayInitLoopExprElementCount(const ArrayInitLoopExpr *AILE) const;
+
/// Perform adjustment on the parameter type of a function.
///
/// This routine adjusts the given parameter type @p T to the actual
@@ -2588,22 +2812,6 @@ public:
/// long double and double on AArch64 will return 0).
int getFloatingTypeSemanticOrder(QualType LHS, QualType RHS) const;
- /// Return a real floating point or a complex type (based on
- /// \p typeDomain/\p typeSize).
- ///
- /// \param typeDomain a real floating point or complex type.
- /// \param typeSize a real floating point or complex type.
- QualType getFloatingTypeOfSizeWithinDomain(QualType typeSize,
- QualType typeDomain) const;
-
- unsigned getTargetAddressSpace(QualType T) const {
- return getTargetAddressSpace(T.getQualifiers());
- }
-
- unsigned getTargetAddressSpace(Qualifiers Q) const {
- return getTargetAddressSpace(Q.getAddressSpace());
- }
-
unsigned getTargetAddressSpace(LangAS AS) const;
LangAS getLangASForBuiltinAddressSpace(unsigned AS) const;
@@ -2616,6 +2824,23 @@ public:
return AddrSpaceMapMangling || isTargetAddressSpace(AS);
}
+ // Merges two exception specifications, such that the resulting
+ // exception spec is the union of both. For example, if either
+ // of them can throw something, the result can throw it as well.
+ FunctionProtoType::ExceptionSpecInfo
+ mergeExceptionSpecs(FunctionProtoType::ExceptionSpecInfo ESI1,
+ FunctionProtoType::ExceptionSpecInfo ESI2,
+ SmallVectorImpl<QualType> &ExceptionTypeStorage,
+ bool AcceptDependent);
+
+ // For two "same" types, return a type which has
+ // the common sugar between them. If Unqualified is true,
+ // both types need only be the same unqualified type.
+ // The result will drop the qualifiers which do not occur
+ // in both types.
+ QualType getCommonSugaredType(QualType X, QualType Y,
+ bool Unqualified = false);
+
private:
// Helper for integer ordering
unsigned getIntegerRank(const Type *T) const;
@@ -2633,14 +2858,20 @@ public:
bool typesAreBlockPointerCompatible(QualType, QualType);
bool isObjCIdType(QualType T) const {
+ if (const auto *ET = dyn_cast<ElaboratedType>(T))
+ T = ET->getNamedType();
return T == getObjCIdType();
}
bool isObjCClassType(QualType T) const {
+ if (const auto *ET = dyn_cast<ElaboratedType>(T))
+ T = ET->getNamedType();
return T == getObjCClassType();
}
bool isObjCSelType(QualType T) const {
+ if (const auto *ET = dyn_cast<ElaboratedType>(T))
+ T = ET->getNamedType();
return T == getObjCSelType();
}
@@ -2666,10 +2897,12 @@ public:
bool canBindObjCObjectType(QualType To, QualType From);
// Functions for calculating composite types
- QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false,
- bool Unqualified = false, bool BlockReturnType = false);
- QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer=false,
- bool Unqualified = false, bool AllowCXX = false);
+ QualType mergeTypes(QualType, QualType, bool OfBlockPointer = false,
+ bool Unqualified = false, bool BlockReturnType = false,
+ bool IsConditionalOperator = false);
+ QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer = false,
+ bool Unqualified = false, bool AllowCXX = false,
+ bool IsConditionalOperator = false);
QualType mergeFunctionParameterTypes(QualType, QualType,
bool OfBlockPointer = false,
bool Unqualified = false);
@@ -2722,6 +2955,14 @@ public:
// a given fixed point type.
QualType getCorrespondingUnsignedType(QualType T) const;
+ // Per C99 6.2.5p6, for every signed integer type, there is a corresponding
+ // unsigned integer type. This method takes an unsigned type, and returns the
+ // corresponding signed integer type.
+ // With the introduction of fixed point types in ISO N1169, this method also
+ // accepts fixed point types and returns the corresponding signed type for
+ // a given fixed point type.
+ QualType getCorrespondingSignedType(QualType T) const;
+
// Per ISO N1169, this method accepts fixed point types and returns the
// corresponding saturated type for a given fixed point type.
QualType getCorrespondingSaturatedType(QualType Ty) const;
@@ -2832,7 +3073,7 @@ public:
}
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const;
- GVALinkage GetGVALinkageForVariable(const VarDecl *VD);
+ GVALinkage GetGVALinkageForVariable(const VarDecl *VD) const;
/// Determines if the decl can be CodeGen'ed or deserialized from PCH
/// lazily, only when used; this is only relevant for function or file scoped
@@ -2863,7 +3104,8 @@ public:
DeclaratorDecl *getDeclaratorForUnnamedTagDecl(const TagDecl *TD);
void setManglingNumber(const NamedDecl *ND, unsigned Number);
- unsigned getManglingNumber(const NamedDecl *ND) const;
+ unsigned getManglingNumber(const NamedDecl *ND,
+ bool ForAuxTarget = false) const;
void setStaticLocalNumber(const VarDecl *VD, unsigned Number);
unsigned getStaticLocalNumber(const VarDecl *VD) const;
@@ -2894,6 +3136,11 @@ public:
/// GUID value.
MSGuidDecl *getMSGuidDecl(MSGuidDeclParts Parts) const;
+ /// Return a declaration for a uniquified anonymous global constant
+ /// corresponding to a given APValue.
+ UnnamedGlobalConstantDecl *
+ getUnnamedGlobalConstantDecl(QualType Ty, const APValue &Value) const;
+
/// Return the template parameter object of the given type with the given
/// value.
TemplateParamObjectDecl *getTemplateParamObjectDecl(QualType T,
@@ -2903,6 +3150,9 @@ public:
/// valid feature names.
ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const;
+ std::vector<std::string>
+ filterFunctionTargetVersionAttrs(const TargetVersionAttr *TV) const;
+
void getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
const FunctionDecl *) const;
void getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
@@ -2974,7 +3224,6 @@ private:
public:
ObjCEncOptions() : Bits(0) {}
- ObjCEncOptions(const ObjCEncOptions &RHS) : Bits(RHS.Bits) {}
#define OPT_LIST(V) \
V(ExpandPointedToStructures, 0) \
@@ -2995,11 +3244,11 @@ OPT_LIST(V)
#undef OPT_LIST
- LLVM_NODISCARD ObjCEncOptions keepingOnly(ObjCEncOptions Mask) const {
+ [[nodiscard]] ObjCEncOptions keepingOnly(ObjCEncOptions Mask) const {
return Bits & Mask.Bits;
}
- LLVM_NODISCARD ObjCEncOptions forComponentType() const {
+ [[nodiscard]] ObjCEncOptions forComponentType() const {
ObjCEncOptions Mask = ObjCEncOptions()
.setIsOutermostType()
.setIsStructField();
@@ -3110,11 +3359,13 @@ public:
/// Return a new OMPTraitInfo object owned by this context.
OMPTraitInfo &getNewOMPTraitInfo();
- /// Whether a C++ static variable may be externalized.
- bool mayExternalizeStaticVar(const Decl *D) const;
+ /// Whether a C++ static variable or CUDA/HIP kernel may be externalized.
+ bool mayExternalize(const Decl *D) const;
+
+ /// Whether a C++ static variable or CUDA/HIP kernel should be externalized.
+ bool shouldExternalize(const Decl *D) const;
- /// Whether a C++ static variable should be externalized.
- bool shouldExternalizeStaticVar(const Decl *D) const;
+ StringRef getCUIDHash() const;
private:
/// All OMPTraitInfo objects live in this collection, one per