[PATCH] D39603: [clang-tidy] Support relative paths in run-clang-tidy.py

Gábor Horváth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 3 10:05:06 PDT 2017


xazax.hun created this revision.
Herald added subscribers: baloghadamsoftware, whisperity.

Currently relative paths wasn't supperted by run-clang-tidy.py

I added the support, however I did not find any existing tests. Is it ok for this to land without a test or should I introduce one?


https://reviews.llvm.org/D39603

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
@@ -67,6 +67,11 @@
     result += '../'
   return os.path.realpath(result)
 
+def make_absolute(f, directory):
+  if os.path.isabs(f):
+    return f
+  return os.path.normpath(os.path.join(directory, f))
+
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
                         header_filter, extra_arg, extra_arg_before, quiet):
@@ -223,7 +228,8 @@
 
   # Load the database and extract all files.
   database = json.load(open(os.path.join(build_path, db_path)))
-  files = [entry['file'] for entry in database]
+  files = [make_absolute(entry['file'], entry['directory'])
+          for entry in database]
 
   max_task = args.j
   if max_task == 0:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39603.121498.patch
Type: text/x-patch
Size: 866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171103/9fd8b207/attachment.bin>


More information about the cfe-commits mailing list