summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorWill Dietz <wdietz2@illinois.edu>2013-01-18 11:30:38 +0000
committerWill Dietz <wdietz2@illinois.edu>2013-01-18 11:30:38 +0000
commitf54319c891d806e410ac09caac35462cf95b8cce (patch)
tree195d8af1cea50e7be3e52d45a6c116ed7c578ef3 /clang/lib/CodeGen/CodeGenFunction.cpp
parent63c36bbe5e0ae8d64df8c2a3be6c0b072febdc9a (diff)
downloadbcm5719-llvm-f54319c891d806e410ac09caac35462cf95b8cce.tar.gz
bcm5719-llvm-f54319c891d806e410ac09caac35462cf95b8cce.zip
[ubsan] Add support for -fsanitize-blacklist
llvm-svn: 172808
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 8ba1bf4b6fd..1fdcc6f9ecd 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -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[] = {
OpenPOWER on IntegriCloud