r247228 - Don't crash when emitting a block under returns_nonnull.
John McCall via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 9 17:57:47 PDT 2015
Author: rjmccall
Date: Wed Sep 9 19:57:46 2015
New Revision: 247228
URL: http://llvm.org/viewvc/llvm-project?rev=247228&view=rev
Log:
Don't crash when emitting a block under returns_nonnull.
rdar://22071955
Added:
cfe/trunk/test/CodeGen/sanitize-blocks.c
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=247228&r1=247227&r2=247228&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Sep 9 19:57:46 2015
@@ -2440,8 +2440,8 @@ void CodeGenFunction::EmitFunctionEpilog
llvm::Instruction *Ret;
if (RV) {
- if (SanOpts.has(SanitizerKind::ReturnsNonnullAttribute)) {
- if (auto RetNNAttr = CurGD.getDecl()->getAttr<ReturnsNonNullAttr>()) {
+ if (CurCodeDecl && SanOpts.has(SanitizerKind::ReturnsNonnullAttribute)) {
+ if (auto RetNNAttr = CurCodeDecl->getAttr<ReturnsNonNullAttr>()) {
SanitizerScope SanScope(this);
llvm::Value *Cond = Builder.CreateICmpNE(
RV, llvm::Constant::getNullValue(RV->getType()));
Added: cfe/trunk/test/CodeGen/sanitize-blocks.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sanitize-blocks.c?rev=247228&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/sanitize-blocks.c (added)
+++ cfe/trunk/test/CodeGen/sanitize-blocks.c Wed Sep 9 19:57:46 2015
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsanitize-trap=returns-nonnull-attribute -fsanitize=returns-nonnull-attribute -emit-llvm %s -o - -triple x86_64-apple-darwin10 -fblocks | FileCheck %s
+
+// Awkward interactions of sanitizers with blocks.
+
+// rdar://22071955
+const char *TheString = "Hello, world!";
+const char *(^getString)(void) = ^{
+ return TheString;
+};
+
+// CHECK-LABEL: define internal i8* @getString_block_invoke
+
+// TODO: Actually support returns_nonnull on blocks.
More information about the cfe-commits
mailing list