summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGBuiltin.cpp
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2017-12-21 00:10:25 +0000
committerVedant Kumar <vsk@apple.com>2017-12-21 00:10:25 +0000
commit09b5bfdd85fa23a331ee565bda289b3c27c00fdf (patch)
treea5adff5e6bd5871fe32873bd2e3da642ba0f6247 /clang/lib/CodeGen/CGBuiltin.cpp
parentfae4f7c6818343acc9ad54cacaadaf9fc6fcf52d (diff)
downloadbcm5719-llvm-09b5bfdd85fa23a331ee565bda289b3c27c00fdf.tar.gz
bcm5719-llvm-09b5bfdd85fa23a331ee565bda289b3c27c00fdf.zip
[ubsan] Diagnose noreturn functions which return
Diagnose 'unreachable' UB when a noreturn function returns. 1. Insert a check at the end of functions marked noreturn. 2. A decl may be marked noreturn in the caller TU, but not marked in the TU where it's defined. To diagnose this scenario, strip away the noreturn attribute on the callee and insert check after calls to it. Testing: check-clang, check-ubsan, check-ubsan-minimal, D40700 rdar://33660464 Differential Revision: https://reviews.llvm.org/D40698 llvm-svn: 321231
Diffstat (limited to 'clang/lib/CodeGen/CGBuiltin.cpp')
-rw-r--r--clang/lib/CodeGen/CGBuiltin.cpp9
1 files changed, 1 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 01cc0187fb5..d67f2fede38 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1432,14 +1432,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
case Builtin::BI__debugbreak:
return RValue::get(EmitTrapCall(Intrinsic::debugtrap));
case Builtin::BI__builtin_unreachable: {
- if (SanOpts.has(SanitizerKind::Unreachable)) {
- SanitizerScope SanScope(this);
- EmitCheck(std::make_pair(static_cast<llvm::Value *>(Builder.getFalse()),
- SanitizerKind::Unreachable),
- SanitizerHandler::BuiltinUnreachable,
- EmitCheckSourceLocation(E->getExprLoc()), None);
- } else
- Builder.CreateUnreachable();
+ EmitUnreachable(E->getExprLoc());
// We do need to preserve an insertion point.
EmitBlock(createBasicBlock("unreachable.cont"));
OpenPOWER on IntegriCloud