[PATCH] D126134: [clang-tidy] Improve add_new_check.py to recognize more checks

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 23 06:52:18 PDT 2022


aaron.ballman added a comment.

Thanks for this! It generally LGTM (though my Python skills are not particularly awesome, so take it with a grain of salt). Just a few questions at this point.



================
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:
----------------
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.)


================
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:
----------------
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.


================
Comment at: clang-tools-extra/clang-tidy/add_new_check.py:371
+
+    # The constructor might be inline in the header
+    if not matches:
----------------



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126134/new/

https://reviews.llvm.org/D126134



More information about the cfe-commits mailing list