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.h130
1 files changed, 102 insertions, 28 deletions
diff --git a/contrib/llvm-project/clang/include/clang/AST/ASTContext.h b/contrib/llvm-project/clang/include/clang/AST/ASTContext.h
index 3700d0101daf..ae69a68608b7 100644
--- a/contrib/llvm-project/clang/include/clang/AST/ASTContext.h
+++ b/contrib/llvm-project/clang/include/clang/AST/ASTContext.h
@@ -36,6 +36,7 @@
#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"
@@ -43,6 +44,7 @@
#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"
@@ -73,6 +75,8 @@
namespace llvm {
+class APFixedPoint;
+class FixedPointSemantics;
struct fltSemantics;
template <typename T, unsigned N> class SmallPtrSet;
@@ -80,7 +84,6 @@ template <typename T, unsigned N> class SmallPtrSet;
namespace clang {
-class APFixedPoint;
class APValue;
class ASTMutationListener;
class ASTRecordLayout;
@@ -98,7 +101,6 @@ class ParentMapContext;
class DynTypedNode;
class DynTypedNodeList;
class Expr;
-class FixedPointSemantics;
class GlobalDecl;
class MangleContext;
class MangleNumberingContext;
@@ -170,6 +172,16 @@ struct TypeInfo {
: Width(Width), Align(Align), AlignIsRequired(AlignIsRequired) {}
};
+struct TypeInfoChars {
+ CharUnits Width;
+ CharUnits Align;
+ bool AlignIsRequired : 1;
+
+ TypeInfoChars() : AlignIsRequired(false) {}
+ TypeInfoChars(CharUnits Width, CharUnits Align, bool AlignIsRequired)
+ : Width(Width), Align(Align), AlignIsRequired(AlignIsRequired) {}
+};
+
/// Holds long-lived AST nodes (such as types and decls) that can be
/// referred to throughout the semantic analysis of a file.
class ASTContext : public RefCountedBase<ASTContext> {
@@ -278,8 +290,8 @@ class ASTContext : public RefCountedBase<ASTContext> {
/// Mapping from GUIDs to the corresponding MSGuidDecl.
mutable llvm::FoldingSet<MSGuidDecl> MSGuidDecls;
- /// Used to cleanups APValues stored in the AST.
- mutable llvm::SmallVector<APValue *, 0> APValueCleanups;
+ /// Mapping from APValues to the corresponding TemplateParamObjects.
+ mutable llvm::FoldingSet<TemplateParamObjectDecl> TemplateParamObjectDecls;
/// A cache mapping a string value to a StringLiteral object with the same
/// value.
@@ -526,6 +538,9 @@ private:
/// need them (like static local vars).
llvm::MapVector<const NamedDecl *, unsigned> MangleNumbers;
llvm::MapVector<const VarDecl *, unsigned> StaticLocalNumbers;
+ /// Mapping the associated device lambda mangling number if present.
+ mutable llvm::DenseMap<const CXXRecordDecl *, unsigned>
+ DeviceLambdaManglingNumbers;
/// Mapping that stores parameterIndex values for ParmVarDecls when
/// that value exceeds the bitfield size of ParmVarDeclBits.ParameterIndex.
@@ -555,6 +570,10 @@ private:
/// should be imbued with the XRay "always" or "never" attributes.
std::unique_ptr<XRayFunctionFilter> XRayFilter;
+ /// ProfileList object that is used by the profile instrumentation
+ /// to decide which entities should be instrumented.
+ std::unique_ptr<ProfileList> ProfList;
+
/// The allocator used to create AST objects.
///
/// AST objects are never destructed; rather, all memory associated with the
@@ -562,7 +581,7 @@ private:
mutable llvm::BumpPtrAllocator BumpAlloc;
/// Allocator for partial diagnostics.
- PartialDiagnostic::StorageAllocator DiagAllocator;
+ PartialDiagnostic::DiagStorageAllocator DiagAllocator;
/// The current C++ ABI.
std::unique_ptr<CXXABI> ABI;
@@ -641,7 +660,7 @@ public:
/// Return the total memory used for various side tables.
size_t getSideTableAllocatedMemory() const;
- PartialDiagnostic::StorageAllocator &getDiagAllocator() {
+ PartialDiagnostic::DiagStorageAllocator &getDiagAllocator() {
return DiagAllocator;
}
@@ -664,6 +683,14 @@ public:
const LangOptions& getLangOpts() const { return LangOpts; }
+ // If this condition is false, typo correction must be performed eagerly
+ // rather than delayed in many places, as it makes use of dependent types.
+ // the condition is false for clang's C-only codepath, as it doesn't support
+ // dependent types yet.
+ bool isDependenceAllowed() const {
+ return LangOpts.CPlusPlus || LangOpts.RecoveryAST;
+ }
+
const SanitizerBlacklist &getSanitizerBlacklist() const {
return *SanitizerBL;
}
@@ -672,6 +699,8 @@ public:
return *XRayFilter;
}
+ const ProfileList &getProfileList() const { return *ProfList; }
+
DiagnosticsEngine &getDiagnostics() const;
FullSourceLoc getFullLoc(SourceLocation Loc) const {
@@ -988,6 +1017,9 @@ public:
#define SVE_TYPE(Name, Id, SingletonId) \
CanQualType SingletonId;
#include "clang/Basic/AArch64SVEACLETypes.def"
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
+ CanQualType Id##Ty;
+#include "clang/Basic/PPCTypes.def"
// Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand.
mutable QualType AutoDeductTy; // Deduction against 'auto'.
@@ -1000,6 +1032,9 @@ 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;
+
ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents,
SelectorTable &sels, Builtin::Context &builtins);
ASTContext(const ASTContext &) = delete;
@@ -1406,7 +1441,7 @@ public:
/// Return the unique reference to the type for the specified
/// typedef-name decl.
QualType getTypedefType(const TypedefNameDecl *Decl,
- QualType Canon = QualType()) const;
+ QualType Underlying = QualType()) const;
QualType getRecordType(const RecordDecl *Decl) const;
@@ -1981,9 +2016,9 @@ public:
unsigned char getFixedPointScale(QualType Ty) const;
unsigned char getFixedPointIBits(QualType Ty) const;
- FixedPointSemantics getFixedPointSemantics(QualType Ty) const;
- APFixedPoint getFixedPointMax(QualType Ty) const;
- APFixedPoint getFixedPointMin(QualType Ty) const;
+ llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const;
+ llvm::APFixedPoint getFixedPointMax(QualType Ty) const;
+ llvm::APFixedPoint getFixedPointMin(QualType Ty) const;
DeclarationNameInfo getNameForTemplate(TemplateName Name,
SourceLocation NameLoc) const;
@@ -2022,6 +2057,10 @@ public:
GE_Missing_ucontext
};
+ QualType DecodeTypeStr(const char *&Str, const ASTContext &Context,
+ ASTContext::GetBuiltinTypeError &Error,
+ bool &RequireICE, bool AllowTypeModifiers) const;
+
/// Return the type for the specified builtin.
///
/// If \p IntegerConstantArgs is non-null, it is filled in with a bitmask of
@@ -2054,6 +2093,15 @@ public:
/// types.
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec);
+ /// Return true if the given types are an SVE builtin and a VectorType that
+ /// is a fixed-length representation of the SVE builtin for a specific
+ /// vector-length.
+ bool areCompatibleSveTypes(QualType FirstType, QualType SecondType);
+
+ /// Return true if the given vector types are lax-compatible SVE vector types,
+ /// false otherwise.
+ bool areLaxCompatibleSveTypes(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.
@@ -2125,16 +2173,25 @@ public:
}
unsigned getTypeUnadjustedAlign(const Type *T) const;
- /// Return the ABI-specified alignment of a type, in bits, or 0 if
+ /// Return the alignment of a type, in bits, or 0 if
/// the type is incomplete and we cannot determine the alignment (for
- /// example, from alignment attributes).
- unsigned getTypeAlignIfKnown(QualType T) const;
+ /// example, from alignment attributes). The returned alignment is the
+ /// Preferred alignment if NeedsPreferredAlignment is true, otherwise is the
+ /// ABI alignment.
+ unsigned getTypeAlignIfKnown(QualType T,
+ bool NeedsPreferredAlignment = false) const;
/// Return the ABI-specified alignment of a (complete) type \p T, in
/// characters.
CharUnits getTypeAlignInChars(QualType T) const;
CharUnits getTypeAlignInChars(const Type *T) const;
+ /// Return the PreferredAlignment of a (complete) type \p T, in
+ /// characters.
+ CharUnits getPreferredTypeAlignInChars(QualType T) const {
+ return toCharUnitsFromBits(getPreferredTypeAlign(T));
+ }
+
/// getTypeUnadjustedAlignInChars - Return the ABI-specified alignment of a type,
/// in characters, before alignment adjustments. This method does not work on
/// incomplete types.
@@ -2143,10 +2200,10 @@ public:
// getTypeInfoDataSizeInChars - Return the size of a type, in chars. If the
// type is a record, its data size is returned.
- std::pair<CharUnits, CharUnits> getTypeInfoDataSizeInChars(QualType T) const;
+ TypeInfoChars getTypeInfoDataSizeInChars(QualType T) const;
- std::pair<CharUnits, CharUnits> getTypeInfoInChars(const Type *T) const;
- std::pair<CharUnits, CharUnits> getTypeInfoInChars(QualType T) const;
+ TypeInfoChars getTypeInfoInChars(const Type *T) const;
+ TypeInfoChars getTypeInfoInChars(QualType T) const;
/// Determine if the alignment the type has was required using an
/// alignment attribute.
@@ -2157,7 +2214,12 @@ public:
/// the current target, in bits.
///
/// This can be different than the ABI alignment in cases where it is
- /// beneficial for performance to overalign a data type.
+ /// beneficial for performance or backwards compatibility preserving to
+ /// overalign a data type. (Note: despite the name, the preferred alignment
+ /// is ABI-impacting, and not an optimization.)
+ unsigned getPreferredTypeAlign(QualType T) const {
+ return getPreferredTypeAlign(T.getTypePtr());
+ }
unsigned getPreferredTypeAlign(const Type *T) const;
/// Return the default alignment for __attribute__((aligned)) on
@@ -2250,6 +2312,10 @@ public:
const ObjCImplementationDecl *ID,
const ObjCIvarDecl *Ivar) const;
+ /// Find the 'this' offset for the member path in a pointer-to-member
+ /// APValue.
+ CharUnits getMemberPointerPathAdjustment(const APValue &MP) const;
+
bool isNearlyEmpty(const CXXRecordDecl *RD) const;
VTableContextBase *getVTableContext();
@@ -2345,12 +2411,10 @@ public:
return (*SuperTnullability == NullabilityKind::NonNull &&
*SubTnullability == NullabilityKind::Nullable);
}
- else {
- // For the return type, it's okay for the superclass method to specify
- // "nullable" and the subclass method specify "nonnull"
- return (*SuperTnullability == NullabilityKind::Nullable &&
- *SubTnullability == NullabilityKind::NonNull);
- }
+ // For the return type, it's okay for the superclass method to specify
+ // "nullable" and the subclass method specify "nonnull"
+ return (*SuperTnullability == NullabilityKind::Nullable &&
+ *SubTnullability == NullabilityKind::NonNull);
}
return true;
}
@@ -2830,6 +2894,11 @@ public:
/// GUID value.
MSGuidDecl *getMSGuidDecl(MSGuidDeclParts Parts) const;
+ /// Return the template parameter object of the given type with the given
+ /// value.
+ TemplateParamObjectDecl *getTemplateParamObjectDecl(QualType T,
+ const APValue &V) const;
+
/// Parses the target attributes passed in, and returns only the ones that are
/// valid feature names.
ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const;
@@ -3025,13 +3094,12 @@ public:
};
struct SectionInfo {
- DeclaratorDecl *Decl;
+ NamedDecl *Decl;
SourceLocation PragmaSectionLocation;
int SectionFlags;
SectionInfo() = default;
- SectionInfo(DeclaratorDecl *Decl,
- SourceLocation PragmaSectionLocation,
+ SectionInfo(NamedDecl *Decl, SourceLocation PragmaSectionLocation,
int SectionFlags)
: Decl(Decl), PragmaSectionLocation(PragmaSectionLocation),
SectionFlags(SectionFlags) {}
@@ -3042,6 +3110,12 @@ 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 should be externalized.
+ bool shouldExternalizeStaticVar(const Decl *D) const;
+
private:
/// All OMPTraitInfo objects live in this collection, one per
/// `pragma omp [begin] declare variant` directive.
@@ -3049,8 +3123,8 @@ private:
};
/// Insertion operator for diagnostics.
-const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
- const ASTContext::SectionInfo &Section);
+const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
+ const ASTContext::SectionInfo &Section);
/// Utility function for constructing a nullary selector.
inline Selector GetNullarySelector(StringRef name, ASTContext &Ctx) {