[PATCH] D32294: [clang-tidy] run-clang-tidy.py: check if clang-apply-replacements succeeds

Jakub Kuderski via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 20 07:17:20 PDT 2017


kuhar created this revision.
kuhar added a project: clang-tools-extra.

When running run-clang-tidy.py with -fix it tries to apply found replacements at the end.
If there are errors running clang-apply-replacements, the script currently crashes or displays no error at all.

This patch checks for errors running clang-apply-replacements the same way clang-tidy binary is handled.

Another option would be probably checking for clang-apply-replacements (when -fix is passed) even before running clang-tidy.


https://reviews.llvm.org/D32294

Files:
  clang-tidy/tool/run-clang-tidy.py


Index: clang-tidy/tool/run-clang-tidy.py
===================================================================
--- clang-tidy/tool/run-clang-tidy.py
+++ clang-tidy/tool/run-clang-tidy.py
@@ -89,12 +89,16 @@
 
 def apply_fixes(args, tmpdir):
   """Calls clang-apply-fixes on a given directory. Deletes the dir when done."""
-  invocation = [args.clang_apply_replacements_binary]
-  if args.format:
-    invocation.append('-format')
-  invocation.append(tmpdir)
-  subprocess.call(invocation)
-  shutil.rmtree(tmpdir)
+  try:
+    invocation = [args.clang_apply_replacements_binary]
+    if args.format:
+      invocation.append('-format')
+    invocation.append(tmpdir)
+    subprocess.call(invocation)
+    shutil.rmtree(tmpdir)
+  except:
+    print >>sys.stderr, "Unable to run clang-apply-replacements."
+    sys.exit(1)
 
 
 def run_tidy(args, tmpdir, build_path, queue):


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32294.95952.patch
Type: text/x-patch
Size: 874 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170420/a50f7626/attachment-0001.bin>


More information about the cfe-commits mailing list