aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.h
diff options
context:
space:
mode:
authorAlexey Samsonov <vonosmas@gmail.com>2014-09-08 17:22:45 +0000
committerAlexey Samsonov <vonosmas@gmail.com>2014-09-08 17:22:45 +0000
commit8e1162c71d40ada37c358d17182c68d8d9fad41d (patch)
tree6f0f54eaa85f0668b41b63a9e6a1340822c5003d /clang/lib/CodeGen/CodeGenFunction.h
parentea65e37beea96207b6fa64959112dc7ba6e44b3c (diff)
downloadllvm-8e1162c71d40ada37c358d17182c68d8d9fad41d.zip
llvm-8e1162c71d40ada37c358d17182c68d8d9fad41d.tar.gz
llvm-8e1162c71d40ada37c358d17182c68d8d9fad41d.tar.bz2
Implement nonnull-attribute sanitizer
Summary: This patch implements a new UBSan check, which verifies that function arguments declared to be nonnull with __attribute__((nonnull)) are actually nonnull in runtime. To implement this check, we pass FunctionDecl to CodeGenFunction::EmitCallArgs (where applicable) and if function declaration has nonnull attribute specified for a certain formal parameter, we compare the corresponding RValue to null as soon as it's calculated. Test Plan: regression test suite Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits, rnk Differential Revision: http://reviews.llvm.org/D5082 llvm-svn: 217389
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 4841b53..ff74ce9 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -2625,6 +2625,7 @@ public:
void EmitCallArgs(CallArgList &Args, const T *CallArgTypeInfo,
CallExpr::const_arg_iterator ArgBeg,
CallExpr::const_arg_iterator ArgEnd,
+ const FunctionDecl *CalleeDecl = nullptr,
unsigned ParamsToSkip = 0, bool ForceColumnInfo = false) {
SmallVector<QualType, 16> ArgTypes;
CallExpr::const_arg_iterator Arg = ArgBeg;
@@ -2673,13 +2674,15 @@ public:
for (; Arg != ArgEnd; ++Arg)
ArgTypes.push_back(Arg->getType());
- EmitCallArgs(Args, ArgTypes, ArgBeg, ArgEnd, ForceColumnInfo);
+ EmitCallArgs(Args, ArgTypes, ArgBeg, ArgEnd, CalleeDecl, ParamsToSkip,
+ ForceColumnInfo);
}
void EmitCallArgs(CallArgList &Args, ArrayRef<QualType> ArgTypes,
CallExpr::const_arg_iterator ArgBeg,
CallExpr::const_arg_iterator ArgEnd,
- bool ForceColumnInfo = false);
+ const FunctionDecl *CalleeDecl = nullptr,
+ unsigned ParamsToSkip = 0, bool ForceColumnInfo = false);
private:
const TargetCodeGenInfo &getTargetHooks() const {