summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGCall.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/CGCall.cpp')
-rw-r--r--clang/lib/CodeGen/CGCall.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index a650493c5ba..bebefe5384a 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -4401,12 +4401,16 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
if (UnusedReturnSizePtr)
PopCleanupBlock();
- // Strip away the noreturn attribute to better diagnose unreachable UB.
+ // Replace the noreturn attribute to better diagnose unreachable UB.
if (SanOpts.has(SanitizerKind::Unreachable)) {
+ // Also remove from function since CS.hasFnAttr(..) also checks attributes
+ // of the called function.
if (auto *F = CS.getCalledFunction())
F->removeFnAttr(llvm::Attribute::NoReturn);
CS.removeAttribute(llvm::AttributeList::FunctionIndex,
llvm::Attribute::NoReturn);
+ CS.addAttribute(llvm::AttributeList::FunctionIndex,
+ llvm::Attribute::ExpectNoReturn);
}
EmitUnreachable(Loc);
OpenPOWER on IntegriCloud