clang 24.0.0git
clang::CodeGenUtils Namespace Reference

Functions

CanQual< FunctionProtoType > getFormalType (const CXXMethodDecl *MD)
 Returns the canonical formal type of the given C++ method.
llvm::FPClassTest getNoFPClassTestMask (const LangOptions &LangOpts)
 Returns the set of floating-point value kinds that the language options promise never reach a function's arguments or return value.
bool baseInitializerUsesThis (ASTContext &Ctx, const Expr *Init)
 Check whether Init uses 'this' in a way which requires the vtable to be properly set.
bool canSkipVTablePointerInitialization (ASTContext &Ctx, const CXXDestructorDecl *Dtor)
 Check whether we need to initialize any vtable pointers before calling this destructor.
bool fieldHasTrivialDestructorBody (ASTContext &Context, const FieldDecl *Field)
 Check whether destructing Field has no observable behaviors, and thus can be skipped when creating a destructor body.
bool hasUnwindExceptions (const LangOptions &LangOpts)
 Determines whether the language options require us to model unwind exceptions.
bool isAAPCS (const TargetInfo &TargetInfo)
 Helper method to check if the underlying ABI is AAPCS.
bool isInitializerOfDynamicClass (const CXXCtorInitializer *BaseInit)
void checkTargetFeatures (ASTContext &Ctx, DiagnosticsEngine &Diags, const LangOptions &LangOpts, const CallExpr *E, const FunctionDecl *Caller, const FunctionDecl *TargetDecl)
 Check that a call to a target-specific builtin has the required target features enabled in the caller, emitting an error diagnostic if not.
void checkTargetFeatures (ASTContext &Ctx, DiagnosticsEngine &Diags, const LangOptions &LangOpts, SourceLocation Loc, const FunctionDecl *Caller, const FunctionDecl *TargetDecl)
 Overload taking a raw source location instead of a CallExpr.
QualType getFixedSizeElementType (const ASTContext &Ctx, const VariableArrayType *VLA)
 Strip off the variably-modified array types wrapping VLA and return the first element type that has a fixed size.
bool isBlockVarRef (const Expr *E)
 Check whether the value of E is possibly a reference to or into a __block variable.
bool isCheapEnoughToEvaluateUnconditionally (const Expr *E, const ASTContext &Ctx)
 Check whether E is cheap enough and side-effect-free enough to evaluate unconditionally instead of conditionally.
bool isTrivialFiller (const Expr *E)
 Check whether E is a trivial array filler, that is, one that is equivalent to zero-initialization.
bool onlyHasInlineBuiltinDeclaration (const FunctionDecl *FD)
 Detect the unusual situation where an inline version of a builtin is shadowed by a non-inline version.
bool shouldEmitLifetimeMarkers (const CodeGenOptions &CGOpts, const LangOptions &LangOpts)
 Decide whether we need to emit the lifetime markers.
CharUnits computeOffsetHint (ASTContext &Ctx, const CXXRecordDecl *Src, const CXXRecordDecl *Dst)
 Compute the src2dst_offset hint as described in the Itanium C++ ABI [2.9.7].
static bool hasTrivialDestructorBody (ASTContext &Context, const CXXRecordDecl *BaseClassDecl, const CXXRecordDecl *MostDerivedClassDecl)

Function Documentation

◆ baseInitializerUsesThis()

bool clang::CodeGenUtils::baseInitializerUsesThis ( ASTContext & Ctx,
const Expr * Init )

Check whether Init uses 'this' in a way which requires the vtable to be properly set.

Definition at line 33 of file ClassUtils.cpp.

References clang::Init.

Referenced by EmitBaseInitializer(), and clang::CIRGen::CIRGenFunction::emitBaseInitializer().

◆ canSkipVTablePointerInitialization()

bool clang::CodeGenUtils::canSkipVTablePointerInitialization ( ASTContext & Ctx,
const CXXDestructorDecl * Dtor )

◆ checkTargetFeatures() [1/2]

void clang::CodeGenUtils::checkTargetFeatures ( ASTContext & Ctx,
DiagnosticsEngine & Diags,
const LangOptions & LangOpts,
const CallExpr * E,
const FunctionDecl * Caller,
const FunctionDecl * TargetDecl )

◆ checkTargetFeatures() [2/2]

◆ computeOffsetHint()

CharUnits clang::CodeGenUtils::computeOffsetHint ( ASTContext & Ctx,
const CXXRecordDecl * Src,
const CXXRecordDecl * Dst )

Compute the src2dst_offset hint as described in the Itanium C++ ABI [2.9.7].

Definition at line 15 of file ItaniumCXXABIUtils.cpp.

References clang::AS_public, clang::CharUnits::fromQuantity(), clang::ASTContext::getASTRecordLayout(), clang::ASTRecordLayout::getBaseClassOffset(), and clang::CXXRecordDecl::isDerivedFrom().

Referenced by emitDynamicCastInfo().

◆ fieldHasTrivialDestructorBody()

bool clang::CodeGenUtils::fieldHasTrivialDestructorBody ( ASTContext & Context,
const FieldDecl * Field )

Check whether destructing Field has no observable behaviors, and thus can be skipped when creating a destructor body.

So non-record types, anonymous structs/unions, or record types where the destructor doesnt DO anything are considered as this version of 'trivial'. Note: This is a more liberal definition of trivial destruction than the C++ Standard's version, and thus cannot be used as a substitute for C++ Standard requirements.

Definition at line 58 of file CodeGenUtils.cpp.

References clang::Type::getAsCXXRecordDecl(), and hasTrivialDestructorBody().

Referenced by canSkipVTablePointerInitialization(), and hasTrivialDestructorBody().

◆ getFixedSizeElementType()

QualType clang::CodeGenUtils::getFixedSizeElementType ( const ASTContext & Ctx,
const VariableArrayType * VLA )

Strip off the variably-modified array types wrapping VLA and return the first element type that has a fixed size.

Definition at line 15 of file ExprUtils.cpp.

References clang::ASTContext::getAsVariableArrayType(), and clang::ArrayType::getElementType().

Referenced by emitArraySubscriptGEP(), and emitArraySubscriptPtr().

◆ getFormalType()

◆ getNoFPClassTestMask()

llvm::FPClassTest clang::CodeGenUtils::getNoFPClassTestMask ( const LangOptions & LangOpts)

Returns the set of floating-point value kinds that the language options promise never reach a function's arguments or return value.

Definition at line 19 of file CallUtils.cpp.

Referenced by clang::CodeGen::CodeGenModule::ConstructAttributeList().

◆ hasTrivialDestructorBody()

◆ hasUnwindExceptions()

bool clang::CodeGenUtils::hasUnwindExceptions ( const LangOptions & LangOpts)

Determines whether the language options require us to model unwind exceptions.

We treat -fexceptions as mandating this except under the fragile ObjC ABI with only ObjC exceptions enabled. This means, for example, that C with -fexceptions enables this.

Definition at line 96 of file CodeGenUtils.cpp.

References clang::ObjCRuntime::hasUnwindExceptions(), and clang::LangOptions::ObjCRuntime.

Referenced by clang::CIRGen::CIRGenModule::setCIRFunctionAttributesForDefinition(), and clang::CodeGen::CodeGenModule::SetLLVMFunctionAttributesForDefinition().

◆ isAAPCS()

◆ isBlockVarRef()

bool clang::CodeGenUtils::isBlockVarRef ( const Expr * E)

Check whether the value of E is possibly a reference to or into a __block variable.

Definition at line 24 of file ExprUtils.cpp.

References clang::Decl::hasAttr(), clang::Expr::IgnoreParens(), and isBlockVarRef().

Referenced by isBlockVarRef().

◆ isCheapEnoughToEvaluateUnconditionally()

bool clang::CodeGenUtils::isCheapEnoughToEvaluateUnconditionally ( const Expr * E,
const ASTContext & Ctx )

Check whether E is cheap enough and side-effect-free enough to evaluate unconditionally instead of conditionally.

This is used to convert control flow into selects in some cases.

Definition at line 87 of file ExprUtils.cpp.

References clang::Expr::IgnoreParens(), and clang::Expr::isEvaluatable().

◆ isInitializerOfDynamicClass()

◆ isTrivialFiller()

bool clang::CodeGenUtils::isTrivialFiller ( const Expr * E)

Check whether E is a trivial array filler, that is, one that is equivalent to zero-initialization.

Definition at line 100 of file ExprUtils.cpp.

References clang::isa(), and isTrivialFiller().

Referenced by isTrivialFiller().

◆ onlyHasInlineBuiltinDeclaration()

bool clang::CodeGenUtils::onlyHasInlineBuiltinDeclaration ( const FunctionDecl * FD)

Detect the unusual situation where an inline version of a builtin is shadowed by a non-inline version.

In that case we should pick the external one everywhere. That's GCC behavior too.

Definition at line 121 of file ExprUtils.cpp.

References clang::FunctionDecl::getPreviousDecl().

Referenced by EmitDirectCallee().

◆ shouldEmitLifetimeMarkers()

bool clang::CodeGenUtils::shouldEmitLifetimeMarkers ( const CodeGenOptions & CGOpts,
const LangOptions & LangOpts )

Decide whether we need to emit the lifetime markers.

Definition at line 13 of file FunctionUtils.cpp.

References clang::SanitizerSet::has(), and clang::LangOptions::Sanitize.

Referenced by clang::CIRGen::CIRGenFunction::CIRGenFunction().