Repository navigation
Add a dynamic check for pointer arithmetic of null pointers - #663
Conversation
|
This is a cleaned-up version of #647 with all git merge conflicts resolved. |
|
This patch uncovered a bug in checkedc-parson: https://github.com/microsoft/checkedc-parson/pull/18 |
dtarditi
left a comment
There was a problem hiding this comment.
This change looks good. There appears to be a typo where a function is called twice.
Could you add dynamic tests for the Checked C repo that check the null pointer arithmetic properly fails? These tests should be placed in a new subdirectory of tests/dynamic_checking.
| ++NumDynamicChecksNonNull; | ||
|
|
||
| Value *ConditionVal = Builder.CreateIsNotNull(Val, "_Dynamic_check.non_null"); | ||
| EmitDynamicCheckBlocks(ConditionVal); EmitDynamicCheckBlocks(ConditionVal); |
There was a problem hiding this comment.
It looks like EmitDynamicCheckBlocks is being called twice here.
|
|
||
| // RUN: %clang_cc1 -fcheckedc-extension -verify -verify-ignore-unexpected=note %s -ast-dump | FileCheck %s --check-prefix=CHECK-AST | ||
| // RUN: %clang_cc1 -fcheckedc-extension -verify -verify-ignore-unexpected=note %s -emit-llvm -O0 -o - | FileCheck %s --check-prefix=CHECK-IR | ||
| // RUN: %clang_cc1 -fcheckedc-extension -fno-checkedc-null-ptr-arith -verify -verify-ignore-unexpected=note %s -emit-llvm -O0 -o - | FileCheck %s --check-prefix=CHECK-IR |
There was a problem hiding this comment.
By default, null ptr arithmetic checks are enabled. This breaks a few test cases which perform ptr arithmetic but which do not expect the checks. So I had to add the flag -fno-checkedc-null-ptr-arith to keep these tests from breaking.
|
The runtime tests for null ptr arithmetic have been added in checkedc/checkedc#378 |
dtarditi
left a comment
There was a problem hiding this comment.
Looks great, thank you!
Please open a GitHub issue for improving the tests. You and I discuss this in-person. We should update the codegen tests where we are currently disabling null-pointer arithmetic checks. In addition, the tests should cover local variables and parameters.
Done #669. |
Cherry-picked from commit b242b14 * Add a dynamic check for pointer arithmetic of null pointers
…crosoft-20210803 Merge from Microsoft 2021-08-03
No description provided.