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

    <tr>
        <th>Summary</th>
        <td>
            Warnings in templates are duplicated per instance
        </td>
    </tr>

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

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

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

<pre>
    Some warnings are emitted for each time a template is instantiated. This can cause hundreds of lines to be emitted for a single issue.

This notably affects `-Wreturn-type` and `-Wreturn-stack-address`, although there are probably others.

The easiest way to see this is with an infinite template, which spews over 18,000 lines of warnings before erroring on the template depth (Godbolt chops it down to 7000):
```cpp
// classic infinite template
template <typename T>
int f(T x)
{
    f(&x);
    // whoops, forgot to return a value
}
int x = f(0);
```
https://godbolt.org/z/vjKecMjcK

```
<source>:7:1: warning: non-void function does not return a value [-Wreturn-type]
}
^
<source>:8:9: note: in instantiation of function template specialization 'f<int>' requested here
int x = f(0);
        ^
<source>:7:1: warning: non-void function does not return a value [-Wreturn-type]
}
^
<source>:5:5: note: in instantiation of function template specialization 'f<int *>' requested here
    f(&x);
    ^
<source>:8:9: note: in instantiation of function template specialization 'f<int>' requested here
int x = f(0);
        ^
<source>:7:1: warning: non-void function does not return a value [-Wreturn-type]
}
^
<source>:5:5: note: in instantiation of function template specialization 'f<int **>' requested here
    f(&x);
    ^
<source>:5:5: note: in instantiation of function template specialization 'f<int *>' requested here
<source>:8:9: note: in instantiation of function template specialization 'f<int>' requested here
int x = f(0);
        ^
<source>:7:1: warning: non-void function does not return a value [-Wreturn-type]
}
^
<source>:5:5: note: in instantiation of function template specialization 'f<int ***>' requested here
    f(&x);
    ^
<source>:5:5: note: in instantiation of function template specialization 'f<int **>' requested here
<source>:5:5: note: in instantiation of function template specialization 'f<int *>' requested here
<source>:8:9: note: in instantiation of function template specialization 'f<int>' requested here
int x = f(0);
        ^
<source>:7:1: warning: non-void function does not return a value [-Wreturn-type]
}
^
<source>:5:5: note: in instantiation of function template specialization 'f<int ****>' requested here
    f(&x);
    ^
<source>:5:5: note: in instantiation of function template specialization 'f<int ***>' requested here
<source>:5:5: note: in instantiation of function template specialization 'f<int **>' requested here
<source>:5:5: note: in instantiation of function template specialization 'f<int *>' requested here
<source>:8:9: note: in instantiation of function template specialization 'f<int>' requested here
int x = f(0);
        ^
<source>:7:1: warning: non-void function does not return a value [-Wreturn-type]
}
^
<source>:5:5: note: in instantiation of function template specialization 'f<int *****>' requested here
    f(&x);
    ^
<source>:5:5: note: in instantiation of function template specialization 'f<int ****>' requested here
<source>:5:5: note: in instantiation of function template specialization 'f<int ***>' requested here
<source>:5:5: note: in instantiation of function template specialization 'f<int **>' requested here
<source>:5:5: note: in instantiation of function template specialization 'f<int *>' requested here
<source>:8:9: note: in instantiation of function template specialization 'f<int>' requested here
int x = f(0);
        ^

...thousands more lines spewed to the console
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWF1v0zAU_TXpi9UoS5pmfcjDYMAD4olJPDv2bePh2sF2Wsqv5zhpu60aIARim2hVp_5I7zn3-DhSbmPlrv5o18S23BllVp5xR4zWKgSSbGkdIy5aFhRu4SzQutM8EFOeKeMDN0FhKFN202JKcIPWe2Jtb6Qj6ZldMq0MeRYsax4G5swDUMdgvqc0ya6T7Gq8DtGMDbzRO8aXSxLBs2SeTT85Cr0z07DrCGPGjXwwD0ri85RLgHuPhSR_zbgOre1XSKIl5Bbz65xthtg2zvkTbNDkXpEPEGUXiXsi_Dnm7NlWhRawSH-pjIIUB00i1LZVEMt3tEXmG3Ls4hLTWZbtRYAaR50bggiAcs46TDBrIsE7iSV1QEryy3dWNlYHJlrbgUJg0m5NpFUhcJIvkmLPPOY7fEXX7Wfyt_gyobn3SjzCebjrCJkUr6OwhmOzb5LizbisTGBL8LhhXyPaGLh6NXYYPnExyefDanFvfo--bS2IR3mQ8MqGS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