<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/56554>56554</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            -ftime-trace incorrect header hierarchy when a header contains a template function for his last symbol
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          galop1n
      </td>
    </tr>
</table>

<pre>
    
Using the repro case below, you will observe in the traces that `2.h` shows up as an inclusion under `1.h` instead of being an inclusion of `main/cpp`. The addition of a dummy forward declaration at the end of `1.h` is a workaround to the problem and will yield the correct result with `2.h` being under `main.cpp`. In both case, `3.h` remains under `2.h` accordingly.

* main.cpp
```c++
#include "1.h"
#include "2.h"
int foo();
```
* 1.h
```
#pragma once
#include <vector>
struct LARGE {};
template <typename T> auto Zero() -> T { return T{}; }
#if defined GUARD
struct guard;
#endif
```
* 2.h
```
#pragma once
#include "3.h"
#include <map>
struct Bla {};
```
* 3.h
```
#pragma once
#include <algorithm>
struct Foo {};
```

To produce the incorrect time trace : `clang -ftime-trace main.cpp -c -o main-wrong.o`
To produce the correct time trace : `clang -DGUARD -ftime-trace main.cpp -c -o main-right.o`



</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJydVEtv2zAM_jXOhYjhyE3cHHxIm3YYsNPQXXaTJdrWJkuGJDfIvx8l59FmHQoMEGRLfHwfKZKNlcc6K_ZZsfvhlekg9AgOR2dBcI_QoLaHjD3C0U5wUFqDbTy6VwRlkm5wXKCnXx4g2xQs72kH39uDh2kE7oEb0hV68soamIxEFxVXs6IyPiCXYFuCivjvtOmWlAauTMaexTjSIYcXQuVSqnDS4CCnYThCa92BOwkSheaOJzGRiiTRyJOvMyzRgoN1v7mzRAmCTXoUdqNxIBJyDvaoUMskEtY5FIFy4ycdSBr6N_HO3C_BRcb5me9XA40l7ZjPmEm6LGcrh1HRX-1O3rggNEke9TGf3-a0sx1cXM83m2JeImMPcZ30ypRDiZAxFkNm7CMJeyNRJlAGbcbuM7bNyocb_1cC0d3HsnJ0vBs4WCPwb7jy8ZXyZ11WPs1CH9xECf22-_7lCbLqIav2F9yAw6h5SGbhOKLhA8ILmQKf6K1-ojsxhWW8fIn2lM4wOUNqZ18QPxciLVVGqwxK-PJj933_jkQ3UeVco2YlVYxq_5kD9p85YKz8x2OUjwMfb1PzoPltYj4gU_73g3DdWUeFPNwCP1v7GXDaX2xsGTkJTD1Crk9dEtRwGg2Es4ulTT1JHbJso2Q5S86lDEsBS5uOy4OzpsvtBecG4VP_-_S2n-M41fXhDc7bfSHrUm7LLV8EFTTW75xdY-xpblHb9godd6I_wqFHmjjne2FNSN3N4VLN7WREmks0q8jQg-Y-gD8OjdWLyem6D2H0FBGNO1odvc3U5MIOdND69fxZUkp-EQU6Ku8n9PSz3qzXd4u-3pSbzUZs7zk2xWaLQmJTVfdNtW0qcdditdCcZrqvszXNC2bwAMlFLMr1fqFqVjBWVKv1arsqiyrHu2bbkruKNawqVkV2V8ShpfPII7euW7g6UWqmzpNQKx_8Vci9V51BTHDkn7q3t67uuLbjyiwSdJ2o_wEUqfhw">