aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.
LGTM, thank you!
================
Comment at: clang-tools-extra/clang-tidy/add_new_check.py:335-336
+ module_file = get_module_filename(module_path, module_name)
+ if not os.path.isfile(module_file):
+ return ''
+ with io.open(module_file, 'r') as f:
----------------
LegalizeAdulthood wrote:
> LegalizeAdulthood wrote:
> > aaron.ballman wrote:
> > > Do we have to check this or can we rely on open failing because it's not
> > > a file? (It tripped my psychic TOCTOU sensor.)
> > If we don't check here, then it throws an exception when attempting to open
> > the file.
> Also, I was following the existing pattern in this file `:)`
Sounds like a good reason to leave it in then, thanks!
================
Comment at: clang-tools-extra/clang-tidy/add_new_check.py:352
+ stmt = code[stmt_start_pos+1:stmt_end_pos]
+ matches = re.search('registerCheck<([^>:]*)>\(\s*"([^"]*)"\s*\)', stmt)
+ if matches and matches[2] == full_check_name:
----------------
LegalizeAdulthood wrote:
> LegalizeAdulthood wrote:
> > aaron.ballman wrote:
> > > It's a bit early for me to fully grok regex, but: is this going to handle
> > > line continuations/newlines okay? I don't know if those show up in cases
> > > that matter right now, but I wanted to make sure it was being thought
> > > about.
> > `\s` matches any single whitespace character and `\s*` matches zero or more
> > whitespace characters. I could sprinkle some more in between tokens, but
> > this catches the existing code correctly.
> There is some code like this:
> `CheckFactories.registerCheck<bugprone::UnhandledSelfAssignmentCheck>("cert-oop54-cpp");`
> and I intentionally omit searching for this (`[^:>]*`) because these are
> aliases for other checks.
>
> Which makes me wonder if we want to explicitly register aliases differently
> from regular checks? If you want to run a list of checks and exclude aliases
> (so the check doesn't run twice), how do you do that?
> Which makes me wonder if we want to explicitly register aliases differently
> from regular checks? If you want to run a list of checks and exclude aliases
> (so the check doesn't run twice), how do you do that?
You can't, which was the subject of https://reviews.llvm.org/D114317 but it's
complicated in practice.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126134/new/
https://reviews.llvm.org/D126134
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits