clang
6.0.0
|
#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>
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::Value * | emitHash16Bytes (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::Value * | getArrayIndexingBound (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 DeclRefExpr * | tryToConvertMemberExprToDeclRefExpr (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::Value * | EmitBitCastOfLValueToProperType (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 Expr * | isSimpleArrayDecayOperand (const Expr *E) |
isSimpleArrayDecayOperand - If the specified expr is a simple decay from an array to pointer, return the array subexpression. More... | |
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 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< LValue > | EmitLValueOrThrowExpression (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 [] |
#define SANITIZER_CHECK | ( | Enum, | |
Name, | |||
Version | |||
) | {#Name, Version}, |
|
strong |
Specify under what conditions this check can be recovered.
Definition at line 2744 of file CGExpr.cpp.
enum 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 1327 of file CGExpr.cpp.
|
static |
Definition at line 1333 of file CGExpr.cpp.
References CEK_AsReferenceOnly, CEK_AsValueOnly, CEK_AsValueOrReference, CEK_None, clang::QualType::getCanonicalType(), and isConstantEmittableObjectType().
Referenced by clang::CodeGen::CodeGenFunction::tryEmitAsConstant().
|
static |
Definition at line 348 of file CGExpr.cpp.
References clang::CodeGen::CodeGenFunction::CGM, clang::CodeGen::CodeGenFunction::CreateMemTemp(), clang::Default, clang::CodeGen::CodeGenFunction::EmitMaterializeTemporaryExpr(), clang::CodeGen::CodeGenModule::GetAddrOfGlobalTemporary(), clang::CodeGen::CodeGenModule::getCodeGenOpts(), clang::TargetInfo::getConstantAddressSpace(), clang::CodeGen::CodeGenFunction::getContext(), clang::CodeGen::CodeGenModule::getModule(), clang::MaterializeTemporaryExpr::getStorageDuration(), clang::CodeGen::CodeGenFunction::getTarget(), clang::ASTContext::getTargetAddressSpace(), clang::CodeGen::CodeGenFunction::getTargetHooks(), clang::Expr::getType(), clang::ASTContext::getTypeAlignInChars(), clang::Type::isArrayType(), clang::Type::isRecordType(), clang::CodeGen::CodeGenModule::isTypeConstant(), clang::SD_Automatic, clang::SD_Dynamic, clang::SD_FullExpression, clang::SD_Static, clang::SD_Thread, and clang::CodeGen::ConstantEmitter::tryEmitAbstract().
|
static |
Drill down to the storage of a field without walking into reference types.
The resulting address doesn't necessarily have the right type.
Definition at line 3705 of file CGExpr.cpp.
References clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::CGM, clang::CodeGen::CGBuilderTy::CreateStructGEP(), clang::ASTContext::getASTRecordLayout(), clang::CodeGen::CodeGenTypes::getCGRecordLayout(), clang::CodeGen::CodeGenFunction::getContext(), clang::FieldDecl::getFieldIndex(), clang::ASTRecordLayout::getFieldOffset(), clang::CodeGen::CGRecordLayout::getLLVMFieldNo(), clang::NamedDecl::getName(), clang::FieldDecl::getParent(), clang::CodeGen::CodeGenModule::getTypes(), and clang::ASTContext::toCharUnitsFromBits().
Referenced by clang::CodeGen::CodeGenFunction::EmitLValueForField(), and clang::CodeGen::CodeGenFunction::EmitLValueForFieldInitialization().
|
static |
Definition at line 3176 of file CGExpr.cpp.
References clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::EmitCheckedInBoundsGEP(), and clang::CodeGen::CodeGenFunction::NotSubtraction.
Referenced by emitArraySubscriptGEP().
|
static |
Definition at line 3216 of file CGExpr.cpp.
References emitArraySubscriptGEP(), clang::CodeGen::Address::getAlignment(), getArrayElementAlign(), clang::ASTContext::getAsVariableArrayType(), clang::CodeGen::CodeGenFunction::getContext(), getFixedSizeElementType(), clang::CodeGen::Address::getPointer(), and clang::ASTContext::getTypeSizeInChars().
|
static |
Definition at line 2194 of file CGExpr.cpp.
|
static |
|
static |
Definition at line 2781 of file CGExpr.cpp.
References clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::CGM, clang::CodeGen::CodeGenModule::CreateRuntimeFunction(), clang::CodeGen::CodeGenFunction::EmitNounwindRuntimeCall(), clang::CodeGen::CodeGenModule::getCodeGenOpts(), clang::CodeGen::CodeGenFunction::getLLVMContext(), and Unrecoverable.
Referenced by clang::CodeGen::CodeGenFunction::EmitCheck().
|
static |
Definition at line 4231 of file CGExpr.cpp.
References clang::CodeGen::CodeGenFunction::CGM, EmitFunctionDeclPointer(), clang::CodeGen::CGCallee::forBuiltin(), clang::CodeGen::CGCallee::forDirect(), and clang::FunctionDecl::getBuiltinID().
|
static |
Definition at line 2303 of file CGExpr.cpp.
|
static |
Definition at line 2279 of file CGExpr.cpp.
References clang::CodeGen::CodeGenTypes::ConvertType(), clang::CodeGen::CodeGenModule::GetAddrOfFunction(), clang::Type::getAs(), clang::CodeGen::CodeGenModule::getContext(), clang::ASTContext::getFunctionNoProtoType(), clang::CodeGen::ConstantAddress::getPointer(), clang::ASTContext::getPointerType(), clang::ValueDecl::getType(), clang::CodeGen::CodeGenModule::getTypes(), clang::CodeGen::CodeGenModule::GetWeakRefReference(), clang::Decl::hasAttr(), and clang::FunctionDecl::hasPrototype().
Referenced by EmitDirectCallee().
|
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 2324 of file CGExpr.cpp.
|
static |
Definition at line 2250 of file CGExpr.cpp.
|
static |
Emit the hash_16_bytes function from include/llvm/ADT/Hashing.h.
Definition at line 560 of file CGExpr.cpp.
Referenced by clang::CodeGen::CodeGenFunction::EmitTypeCheck().
|
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 3918 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().
|
static |
Definition at line 3400 of file CGExpr.cpp.
References clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::CGM, clang::CodeGen::CodeGenFunction::ConvertType(), clang::CodeGen::CodeGenFunction::ConvertTypeForMem(), clang::CodeGen::CGBuilderTy::CreateElementBitCast(), clang::CodeGen::CGBuilderTy::CreateLoad(), clang::CodeGen::CGBuilderTy::CreateStructGEP(), clang::CodeGen::CodeGenFunction::EmitOMPArraySectionExpr(), clang::CodeGen::CodeGenFunction::EmitPointerWithAlignment(), clang::CodeGen::LValue::getAddress(), clang::CodeGen::LValue::getBaseInfo(), clang::CodeGen::Address::getElementType(), clang::CodeGen::CodeGenFunction::getNaturalTypeAlignment(), clang::Expr::IgnoreParenImpCasts(), clang::Type::isArrayType(), clang::Type::isVariableArrayType(), clang::CodeGen::LValueBaseInfo::mergeForCast(), clang::CodeGen::CodeGenModule::mergeTBAAInfoForCast(), clang::CodeGen::Type, and clang::CharUnits::Zero().
|
static |
Definition at line 4696 of file CGExpr.cpp.
|
static |
Definition at line 2201 of file CGExpr.cpp.
References clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::CGM, clang::CodeGen::CGBuilderTy::CreateElementBitCast(), clang::CodeGen::Decl, clang::CodeGen::CodeGenModule::getOpenMPRuntime(), and clang::CodeGen::CodeGenFunction::MakeAddrLValue().
|
static |
Definition at line 3192 of file CGExpr.cpp.
References clang::CharUnits::alignmentAtOffset(), and clang::CharUnits::alignmentOfArrayElement().
Referenced by emitArraySubscriptGEP().
|
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 858 of file CGExpr.cpp.
References clang::CodeGen::CodeGenFunction::Builder, clang::Type::castAsArrayTypeUnsafe(), clang::Type::getAs(), clang::Type::getPointeeOrArrayElementType(), clang::Expr::getType(), clang::CodeGen::CodeGenFunction::getVLASize(), clang::Expr::IgnoreParens(), isFlexibleArrayMemberExpr(), and clang::CodeGen::CodeGenFunction::LoadPassedObjectSize().
|
static |
Definition at line 3207 of file CGExpr.cpp.
References clang::ASTContext::getAsVariableArrayType(), and clang::ArrayType::getElementType().
Referenced by emitArraySubscriptGEP().
|
static |
Definition at line 1452 of file CGExpr.cpp.
References clang::CodeGen::CodeGenFunction::CGM, clang::CodeGen::CodeGenFunction::ConvertTypeForMem(), End, clang::Type::getAs(), clang::CodeGen::CodeGenModule::getCodeGenOpts(), clang::CodeGen::CodeGenFunction::getContext(), clang::EnumType::getDecl(), clang::EnumDecl::getIntegerType(), clang::CodeGen::CodeGenFunction::getLangOpts(), clang::CodeGen::CodeGenFunction::getLLVMContext(), clang::EnumDecl::getNumNegativeBits(), clang::EnumDecl::getNumPositiveBits(), clang::ASTContext::getTypeSize(), hasBooleanRepresentation(), clang::EnumDecl::isFixed(), max(), and clang::CodeGen::Type.
Referenced by clang::CodeGen::CodeGenFunction::EmitScalarRangeCheck().
|
static |
Definition at line 2755 of file CGExpr.cpp.
References Unrecoverable.
Referenced by clang::CodeGen::CodeGenFunction::EmitCheck().
|
static |
Definition at line 3728 of file CGExpr.cpp.
Referenced by clang::CodeGen::CodeGenFunction::EmitLValueForField().
Definition at line 1439 of file CGExpr.cpp.
References clang::Type::getAs(), and clang::Type::isBooleanType().
Referenced by clang::CodeGen::CodeGenFunction::EmitFromMemory(), clang::CodeGen::CodeGenFunction::EmitScalarRangeCheck(), clang::CodeGen::CodeGenFunction::EmitStoreThroughBitfieldLValue(), clang::CodeGen::CodeGenFunction::EmitToMemory(), and getRangeForType().
Given an object of the given canonical type, can we safely copy a value out of it based on its initializer?
Definition at line 1302 of file CGExpr.cpp.
References clang::QualType::getLocalQualifiers(), clang::QualType::isCanonical(), and clang::Type::isReferenceType().
Referenced by checkVarTypeForConstantEmission().
Determine whether this expression refers to a flexible array member in a struct.
We disable array bounds checks for such members.
Definition at line 789 of file CGExpr.cpp.
Referenced by getArrayIndexingBound().
isSimpleArrayDecayOperand - If the specified expr is a simple decay from an array to pointer, return the array subexpression.
Definition at line 3162 of file CGExpr.cpp.
|
static |
Definition at line 232 of file CGExpr.cpp.
|
static |
Definition at line 2096 of file CGExpr.cpp.
|
static |
Definition at line 1413 of file CGExpr.cpp.
References clang::DeclRefExpr::Create(), clang::CodeGen::CodeGenFunction::getContext(), clang::MemberExpr::getExprLoc(), clang::MemberExpr::getMemberDecl(), clang::Expr::getType(), and clang::Expr::getValueKind().
Referenced by clang::CodeGen::CodeGenFunction::tryEmitAsConstant().
const SanitizerHandlerInfo SanitizerHandlers[] |
Definition at line 2775 of file CGExpr.cpp.