[PATCH] D119481: run-clang-tidy: Fix infinite loop on windowsfind_compilation_database checked only for "/" as exit point, but on windows, this root is impossible. Fixes #53642

Fabian Ke├čler via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 10 13:58:56 PST 2022

Febbe created this revision.
Herald added a subscriber: carlosgalvezp.
Febbe requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

  rG LLVM Github Monorepo



Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -64,13 +64,14 @@
 def find_compilation_database(path):
   """Adjusts the directory until a compilation database is found."""
-  result = './'
+  result = os.path.realpath('./')
   while not os.path.isfile(os.path.join(result, path)):
-    if os.path.realpath(result) == '/':
+    parent = os.path.dirname(result)    
+    if result == parent:
       print('Error: could not find compilation database.')
-    result += '../'
-  return os.path.realpath(result)
+    result = parent
+  return result
 def make_absolute(f, directory):

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119481.407675.patch
Type: text/x-patch
Size: 798 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220210/a60fa56e/attachment-0001.bin>

More information about the cfe-commits mailing list