[PATCH] D153218: [clang-tidy] Fix `llvmlibc-inline-function-decl` false positives for templated function definitions

Piotr Zegar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 18 00:54:24 PDT 2023


PiotrZSL requested changes to this revision.
PiotrZSL added a comment.
This revision now requires changes to proceed.

I got one concern, if you write this:

  template <typename... Ts>LIBC_INLINE void VariadicTemplate<Ts...>::goodVariadicTemplate() {}
  template <typename... Ts>inline void VariadicTemplate<Ts...>::badVariadicTemplate() {}

Aka, no space after `>`, warning will be emitted for both.
That's because of `TemplateParams->getRAngleLoc().getLocWithOffset(1);`
So we find `>` character, then we skip it, now we pointing into `inline` or whitespace location, and when we skip to a next token.
If you remove this `getLocWithOffset(1)` then `findNextTokenSkippingComments` should work correctly.

Additionally you missing release notes.
There is also other way to deal with this issue, simply use `FunctionDecl::getReturnTypeSourceRange()` and work with `tidy::utils::lexer::getPreviousToken`.
But in theory both solutions should work fine. Question is also how it will work with attributes, like `[[nodiscard]]` that could be put before inline.

Requesting change mainly due to false-positive with space.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153218/new/

https://reviews.llvm.org/D153218



More information about the cfe-commits mailing list