20#include "llvm/ADT/SmallPtrSet.h"
28 bool &IncompleteType) {
40 if (II && II->
isStr(
"uintptr_t"))
45 if (
const ArrayType *AT = dyn_cast<ArrayType>(CanonicalType))
49 if (
const AtomicType *AT = dyn_cast<AtomicType>(CanonicalType))
54 if (!RD->isCompleteDefinition()) {
55 IncompleteType =
true;
58 if (!VisitedRD.insert(RD).second)
61 for (
const FieldDecl *Field : RD->fields()) {
66 if (
const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
68 if (CXXRD->isDynamicClass())
82 if (
const auto *UET = dyn_cast<UnaryExprOrTypeTraitExpr>(Arg)) {
83 if (UET->getKind() == UETT_SizeOf) {
84 if (UET->isArgumentType())
85 return UET->getArgumentTypeInfo()->getType();
87 return UET->getArgumentExpr()->getType();
111 if (
const auto *BO = dyn_cast<BinaryOperator>(Arg)) {
114 switch (BO->getOpcode()) {
144 if (
const auto *DRE = dyn_cast<DeclRefExpr>(Arg)) {
145 if (
const auto *VD = dyn_cast<VarDecl>(DRE->getDecl())) {
146 if (
const Expr *
Init = VD->getInit())
186std::optional<llvm::AllocTokenMetadata>
188 llvm::AllocTokenMetadata ATMD;
194 llvm::raw_svector_ostream TypeNameOS(ATMD.TypeName);
195 T.getCanonicalType().print(TypeNameOS, Policy);
200 bool IncompleteType =
false;
202 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.
QualType getCanonicalType() const
Represents a struct/union/class.
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
bool isPointerType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
const T * getAs() const
Member-template getAs<specific type>'.
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.
The JSON file list parser is used to communicate input to InstallAPI.
Describes how types, statements, expressions, and declarations should be printed.
unsigned FullyQualifiedName
When true, print the fully qualified name of function declarations.
unsigned SuppressTagKeyword
Whether type printing should skip printing the tag keyword.