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


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):
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to