This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Change the namespace for llvm checkers from 'llvm' to 'llvm_check'
ClosedPublic

Authored by hintonda on Apr 12 2019, 12:39 PM.

Details

Summary

Change the namespace for llvm checkers from 'llvm' to
'llvm_check', and modify add_new_check.py and rename_check.py to
support the new namespace. Checker, file, and directory names remain
unchanged.

Used new version of rename_check.py to make the change in existing
llvm checkers, but had to fix LLVMTidyModule.cpp and
LLVMModuleTest.cpp by hand.

The changes to rename_check.py are idempotent, so if accidentally
run multiple times, it won't do anything.

Event Timeline

hintonda created this revision.Apr 12 2019, 12:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2019, 12:40 PM
Herald added a subscriber: xazax.hun. · View Herald Transcript
hintonda updated this revision to Diff 194940.Apr 12 2019, 12:48 PM
  • Remove leftover comments, etc.
hintonda updated this revision to Diff 194941.Apr 12 2019, 12:52 PM
  • Add missing 'clang'.
Harbormaster completed remote builds in B30463: Diff 194941.

Please use check for consistency with rest of Clang-tidy.

Eugene.Zelenko added a project: Restricted Project.

Please use check for consistency with rest of Clang-tidy.

Thanks for taking a look — I’ll Fix that on the next upload. So are you okay with llvm_check? I sorta like it, but happy to use anything other than llvm, which caused the initial problem.

No opposition from me regarding llvm_check, though I think llvm_tidy might also be a reasonable option. I'm a bit less keen on llvm_checker as the name, but not strongly opposed.

clang-tools-extra/clang-tidy/add_new_check.py
383

I thought we were going with llvm_check?

hintonda marked an inline comment as done.Apr 15 2019, 2:04 PM
hintonda added inline comments.
clang-tools-extra/clang-tidy/add_new_check.py
383

Just typo on my part. I the options mentioned before where things like llvm_project or llvm_proj, etc. I just settled on llvm_check because it sounded better -- then actually typed checker.

I'll fix it this afternoon.

hintonda retitled this revision from [clang-tidy] Change the namespace for llvm checkers from 'llvm' to 'llvm_checker' to [clang-tidy] Change the namespace for llvm checkers from 'llvm' to 'llvm_check'.Apr 15 2019, 2:04 PM
hintonda edited the summary of this revision. (Show Details)
hintonda updated this revision to Diff 195278.Apr 15 2019, 5:25 PM
  • Change llvm_checker to llvm_check.
alexfh added inline comments.Apr 16 2019, 1:34 PM
clang-tools-extra/clang-tidy/add_new_check.py
382

We don't have the clang module. No need to check for it here. If we ever add one (which I doubt), we can modify this script again. But for now let's remove this to avoid confusion.

clang-tools-extra/clang-tidy/rename_check.py
272

--?

Anyways, we don't have (or plan to have) a module named clang.

hintonda marked 2 inline comments as done.Apr 17 2019, 8:31 AM
hintonda added inline comments.
clang-tools-extra/clang-tidy/add_new_check.py
382

No problem. Or we could outlaw it...

clang-tools-extra/clang-tidy/rename_check.py
272

Thanks for catching that...

hintonda updated this revision to Diff 195581.Apr 17 2019, 8:54 AM
  • Remove clang module check.
alexfh added inline comments.Apr 17 2019, 12:41 PM
clang-tools-extra/clang-tidy/add_new_check.py
381

I'd add an explanation: # Map module names to namespace names that don't conflict with widely used top-level namespaces.

And again, no need to mention clang here.

383

I have another suggestion re: the color of this bike shed, namely: llvm_checks. But I don't feel strongly about this.

clang-tools-extra/clang-tidy/rename_check.py
218

s/_Check/_CHECK/, maybe?

271

I believe, we should first construct the new namespace name (using exactly the same code as in add_new_check.py) and then check if it differs from the old one.

hintonda marked an inline comment as done.Apr 21 2019, 9:51 AM
hintonda added inline comments.
clang-tools-extra/clang-tidy/rename_check.py
218

Not sure it matters, but args.old_check_name is all lower case, so we have to uppercase the entire string.

hintonda updated this revision to Diff 196011.Apr 21 2019, 12:07 PM
  • Address comments.
alexfh added inline comments.Apr 23 2019, 4:03 PM
clang-tools-extra/clang-tidy/rename_check.py
275

Why new_namespace == 'llvm_check' is needed? Can we figure out old_namespace and use the condition new_namespace != old_namespace instead?

hintonda updated this revision to Diff 196521.Apr 24 2019, 2:20 PM
  • Remove unnecessary comparison.
hintonda updated this revision to Diff 196531.Apr 24 2019, 3:05 PM
  • Change check back to previous version which is much clearer.
  • Apply namespace change to new check.
hintonda marked an inline comment as done.Apr 24 2019, 3:08 PM
hintonda added inline comments.
clang-tools-extra/clang-tidy/rename_check.py
271

Changed this back to the original check which was clearer and easier for the reader to grok.

We are checking two distinct things here, so be explicit. First, we check to see if the modules changed, e.g., from say from 'google' to 'modernize', then we check to see if the new module is 'llvm' and needs special handling.

Then, and only then, do we need to set the new_namespace variable, and we condition that on whether or not the new module name is 'llvm'.

Ping. Is this the direction you'd like to go? Or would you prefer something else? thanks... don

aaron.ballman accepted this revision.May 8 2019, 5:48 AM

This LGTM, but you may want to wait a day or so to see if @alexfh has any remaining concerns.

This revision is now accepted and ready to land.May 8 2019, 5:48 AM

This LGTM, but you may want to wait a day or so to see if @alexfh has any remaining concerns.

Will do, thanks Aaron...

This revision was automatically updated to reflect the committed changes.