[clang] [Clang][Comments] Add argument parsing for @throw @throws @exception (PR #84726)

via cfe-commits cfe-commits at lists.llvm.org
Mon May 6 07:08:37 PDT 2024


cor3ntin wrote:

Before I do an in-depth review i think supporting arguments to `@throw` etc makes a lot of sense.
However, I don't think we want to have a `type-id` parser in the  comment parser. The grammar is complicated, and the approach seems brittle and hard to maintain.

Given use cases, I think it's sufficient to consider anything before a space as part of a type.
You can try to support things like `foo<const bar>` just by balancing `<>`,  but I really don't think we want to parse arbitrary types (including function types, arrays, lambdas, etc) as types that you can throw.

If people want to throw "unsigned int" exceptions, well... it won't work. I think it's a reasonable tradeoff.
99% of exceptions are going to be class types.

In the long term, if we really want to support arbitrary constructs there, I think it would take a more robust approach such as the one that was [proposed here (and subsequently abandoned) ](https://discourse.llvm.org/t/rfc-a-c-pseudo-parser-for-tooling/59217 
)

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


More information about the cfe-commits mailing list