clang  3.9.0
Enumerations | Functions
CGExpr.cpp File Reference
#include "CGCXXABI.h"
#include "CGCall.h"
#include "CGCleanup.h"
#include "CGDebugInfo.h"
#include "CGObjCRuntime.h"
#include "CGOpenMPRuntime.h"
#include "CGRecordLayout.h"
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "TargetInfo.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
#include "clang/AST/DeclObjC.h"
#include "clang/Frontend/CodeGenOptions.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/Path.h"
#include "llvm/Transforms/Utils/SanitizerStats.h"
Include dependency graph for CGExpr.cpp:

Go to the source code of this file.

Enumerations

enum  ConstantEmissionKind { CEK_None, CEK_AsReferenceOnly, CEK_AsValueOrReference, CEK_AsValueOnly }
 Can we constant-emit a load of a reference to a variable of the given type? This is different from predicates like Decl::isUsableInConstantExpressions because we do want it to apply in situations that don't necessarily satisfy the language's rules for this (e.g. More...
 
enum  CheckRecoverableKind
 Specify under what conditions this check can be recovered. More...
 

Functions

static void pushTemporaryCleanup (CodeGenFunction &CGF, const MaterializeTemporaryExpr *M, const Expr *E, Address ReferenceTemporary)
 
static Address createReferenceTemporary (CodeGenFunction &CGF, const MaterializeTemporaryExpr *M, const Expr *Inner)
 
static llvm::ValueemitHash16Bytes (CGBuilderTy &Builder, llvm::Value *Low, llvm::Value *High)
 Emit the hash_16_bytes function from include/llvm/ADT/Hashing.h. More...
 
static bool isFlexibleArrayMemberExpr (const Expr *E)
 Determine whether this expression refers to a flexible array member in a struct. More...
 
static llvm::ValuegetArrayIndexingBound (CodeGenFunction &CGF, const Expr *Base, QualType &IndexedType)
 If Base is known to point to the start of an array, return the length of that array. More...
 
static bool isConstantEmittableObjectType (QualType type)
 Given an object of the given canonical type, can we safely copy a value out of it based on its initializer? More...
 
static ConstantEmissionKind checkVarTypeForConstantEmission (QualType type)
 
static bool hasBooleanRepresentation (QualType Ty)
 
static bool getRangeForType (CodeGenFunction &CGF, QualType Ty, llvm::APInt &Min, llvm::APInt &End, bool StrictEnums)
 
static void setObjCGCLValueClass (const ASTContext &Ctx, const Expr *E, LValue &LV, bool IsMemberAccess=false)
 
static llvm::ValueEmitBitCastOfLValueToProperType (CodeGenFunction &CGF, llvm::Value *V, llvm::Type *IRType, StringRef Name=StringRef())
 
static LValue EmitThreadPrivateVarDeclLValue (CodeGenFunction &CGF, const VarDecl *VD, QualType T, Address Addr, llvm::Type *RealVarTy, SourceLocation Loc)
 
static LValue EmitGlobalVarDeclLValue (CodeGenFunction &CGF, const Expr *E, const VarDecl *VD)
 
static LValue EmitFunctionDeclLValue (CodeGenFunction &CGF, const Expr *E, const FunctionDecl *FD)
 
static LValue EmitCapturedFieldLValue (CodeGenFunction &CGF, const FieldDecl *FD, llvm::Value *ThisValue)
 
static LValue EmitGlobalNamedRegister (const VarDecl *VD, CodeGenModule &CGM)
 Named Registers are named metadata pointing to the register name which will be read from/written to as an argument to the intrinsic .read/write_register. More...
 
static CheckRecoverableKind getRecoverableKind (SanitizerMask Kind)
 
static void emitCheckHandlerCall (CodeGenFunction &CGF, llvm::FunctionType *FnType, ArrayRef< llvm::Value * > FnArgs, StringRef CheckName, CheckRecoverableKind RecoverKind, bool IsFatal, llvm::BasicBlock *ContBB)
 
static const ExprisSimpleArrayDecayOperand (const Expr *E)
 isSimpleArrayDecayOperand - If the specified expr is a simple decay from an array to pointer, return the array subexpression. More...
 
static llvm::ValueemitArraySubscriptGEP (CodeGenFunction &CGF, llvm::Value *ptr, ArrayRef< llvm::Value * > indices, bool inbounds, const llvm::Twine &name="arrayidx")
 
static CharUnits getArrayElementAlign (CharUnits arrayAlign, llvm::Value *idx, CharUnits eltSize)
 
static QualType getFixedSizeElementType (const ASTContext &ctx, const VariableArrayType *vla)
 
static Address emitArraySubscriptGEP (CodeGenFunction &CGF, Address addr, ArrayRef< llvm::Value * > indices, QualType eltType, bool inbounds, const llvm::Twine &name="arrayidx")
 
static Address emitOMPArraySectionBase (CodeGenFunction &CGF, const Expr *Base, AlignmentSource &AlignSource, QualType BaseTy, QualType ElTy, bool IsLowerBound)
 
static Address emitAddrOfFieldStorage (CodeGenFunction &CGF, Address base, const FieldDecl *field)
 Drill down to the storage of a field without walking into reference types. More...
 
static Optional< LValueEmitLValueOrThrowExpression (CodeGenFunction &CGF, const Expr *Operand)
 Emit the operand of a glvalue conditional operator. More...
 
static LValueOrRValue emitPseudoObjectExpr (CodeGenFunction &CGF, const PseudoObjectExpr *E, bool forLValue, AggValueSlot slot)
 

Enumeration Type Documentation

enum CheckRecoverableKind
strong

Specify under what conditions this check can be recovered.

Definition at line 2439 of file CGExpr.cpp.

Can we constant-emit a load of a reference to a variable of the given type? This is different from predicates like Decl::isUsableInConstantExpressions because we do want it to apply in situations that don't necessarily satisfy the language's rules for this (e.g.

C++'s ODR-use rules). For example, we want to able to do this with const float variables even if those variables aren't marked 'constexpr'.

Enumerator
CEK_None 
CEK_AsReferenceOnly 
CEK_AsValueOrReference 
CEK_AsValueOnly 

Definition at line 1111 of file CGExpr.cpp.

Function Documentation

static ConstantEmissionKind checkVarTypeForConstantEmission ( QualType  type)
static
static Address createReferenceTemporary ( CodeGenFunction CGF,
const MaterializeTemporaryExpr M,
const Expr Inner 
)
static
static Address emitAddrOfFieldStorage ( CodeGenFunction CGF,
Address  base,
const FieldDecl field 
)
static
static llvm::Value* emitArraySubscriptGEP ( CodeGenFunction CGF,
llvm::Value ptr,
ArrayRef< llvm::Value * >  indices,
bool  inbounds,
const llvm::Twine &  name = "arrayidx" 
)
static
static Address emitArraySubscriptGEP ( CodeGenFunction CGF,
Address  addr,
ArrayRef< llvm::Value * >  indices,
QualType  eltType,
bool  inbounds,
const llvm::Twine &  name = "arrayidx" 
)
static
static llvm::Value* EmitBitCastOfLValueToProperType ( CodeGenFunction CGF,
llvm::Value V,
llvm::Type *  IRType,
StringRef  Name = StringRef() 
)
static
static LValue EmitCapturedFieldLValue ( CodeGenFunction CGF,
const FieldDecl FD,
llvm::Value ThisValue 
)
static
static void emitCheckHandlerCall ( CodeGenFunction CGF,
llvm::FunctionType *  FnType,
ArrayRef< llvm::Value * >  FnArgs,
StringRef  CheckName,
CheckRecoverableKind  RecoverKind,
bool  IsFatal,
llvm::BasicBlock *  ContBB 
)
static
static LValue EmitFunctionDeclLValue ( CodeGenFunction CGF,
const Expr E,
const FunctionDecl FD 
)
static
static LValue EmitGlobalNamedRegister ( const VarDecl VD,
CodeGenModule CGM 
)
static

Named Registers are named metadata pointing to the register name which will be read from/written to as an argument to the intrinsic .read/write_register.

So far, only the name is being passed down, but other options such as register type, allocation type or even optimization options could be passed down via the metadata node.

Definition at line 2050 of file CGExpr.cpp.

References clang::CodeGen::CodeGenModule::getContext(), clang::ASTContext::getDeclAlign(), clang::CodeGen::CodeGenModule::getLLVMContext(), clang::CodeGen::CodeGenModule::getModule(), clang::ValueDecl::getType(), and clang::Name.

Referenced by clang::CodeGen::CodeGenFunction::EmitDeclRefLValue().

static LValue EmitGlobalVarDeclLValue ( CodeGenFunction CGF,
const Expr E,
const VarDecl VD 
)
static
static llvm::Value* emitHash16Bytes ( CGBuilderTy Builder,
llvm::Value Low,
llvm::Value High 
)
static

Emit the hash_16_bytes function from include/llvm/ADT/Hashing.h.

Definition at line 514 of file CGExpr.cpp.

static Optional<LValue> EmitLValueOrThrowExpression ( CodeGenFunction CGF,
const Expr Operand 
)
static

Emit the operand of a glvalue conditional operator.

This is either a glvalue or a (possibly-parenthesized) throw-expression. If this is a throw, no LValue is returned and the current block has been terminated.

Definition at line 3472 of file CGExpr.cpp.

References clang::CodeGen::CodeGenFunction::EmitCXXThrowExpr(), clang::CodeGen::CodeGenFunction::EmitLValue(), clang::Expr::IgnoreParens(), and clang::None.

Referenced by clang::CodeGen::CodeGenFunction::EmitConditionalOperatorLValue().

static Address emitOMPArraySectionBase ( CodeGenFunction CGF,
const Expr Base,
AlignmentSource AlignSource,
QualType  BaseTy,
QualType  ElTy,
bool  IsLowerBound 
)
static
static LValueOrRValue emitPseudoObjectExpr ( CodeGenFunction CGF,
const PseudoObjectExpr E,
bool  forLValue,
AggValueSlot  slot 
)
static
static LValue EmitThreadPrivateVarDeclLValue ( CodeGenFunction CGF,
const VarDecl VD,
QualType  T,
Address  Addr,
llvm::Type *  RealVarTy,
SourceLocation  Loc 
)
static
static CharUnits getArrayElementAlign ( CharUnits  arrayAlign,
llvm::Value idx,
CharUnits  eltSize 
)
static
static llvm::Value* getArrayIndexingBound ( CodeGenFunction CGF,
const Expr Base,
QualType IndexedType 
)
static

If Base is known to point to the start of an array, return the length of that array.

Return 0 if the length cannot be determined.

Definition at line 718 of file CGExpr.cpp.

References clang::CodeGen::CodeGenFunction::Builder, clang::Type::castAsArrayTypeUnsafe(), clang::Type::getAs(), clang::Expr::getType(), clang::CodeGen::CodeGenFunction::getVLASize(), clang::Expr::IgnoreParens(), and isFlexibleArrayMemberExpr().

Referenced by clang::CodeGen::CodeGenFunction::EmitBoundsCheck().

static QualType getFixedSizeElementType ( const ASTContext ctx,
const VariableArrayType vla 
)
static
static bool getRangeForType ( CodeGenFunction CGF,
QualType  Ty,
llvm::APInt &  Min,
llvm::APInt &  End,
bool  StrictEnums 
)
static
static CheckRecoverableKind getRecoverableKind ( SanitizerMask  Kind)
static

Definition at line 2450 of file CGExpr.cpp.

References Unrecoverable.

Referenced by clang::CodeGen::CodeGenFunction::EmitCheck().

static bool hasBooleanRepresentation ( QualType  Ty)
static
static bool isConstantEmittableObjectType ( QualType  type)
static

Given an object of the given canonical type, can we safely copy a value out of it based on its initializer?

Definition at line 1086 of file CGExpr.cpp.

References clang::QualType::getLocalQualifiers(), clang::QualType::isCanonical(), and clang::Type::isReferenceType().

Referenced by checkVarTypeForConstantEmission().

static bool isFlexibleArrayMemberExpr ( const Expr E)
static

Determine whether this expression refers to a flexible array member in a struct.

We disable array bounds checks for such members.

Definition at line 690 of file CGExpr.cpp.

References clang::Type::castAsArrayTypeUnsafe(), clang::Expr::getType(), and clang::Expr::IgnoreParens().

Referenced by getArrayIndexingBound().

static const Expr* isSimpleArrayDecayOperand ( const Expr E)
static

isSimpleArrayDecayOperand - If the specified expr is a simple decay from an array to pointer, return the array subexpression.

Definition at line 2792 of file CGExpr.cpp.

References E, clang::Expr::getType(), and clang::Type::isVariableArrayType().

Referenced by clang::CodeGen::CodeGenFunction::EmitArraySubscriptExpr(), and clang::CodeGen::CodeGenFunction::EmitOMPArraySectionExpr().

static void pushTemporaryCleanup ( CodeGenFunction CGF,
const MaterializeTemporaryExpr M,
const Expr E,
Address  ReferenceTemporary 
)
static

Definition at line 199 of file CGExpr.cpp.

References clang::CodeGen::CodeGenFunction::CGM, clang::CodeGen::Complete, clang::CodeGen::Destroy(), clang::CodeGen::CodeGenFunction::destroyARCStrongImprecise, clang::CodeGen::CodeGenFunction::destroyARCStrongPrecise, clang::CodeGen::CodeGenFunction::destroyARCWeak, clang::CodeGen::CodeGenFunction::destroyCXXObject, clang::CodeGen::EHCleanup, clang::CodeGen::CodeGenFunction::generateDestroyHelper(), clang::CodeGen::CodeGenModule::getAddrOfCXXStructor(), clang::CodeGen::CodeGenFunction::getARCCleanupKind(), clang::Type::getAs(), clang::Type::getBaseElementTypeUnsafe(), clang::CodeGen::CodeGenModule::getCXXABI(), clang::MaterializeTemporaryExpr::getExtendingDecl(), clang::CodeGen::CodeGenFunction::getLangOpts(), clang::QualType::getObjCLifetime(), clang::CodeGen::Address::getPointer(), clang::MaterializeTemporaryExpr::getStorageDuration(), clang::Expr::getType(), clang::CodeGen::CodeGenTypeCache::Int8PtrTy, clang::Type::isArrayType(), clang::CodeGen::NormalAndEHCleanup, clang::Qualifiers::OCL_Autoreleasing, clang::Qualifiers::OCL_ExplicitNone, clang::Qualifiers::OCL_None, clang::Qualifiers::OCL_Strong, clang::Qualifiers::OCL_Weak, clang::CodeGen::CodeGenFunction::pushDestroy(), clang::CodeGen::CodeGenFunction::pushLifetimeExtendedDestroy(), clang::CodeGen::CGCXXABI::registerGlobalDtor(), clang::SD_Automatic, clang::SD_Dynamic, clang::SD_FullExpression, clang::SD_Static, and clang::SD_Thread.

Referenced by clang::CodeGen::CodeGenFunction::EmitMaterializeTemporaryExpr().

static void setObjCGCLValueClass ( const ASTContext Ctx,
const Expr E,
LValue LV,
bool  IsMemberAccess = false 
)
static