max-winkler wrote:
**Some remarks:**
- The attribute range `A->getRange()` in e.g.
`__attribute__((deprecated("msg")))` gives only the token range for
`deprecated("msg")`. As different syntaxes for the delimiters are possible
there seems to be no other option than searching token by token for the correct
delimiter pattern.
- The helper function `skipTokenPair` was a private non-static method of the
tweak class. I moved this function to the anonymous namespace as I need to call
it from some other helper function.
- The token patterns for right delimiters could fail in cases like
`__attribute__((deprecated("msg")))` as the closing paren of the argument could
be part of the delimiter. This is where `skipTokenPair` helps.
- In attribute lists (`[[deprecated, nodiscard]]`) the token range will be
deleted twice. Deletions are handled by `tooling::Replacements::add` which
accepts identical duplicates.
- I also changed a unit test for "ctor with attribute" matching the new
behavior of the tweak.
- Attributes in `__declspec` syntax are only recognized with `-fdeclspec`
option. Because of this, this case is tested in a separate test.
**Limitation:**
- `FunctionDecl::attrs()` returns only valid attributes known to clang. Only
these attributes are contained in the AST. Unknown attributes are not capture
here and will be copied into the out of line function definition.
- The same holds for attributes defined as macro.
CC: @ckandeler @kadircet as authors of this tweak
https://github.com/llvm/llvm-project/pull/242635
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits