[PATCH] D10356: scan-build: Add --triple option to scan-build
Honggyu Kim
hong.gyu.kim at lge.com
Thu Jul 30 08:30:10 PDT 2015
honggyu.kim added a comment.
I also tested this patch with the following example.
$ cat -n test.c
1 int main()
2 {
3 int a;
4 #if __arm__
5 int b = a;
6 #endif
7 return a;
8 }
As you can see above, the example contains arm specific code region with arm macro in #if statement.
If I run it with scan-build the result doesn't contain the bug for variable b since it is within arm specific code region.
$ scan-build clang test.c
scan-build: Using '/home/hong.gyu.kim/work.hard/clang/install/bin/clang' for static analysis
test.c:7:3: warning: Undefined or garbage value returned to caller
return a;
^~~~~~~~
1 warning generated.
scan-build: 1 bug found.
scan-build: Run 'scan-view /tmp/scan-build-2015-07-31-002115-17505-1' to examine bug reports.
But when I run it with --triple option with arm target triple, it correctly shows the bug from variable b.
$ scan-build --triple=arm-linux-gnueabi clang test.c
scan-build: Using '/home/hong.gyu.kim/work.hard/clang/install/bin/clang' for static analysis
test.c:5:3: warning: Assigned value is garbage or undefined
int b = a;
^~~~~ ~
test.c:5:7: warning: Value stored to 'b' during its initialization is never read
int b = a;
^ ~
2 warnings generated.
scan-build: 2 bugs found.
scan-build: Run 'scan-view /tmp/scan-build-2015-07-31-002128-17518-1' to examine bug reports.
http://reviews.llvm.org/D10356
More information about the cfe-commits
mailing list