[clang] [Clang][Sema] Don't say "is declared here" for invalid template locations (PR #71264)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 29 09:17:30 PST 2023


AaronBallman wrote:

> ping. @AaronBallman Does this look like a reasonable thing to do to you?

Sorry for the delay on the review!

I agree that "is declared here" is useless when "here" is... nowhere. But the point to the note is to help the user to see what the actual declaration is to help them repair the issue. Losing the note entirely isn't the worst thing, but I wonder if it would be better for declarations coming from external AST sources to pretty print the declaration instead? e.g.,
Before:
```
hlsl::vector<1> BadVec; // expected-error{{template argument for template type parameter must be a type}}
// expected-note@*:* {{template is declared here}}
// expected-note@*:* {{template parameter is declared here}}
```
After:
```
hlsl::vector<1> BadVec; // expected-error{{template argument for template type parameter must be a type}}
// expected-note at -1 {{template declaration from hidden source: template <typename Ty> vector}}
// expected-note at -2 {{template parameter from hidden source: typename Ty}}
```
This would give the user more relevant information than just dropping the notes. (I have no idea if I'm asking for something incredibly difficult but I was thinking we could use the declaration printer to print this information out to the diagnostic in these cases.)

https://github.com/llvm/llvm-project/pull/71264


More information about the cfe-commits mailing list