20#include "llvm/ADT/SmallPtrSet.h"
28 bool &IncompleteType) {
29 QualType CanonicalType =
T.getCanonicalType();
42 if (II && II->
isStr(
"uintptr_t"))
47 if (
const ArrayType *AT = dyn_cast<ArrayType>(CanonicalType))
51 if (
const AtomicType *AT = dyn_cast<AtomicType>(CanonicalType))
56 if (!RD->isCompleteDefinition()) {
57 IncompleteType =
true;
60 if (!VisitedRD.insert(RD).second)
63 for (
const FieldDecl *Field : RD->fields()) {
68 if (
const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
70 if (CXXRD->isDynamicClass())
84 if (
const auto *UET = dyn_cast<UnaryExprOrTypeTraitExpr>(Arg)) {
85 if (UET->getKind() == UETT_SizeOf) {
86 if (UET->isArgumentType())
87 return UET->getArgumentTypeInfo()->getType();
89 return UET->getArgumentExpr()->getType();
113 if (
const auto *BO = dyn_cast<BinaryOperator>(Arg)) {
116 switch (BO->getOpcode()) {
146 if (
const auto *DRE = dyn_cast<DeclRefExpr>(Arg)) {
147 if (
const auto *VD = dyn_cast<VarDecl>(DRE->getDecl())) {
148 if (
const Expr *
Init = VD->getInit())
188std::optional<llvm::AllocTokenMetadata>
190 llvm::AllocTokenMetadata ATMD;
195 Policy.FullyQualifiedName =
true;
196 llvm::raw_svector_ostream TypeNameOS(ATMD.TypeName);
197 T.getCanonicalType().print(TypeNameOS, Policy);
202 bool IncompleteType =
false;
204 if (!ATMD.ContainsPointer && IncompleteType)
Defines the clang::ASTContext interface.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
static QualType inferTypeFromSizeofExpr(const Expr *E)
Infer type from a simple sizeof expression.
static QualType inferPossibleTypeFromArithSizeofExpr(const Expr *E)
Infer type from an arithmetic expression involving a sizeof.
static bool typeContainsPointer(QualType T, llvm::SmallPtrSet< const RecordDecl *, 4 > &VisitedRD, bool &IncompleteType)
static QualType inferPossibleTypeFromVarInitSizeofExpr(const Expr *E)
If the expression E is a reference to a variable, infer the type from a variable's initializer if it ...
static QualType inferPossibleTypeFromCastExpr(const CallExpr *CallE, const CastExpr *CastE)
Deduces the allocated type by checking if the allocation call's result is immediately used in a cast ...
static QualType getUnderlyingType(const SubRegion *R)
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const LangOptions & getLangOpts() const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Represents a base class of a C++ class.
Represents a C++ struct/union/class.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
This represents one expression.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Represents a member of a struct/union/class.
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Represents a struct/union/class.
bool isBlockPointerType() const
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
bool isPointerType() const
bool isReferenceType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isMemberFunctionPointerType() const
bool isAnyPointerType() const
TypedefNameDecl * getDecl() const
std::optional< llvm::AllocTokenMetadata > getAllocTokenMetadata(QualType T, const ASTContext &Ctx)
Get the information required for construction of an allocation token ID.
QualType inferPossibleType(const CallExpr *E, const ASTContext &Ctx, const CastExpr *CastE)
Infer the possible allocated type from an allocation call expression.
Top level wrappers for InstallAPI frontend operations.
const FunctionProtoType * T
Describes how types, statements, expressions, and declarations should be printed.
unsigned SuppressTagKeyword
Whether type printing should skip printing the tag keyword.