forked from OSchip/llvm-project
Add nonnull in CodeGen for __attribute__((returns_nonnull))
As a follow-up to r212835, also add the LLVM nonnull function attribute when __attribute__((returns_nonnull)) is provided. llvm-svn: 212874
This commit is contained in:
parent
289ca249f0
commit
d8442b1b21
clang
|
@ -1107,6 +1107,8 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
|
|||
}
|
||||
if (TargetDecl->hasAttr<MallocAttr>())
|
||||
RetAttrs.addAttribute(llvm::Attribute::NoAlias);
|
||||
if (TargetDecl->hasAttr<ReturnsNonNullAttr>())
|
||||
RetAttrs.addAttribute(llvm::Attribute::NonNull);
|
||||
}
|
||||
|
||||
if (CodeGenOpts.OptimizeSize)
|
||||
|
|
|
@ -15,3 +15,9 @@ void bar2(int * x, int * y) __attribute__((nonnull(2))) {
|
|||
*x = 0;
|
||||
}
|
||||
|
||||
static int a;
|
||||
// CHECK: define nonnull i32* @bar3()
|
||||
int * bar3() __attribute__((returns_nonnull)) {
|
||||
return &a;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue