Skip to content

[clang-tidy] matchers::matchesAnyListedName() confusingly uses regular expression searches in bugprone-use-after-move #174229

@higher-performance

Description

@higher-performance

::free should not match the name of ::freedom::Id* S::blah(); (!)

https://godbolt.org/z/vEcY74h8M

namespace freedom {
class Id;
struct S { Id* blah(); };
}
void foo(freedom::S* s) {
  s->blah();
  s->blah();
}
$ clang-tidy --checks='bugprone-use-after-move' --config="{CheckOptions: {bugprone-use-after-move.InvalidationFunctions: '::free'}}"

<source>:7:3: warning: 's' used after it was invalidated [bugprone-use-after-move]
    7 |   s->blah();
      |   ^
<source>:6:6: note: invalidation occurred here
    6 |   s->blah();
      |      ^

Despite its name, apparently matchesAnyListedName treats its arguments as regexes rather than names, causing this issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions