clang  6.0.0svn
Macros | Enumerations | Functions | Variables
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 "ConstantEmitter.h"
#include "TargetInfo.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/NSAPI.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 <string>
Include dependency graph for CGExpr.cpp:

Go to the source code of this file.

Macros

#define SANITIZER_CHECK(Enum, Name, Version)   {#Name, Version},
 

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 DeclRefExprtryToConvertMemberExprToDeclRefExpr (CodeGenFunction &CGF, const MemberExpr *ME)
 
static bool hasBooleanRepresentation (QualType Ty)
 
static bool getRangeForType (CodeGenFunction &CGF, QualType Ty, llvm::APInt &Min, llvm::APInt &End, bool StrictEnums, bool IsBool)
 
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 llvm::Constant * EmitFunctionDeclPointer (CodeGenModule &CGM, const FunctionDecl *FD)
 
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, SanitizerHandler CheckHandler, 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, bool signedIndices, SourceLocation loc, 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, bool signedIndices, SourceLocation loc, const llvm::Twine &name="arrayidx")
 
static Address emitOMPArraySectionBase (CodeGenFunction &CGF, const Expr *Base, LValueBaseInfo &BaseInfo, TBAAAccessInfo &TBAAInfo, 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 bool hasAnyVptr (const QualType Type, const ASTContext &Context)
 
static Optional< LValueEmitLValueOrThrowExpression (CodeGenFunction &CGF, const Expr *Operand)
 Emit the operand of a glvalue conditional operator. More...
 
static CGCallee EmitDirectCallee (CodeGenFunction &CGF, const FunctionDecl *FD)
 
static LValueOrRValue emitPseudoObjectExpr (CodeGenFunction &CGF, const PseudoObjectExpr *E, bool forLValue, AggValueSlot slot)
 

Variables

const SanitizerHandlerInfo SanitizerHandlers []
 

Macro Definition Documentation

◆ SANITIZER_CHECK

#define SANITIZER_CHECK (   Enum,
  Name,
  Version 
)    {#Name, Version},

Enumeration Type Documentation

◆ CheckRecoverableKind

enum CheckRecoverableKind
strong

Specify under what conditions this check can be recovered.

Definition at line 2696 of file CGExpr.cpp.

◆ ConstantEmissionKind

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 1278 of file CGExpr.cpp.

Function Documentation

◆ checkVarTypeForConstantEmission()

static ConstantEmissionKind checkVarTypeForConstantEmission ( QualType  type)
static

◆ createReferenceTemporary()

static Address createReferenceTemporary ( CodeGenFunction CGF,
const MaterializeTemporaryExpr M,
const Expr Inner 
)
static

◆ emitAddrOfFieldStorage()

static Address emitAddrOfFieldStorage ( CodeGenFunction CGF,
Address  base,
const FieldDecl field 
)
static

◆ emitArraySubscriptGEP() [1/2]

static llvm::Value* emitArraySubscriptGEP ( CodeGenFunction CGF,
llvm::Value ptr,
ArrayRef< llvm::Value *>  indices,
bool  inbounds,
bool  signedIndices,
SourceLocation  loc,
const llvm::Twine &  name = "arrayidx" 
)
static

◆ emitArraySubscriptGEP() [2/2]

static Address emitArraySubscriptGEP ( CodeGenFunction CGF,
Address  addr,
ArrayRef< llvm::Value *>  indices,
QualType  eltType,
bool  inbounds,
bool  signedIndices,
SourceLocation  loc,
const llvm::Twine &  name = "arrayidx" 
)
static

◆ EmitBitCastOfLValueToProperType()

static llvm::Value* EmitBitCastOfLValueToProperType ( CodeGenFunction CGF,
llvm::Value V,
llvm::Type *  IRType,
StringRef  Name = StringRef() 
)
static

Definition at line 2149 of file CGExpr.cpp.

◆ EmitCapturedFieldLValue()

static LValue EmitCapturedFieldLValue ( CodeGenFunction CGF,
const FieldDecl FD,
llvm::Value ThisValue 
)
static

◆ emitCheckHandlerCall()

static void emitCheckHandlerCall ( CodeGenFunction CGF,
llvm::FunctionType *  FnType,
ArrayRef< llvm::Value *>  FnArgs,
SanitizerHandler  CheckHandler,
CheckRecoverableKind  RecoverKind,
bool  IsFatal,
llvm::BasicBlock *  ContBB 
)
static

◆ EmitDirectCallee()

static CGCallee EmitDirectCallee ( CodeGenFunction CGF,
const FunctionDecl FD 
)
static

◆ EmitFunctionDeclLValue()

static LValue EmitFunctionDeclLValue ( CodeGenFunction CGF,
const Expr E,
const FunctionDecl FD 
)
static

Definition at line 2253 of file CGExpr.cpp.

◆ EmitFunctionDeclPointer()

static llvm::Constant* EmitFunctionDeclPointer ( CodeGenModule CGM,
const FunctionDecl FD 
)
static

◆ EmitGlobalNamedRegister()

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 2274 of file CGExpr.cpp.

◆ EmitGlobalVarDeclLValue()

static LValue EmitGlobalVarDeclLValue ( CodeGenFunction CGF,
const Expr E,
const VarDecl VD 
)
static

Definition at line 2200 of file CGExpr.cpp.

◆ emitHash16Bytes()

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 557 of file CGExpr.cpp.

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

◆ EmitLValueOrThrowExpression()

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 3855 of file CGExpr.cpp.

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

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

◆ emitOMPArraySectionBase()

static Address emitOMPArraySectionBase ( CodeGenFunction CGF,
const Expr Base,
LValueBaseInfo BaseInfo,
TBAAAccessInfo TBAAInfo,
QualType  BaseTy,
QualType  ElTy,
bool  IsLowerBound 
)
static

◆ emitPseudoObjectExpr()

static LValueOrRValue emitPseudoObjectExpr ( CodeGenFunction CGF,
const PseudoObjectExpr E,
bool  forLValue,
AggValueSlot  slot 
)
static

Definition at line 4626 of file CGExpr.cpp.

◆ EmitThreadPrivateVarDeclLValue()

static LValue EmitThreadPrivateVarDeclLValue ( CodeGenFunction CGF,
const VarDecl VD,
QualType  T,
Address  Addr,
llvm::Type *  RealVarTy,
SourceLocation  Loc 
)
static

◆ getArrayElementAlign()

static CharUnits getArrayElementAlign ( CharUnits  arrayAlign,
llvm::Value idx,
CharUnits  eltSize 
)
static

◆ getArrayIndexingBound()

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 816 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().

◆ getFixedSizeElementType()

static QualType getFixedSizeElementType ( const ASTContext ctx,
const VariableArrayType vla 
)
static

◆ getRangeForType()

static bool getRangeForType ( CodeGenFunction CGF,
QualType  Ty,
llvm::APInt &  Min,
llvm::APInt &  End,
bool  StrictEnums,
bool  IsBool 
)
static

◆ getRecoverableKind()

static CheckRecoverableKind getRecoverableKind ( SanitizerMask  Kind)
static

Definition at line 2707 of file CGExpr.cpp.

References Unrecoverable.

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

◆ hasAnyVptr()

static bool hasAnyVptr ( const QualType  Type,
const ASTContext Context 
)
static

Definition at line 3660 of file CGExpr.cpp.

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

◆ hasBooleanRepresentation()

static bool hasBooleanRepresentation ( QualType  Ty)
static

◆ isConstantEmittableObjectType()

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 1253 of file CGExpr.cpp.

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

Referenced by checkVarTypeForConstantEmission().

◆ isFlexibleArrayMemberExpr()

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 786 of file CGExpr.cpp.

Referenced by getArrayIndexingBound().

◆ isSimpleArrayDecayOperand()

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 3097 of file CGExpr.cpp.

◆ pushTemporaryCleanup()

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

Definition at line 229 of file CGExpr.cpp.

◆ setObjCGCLValueClass()

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

Definition at line 2051 of file CGExpr.cpp.

◆ tryToConvertMemberExprToDeclRefExpr()

static DeclRefExpr* tryToConvertMemberExprToDeclRefExpr ( CodeGenFunction CGF,
const MemberExpr ME 
)
static

Variable Documentation

◆ SanitizerHandlers

const SanitizerHandlerInfo SanitizerHandlers[]
Initial value:
= {
#define SANITIZER_CHECK(Enum, Name, Version)
}
#define LIST_SANITIZER_CHECKS

Definition at line 2727 of file CGExpr.cpp.