r217400 - Report source location of returns_nonnull attribute in UBSan reports.
Alexey Samsonov
vonosmas at gmail.com
Mon Sep 8 13:17:19 PDT 2014
Author: samsonov
Date: Mon Sep 8 15:17:19 2014
New Revision: 217400
URL: http://llvm.org/viewvc/llvm-project?rev=217400&view=rev
Log:
Report source location of returns_nonnull attribute in UBSan reports.
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=217400&r1=217399&r2=217400&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Sep 8 15:17:19 2014
@@ -2095,15 +2095,17 @@ void CodeGenFunction::EmitFunctionEpilog
llvm::Instruction *Ret;
if (RV) {
- if (SanOpts->ReturnsNonnullAttribute &&
- CurGD.getDecl()->hasAttr<ReturnsNonNullAttr>()) {
- SanitizerScope SanScope(this);
- llvm::Value *Cond =
- Builder.CreateICmpNE(RV, llvm::Constant::getNullValue(RV->getType()));
- llvm::Constant *StaticData[] = {
- EmitCheckSourceLocation(EndLoc)
- };
- EmitCheck(Cond, "nonnull_return", StaticData, None, CRK_Recoverable);
+ if (SanOpts->ReturnsNonnullAttribute) {
+ if (auto RetNNAttr = CurGD.getDecl()->getAttr<ReturnsNonNullAttr>()) {
+ SanitizerScope SanScope(this);
+ llvm::Value *Cond = Builder.CreateICmpNE(
+ RV, llvm::Constant::getNullValue(RV->getType()));
+ llvm::Constant *StaticData[] = {
+ EmitCheckSourceLocation(EndLoc),
+ EmitCheckSourceLocation(RetNNAttr->getLocation()),
+ };
+ EmitCheck(Cond, "nonnull_return", StaticData, None, CRK_Recoverable);
+ }
}
Ret = Builder.CreateRet(RV);
} else {
More information about the cfe-commits
mailing list