-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simple static checker using clang-query
- Loading branch information
1 parent
c6b6b8f
commit 3b05077
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
matcher=$(cat <<'EOF' | ||
set print-matcher true | ||
# expressions of any floating point type (unless in a system header) | ||
match expr(allOf(unless(isExpansionInSystemHeader()), hasType(realFloatingPointType()))) | ||
# calls to memcmp (secp256k1_memcmp_var should be used instead) | ||
match callExpr(callee(functionDecl(hasName("memcmp")))) | ||
quit | ||
EOF | ||
) | ||
|
||
check() { | ||
local file=$1 | ||
shift | ||
local extra= | ||
for arg in $@ | ||
do | ||
extra="$extra --extra-arg=$arg " | ||
done | ||
output=$(echo "$matcher" | clang-query --extra-arg="-DHAVE_CONFIG" --extra-arg="-DSECP256K1_BUILD" $extra "src/$file") | ||
|
||
! echo "$output" | grep -C 9999999 -E "^Match" | ||
echo | ||
} | ||
|
||
check secp256k1.c -DHAVE_CONFIG -DSECP256K1_BUILD | ||
check tests.c -DHAVE_CONFIG -DSECP256K1_BUILD -DVERIFY | ||
check tests_exhaustive.c -DHAVE_CONFIG -DSECP256K1_BUILD -DVERIFY | ||
check valgrind_ctime_test.c -DVALGRIND |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters