This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Fix identifier naming for initializer list member initializers.
ClosedPublic

Authored by EricWF on Nov 16 2016, 5:52 AM.

Details

Summary

This patch adds handling for member initializers in a constructors initializer list. Previously we only handled base-class and delegating initializers, which are transformed by the TypeLoc matcher. For Example:

// Style options: All identifiers should start with an upper case letter.
struct base { ...  }; 
struct der :  base {
  int field;  // FIXES: int Field;
  der() : der(42) {} // FIXES: Der() : Der(42) {}
  der(int X) : base(), field(X) {} // FIXES: Der(int X) : Base(), field(X)
  // Note that `field` doesn't get replaced
};

Diff Detail

Event Timeline

EricWF updated this revision to Diff 78175.Nov 16 2016, 5:52 AM
EricWF retitled this revision from to [clang-tidy] Fix identifier naming for initializer list member initializers..
EricWF updated this object.
EricWF added reviewers: alexfh, hokein, aaron.ballman.
EricWF added a subscriber: cfe-commits.
aaron.ballman added inline comments.Nov 16 2016, 1:13 PM
clang-tidy/readability/IdentifierNamingCheck.cpp
681

Please use const auto * instead of just auto.

test/clang-tidy/readability-identifier-naming.cpp
155

Why set the access specifier here (and below)?

224

Wait, our fix is to turn the name into a reserved identifier? That seems less-than-ideal (not that you are changing this behavior, mostly just that this will generate a new diagnostic on the fixed code).

EricWF marked an inline comment as done.Nov 16 2016, 1:19 PM
EricWF added inline comments.
test/clang-tidy/readability-identifier-naming.cpp
155

The tests below need to call these constructors to test base class initializers.

224

It's just for the test, See the RUN lines:

// RUN:     {key: readability-identifier-naming.PrivateMemberPrefix, value: '__'},
EricWF updated this revision to Diff 78252.Nov 16 2016, 1:21 PM

Fix auto usage.

aaron.ballman accepted this revision.Nov 16 2016, 1:23 PM
aaron.ballman edited edge metadata.

LGTM!

test/clang-tidy/readability-identifier-naming.cpp
155

Ah, that makes sense, thank you.

224

Oh! Phew! Now I am much less worried. :-D

This revision is now accepted and ready to land.Nov 16 2016, 1:23 PM
EricWF closed this revision.Nov 16 2016, 1:25 PM