This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Fix RenamerClangTidy handling qualified TypeLocs
ClosedPublic

Authored by njames93 on Mar 21 2020, 12:10 PM.

Details

Summary

Previously if a type was accessed with a qualifier, RenamerClangTidy wouldn't rename the TypeLoc, this patch addresses this shortfall by trying to find the Unqualified TypeLoc first. Also fixed a broken test case that was dependent on this broken behaviour.

Example:

struct a{};

void foo(const a&);
void foo(a&);
void foo(a);
void foo(a&&);
void foo(const a);

exec -checks=readability-identifier-naming --config="{CheckOptions: [{key: readability-identifier-naming.StructCase, value: CamelCase}]}" -fix
Current Behaviour:

struct A{};

void foo(const a&);
void foo(A&);
void foo(A);
void foo(A&&);
void foo(const a);

Proposed new behaviour:

struct A{};

void foo(const A&);
void foo(A&);
void foo(A);
void foo(A&&);
void foo(const A);

Diff Detail

Event Timeline

njames93 created this revision.Mar 21 2020, 12:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 21 2020, 12:10 PM
njames93 edited the summary of this revision. (Show Details)Mar 21 2020, 12:19 PM

I'd appreciate seeing your test cases from the summary added to a test somewhere.

clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
206

Don't use auto as the type is not spelling out in the initialization.

njames93 updated this revision to Diff 251910.Mar 22 2020, 12:09 PM
  • Address auto and add test cases.
njames93 marked an inline comment as done.Mar 22 2020, 12:10 PM
This revision is now accepted and ready to land.Mar 23 2020, 5:25 AM
This revision was automatically updated to reflect the committed changes.