Issue |
140845
|
Summary |
[clang-sa] Macro definitions of header TUs not included in the plist file
|
Labels |
new issue
|
Assignees |
|
Reporter |
ankurkraj
|
When analyzing a particular file ( using CTU ) . For a macro that is part of the bug-path - the definition of the macro is not included in the plist reports , if the macro is not called in the parent file but in any other intermediate file
Steps to reproduce the behaviour:
Following is a relatively simpler representation of the workflow
```
file1.c -> calls demo_function(10,0) defined in file2.c
file2.c -> uses macro DIVISION(a,b) in demo_function(int a, int b), macro DIVISION is defined in file3.h
file3.h -> defines DIVISION(a,b) as ((a)/(b))
```
I have followed the steps for [PCH analysis](https://clang.llvm.org/docs/analyzer/user-docs/CrossTranslationUnit.html#id7) The command I used was
```
clang --analyze -Xclang -analyzer-config -Xclang experimental-enable-naive-ctu-analysis=true -Xclang -analyzer-config -Xclang ctu-dir=. -Xclang -analyzer-config -Xclang ctu-phase1-inlining=all -Xclang -analyzer-config -Xclang expand-macros=true -Xclang -analyzer-output=pl
ist-multi-file -I. file1.c file2.c file3.c
```
The result displayed on the screen includes the macro definition but the plist files do not contain these value
```
In file included from file1.c:1:
file2.c:15:50: warning: Division by zero [core.DivideZero]
printf("Division of %d / %d is: %d\n", a, b, DIVISION(a,b));
^~~~~~~~~~~~~
file3.h:10:29: note: expanded from macro 'DIVISION'
#define DIVISION(a, b) ((a) / (b))
~~~~^~~~~
1 warning generated.
```
The expected behavious is to have the macro included in the plist file,
This is present , but only in the cases when the entry function of the bug contains the MACRO,
for eg. If in the above case, file2.c directly calls the demo_function(10,0) function in its main, the macro definition is found in that case
Is this an expected behaviour or a bug ? Are there any configurations I can tweak to bring the desirable results ?
What are the heuristics behind such decisions
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs