diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-08-27 18:56:18 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-08-27 18:56:18 +0000 |
| commit | 00cc1c09c3b26c50367b24e8cf365308b10ebc76 (patch) | |
| tree | dde3aa3fb9ec1c7f930955aa6cc77f442ef6744e /clang/lib | |
| parent | c26a79d4f2cd82515b7145f8730e6fdfee3ed8a4 (diff) | |
| download | bcm5719-llvm-00cc1c09c3b26c50367b24e8cf365308b10ebc76.tar.gz bcm5719-llvm-00cc1c09c3b26c50367b24e8cf365308b10ebc76.zip | |
Fix regression in r216520: don't apply nonnull to non-pointer function
parameters in the IR.
llvm-svn: 216574
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 45a62590898..c95680ccda6 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1557,8 +1557,17 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, llvm::Value *V = AI; if (const ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(Arg)) { - if ((NNAtt && NNAtt->isNonNull(PVD->getFunctionScopeIndex())) || - PVD->hasAttr<NonNullAttr>()) + // FIXME: __attribute__((nonnull)) can also be applied to: + // - references to pointers, where the pointee is known to be + // nonnull (apparently a Clang extension) + // - transparent unions containing pointers + // In the former case, LLVM IR cannot represent the constraint. In + // the latter case, we have no guarantee that the transparent union + // is in fact passed as a pointer. + if (((NNAtt && NNAtt->isNonNull(PVD->getFunctionScopeIndex())) || + PVD->hasAttr<NonNullAttr>()) && + (PVD->getType()->isAnyPointerType() || + PVD->getType()->isBlockPointerType())) AI->addAttr(llvm::AttributeSet::get(getLLVMContext(), AI->getArgNo() + 1, llvm::Attribute::NonNull)); |

