<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/140845>140845</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-sa] Macro definitions of header TUs not included in the plist file
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ankurkraj
</td>
</tr>
</table>
<pre>
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
</pre>
<img width="1" height="1" alt="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