This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Fix hungarian notation failed to indicate the number of asterisks in check-clang-extra-clang-tidy-checkers-readability
ClosedPublic

Authored by dougpuob on Apr 7 2023, 3:31 AM.

Details

Summary

Fix hungarian notation failed to indicate the number of asterisks for the pointers of multiple word types.

  • WRONG: unsigned char* value : value --> ucValue
  • RIGHT: unsigned cahr* value : value --> pucValue
  • RIGHT: unsigned char** value : value --> ppucValue

Diff Detail

Event Timeline

dougpuob created this revision.Apr 7 2023, 3:31 AM
Herald added a project: Restricted Project. · View Herald Transcript
dougpuob requested review of this revision.Apr 7 2023, 3:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 7 2023, 3:31 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
dougpuob edited the summary of this revision. (Show Details)Apr 7 2023, 3:39 AM
PiotrZSL added inline comments.Apr 7 2023, 4:41 AM
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
376–377

this function is already big, extract this to have something like:

if (removeReudnantAsterisks(Type, ND))
{
    RedundantRemoved = true;
    break;
}
695–701

what if type will be like std::optional<unsigned char**>, will this function also be executed ?

Missing release notes.

dougpuob marked 2 inline comments as done.Apr 9 2023, 2:20 AM

Missing release notes.

Thank you for reminding me.

clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
376–377

Good idea, thank you.

695–701

Yes, this function is also executed in this case, but the std::optional<unsigned char**> is not in the supported list so the case will be ignored. Even though it is still weird, I will add some code to remove template parameters in the getDeclTypeName() function, making it clean.

  • OLD: std::optional<unsigned char**> --> std::optional<unsigned char (weird result)
  • NEW: std::optional<unsigned char**> --> std::optional (removed template parameters)

Thank you for reminding me.

dougpuob updated this revision to Diff 511969.Apr 9 2023, 2:26 AM
dougpuob marked 2 inline comments as done.
  • Extract method
  • Remove template parameters in the getDeclTypeName() function
PiotrZSL added inline comments.Apr 9 2023, 3:28 AM
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
706

const std::string&

clang-tools-extra/docs/ReleaseNotes.rst
324–326

this list should by sorted by a full check name, also there are already fixes for readability-identifier-naming, check if you could merge this to them.

PiotrZSL accepted this revision.Apr 9 2023, 3:28 AM

LGTM, except pointed out issues with order of fixes in release note and missing const.

This revision is now accepted and ready to land.Apr 9 2023, 3:28 AM
dougpuob updated this revision to Diff 512021.Apr 9 2023, 9:31 AM
  • Improved suggestions in code review
dougpuob marked 2 inline comments as done.Apr 9 2023, 9:57 AM
PiotrZSL accepted this revision.Apr 9 2023, 12:01 PM
amurzeau accepted this revision.Apr 10 2023, 1:10 PM

Thanks ! LGTM, nothing to add.

Hi @PiotrZSL
I do not have permission to land the change. Can you please help me to land this change?

Another related question is that can I know how you land diffs? Take this diff as an example. Is it correct with arc land --onto main --revision D147779?

arc land should work, I usually use arc patch --nobranch to check things before committing and then git push.

arc land should work, I usually use arc patch --nobranch to check things before committing and then git push.

Hi @PiotrZSL, thank you for the help :)