[ubsan] Add support for -fsanitize-blacklist
llvm-svn: 172808
This commit is contained in:
@@ -33,10 +33,11 @@ CodeGenFunction::CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext)
|
||||
: CodeGenTypeCache(cgm), CGM(cgm),
|
||||
Target(CGM.getContext().getTargetInfo()),
|
||||
Builder(cgm.getModule().getContext()),
|
||||
SanitizePerformTypeCheck(CGM.getLangOpts().SanitizeNull |
|
||||
CGM.getLangOpts().SanitizeAlignment |
|
||||
CGM.getLangOpts().SanitizeObjectSize |
|
||||
CGM.getLangOpts().SanitizeVptr),
|
||||
SanitizePerformTypeCheck(CGM.getSanOpts().Null |
|
||||
CGM.getSanOpts().Alignment |
|
||||
CGM.getSanOpts().ObjectSize |
|
||||
CGM.getSanOpts().Vptr),
|
||||
SanOpts(&CGM.getSanOpts()),
|
||||
AutoreleaseResult(false), BlockInfo(0), BlockPointer(0),
|
||||
LambdaThisCaptureField(0), NormalCleanupDest(0), NextCleanupDestIndex(1),
|
||||
FirstBlockInfo(0), EHResumeBlock(0), ExceptionSlot(0), EHSelectorSlot(0),
|
||||
@@ -347,6 +348,11 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
|
||||
CurFnInfo = &FnInfo;
|
||||
assert(CurFn->isDeclaration() && "Function already has body?");
|
||||
|
||||
if (CGM.getSanitizerBlacklist().isIn(*Fn)) {
|
||||
SanOpts = &SanitizerOptions::Disabled;
|
||||
SanitizePerformTypeCheck = false;
|
||||
}
|
||||
|
||||
// Pass inline keyword to optimizer if it appears explicitly on any
|
||||
// declaration.
|
||||
if (!CGM.getCodeGenOpts().NoInline)
|
||||
@@ -558,7 +564,7 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn,
|
||||
// function call is used by the caller, the behavior is undefined.
|
||||
if (getLangOpts().CPlusPlus && !FD->hasImplicitReturnZero() &&
|
||||
!FD->getResultType()->isVoidType() && Builder.GetInsertBlock()) {
|
||||
if (getLangOpts().SanitizeReturn)
|
||||
if (SanOpts->Return)
|
||||
EmitCheck(Builder.getFalse(), "missing_return",
|
||||
EmitCheckSourceLocation(FD->getLocation()),
|
||||
ArrayRef<llvm::Value *>(), CRK_Unrecoverable);
|
||||
@@ -1143,7 +1149,7 @@ void CodeGenFunction::EmitVariablyModifiedType(QualType type) {
|
||||
// If the size is an expression that is not an integer constant
|
||||
// expression [...] each time it is evaluated it shall have a value
|
||||
// greater than zero.
|
||||
if (getLangOpts().SanitizeVLABound &&
|
||||
if (SanOpts->VLABound &&
|
||||
size->getType()->isSignedIntegerType()) {
|
||||
llvm::Value *Zero = llvm::Constant::getNullValue(Size->getType());
|
||||
llvm::Constant *StaticArgs[] = {
|
||||
|
||||
Reference in New Issue
Block a user