20#include "llvm/ADT/SmallPtrSet.h"
28 bool &IncompleteType) {
29 QualType CanonicalType =
T.getCanonicalType();
40 if (II && II->
isStr(
"uintptr_t"))
45 if (
const ArrayType *AT = dyn_cast<ArrayType>(CanonicalType))
49 if (!RD->isCompleteDefinition()) {
50 IncompleteType =
true;
53 if (!VisitedRD.insert(RD).second)
56 for (
const FieldDecl *Field : RD->fields()) {
61 if (
const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
63 if (CXXRD->isDynamicClass())
77 if (
const auto *UET = dyn_cast<UnaryExprOrTypeTraitExpr>(Arg)) {
78 if (UET->getKind() == UETT_SizeOf) {
79 if (UET->isArgumentType())
80 return UET->getArgumentTypeInfo()->getType();
82 return UET->getArgumentExpr()->getType();
106 if (
const auto *BO = dyn_cast<BinaryOperator>(Arg)) {
109 switch (BO->getOpcode()) {
139 if (
const auto *DRE = dyn_cast<DeclRefExpr>(Arg)) {
140 if (
const auto *VD = dyn_cast<VarDecl>(DRE->getDecl())) {
141 if (
const Expr *
Init = VD->getInit())
181std::optional<llvm::AllocTokenMetadata>
183 llvm::AllocTokenMetadata ATMD;
189 llvm::raw_svector_ostream TypeNameOS(ATMD.TypeName);
190 T.getCanonicalType().print(TypeNameOS, Policy);
195 bool IncompleteType =
false;
197 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.
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.
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.
const FunctionProtoType * T
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.