[clang-tools-extra] 3f0f203 - run-clang-tidy: Fix infinite loop on windows

Jonas Toth via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 24 08:17:46 PDT 2022


Author: Jonas Toth
Date: 2022-04-24T17:17:02+02:00
New Revision: 3f0f20366622ee5fd35a1d65d7db5226f5e5751f

URL: https://github.com/llvm/llvm-project/commit/3f0f20366622ee5fd35a1d65d7db5226f5e5751f
DIFF: https://github.com/llvm/llvm-project/commit/3f0f20366622ee5fd35a1d65d7db5226f5e5751f.diff

LOG: run-clang-tidy: Fix infinite loop on windows

`find_compilation_database` checked only for "/" as exit point, but on Windows, this root is impossible.
Fixes #53642

Authored By: Febbe
Reviewed By: JonasToth
Differential Revision: https://reviews.llvm.org/D119481

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
index afe2bfd28554d..9497e0b9f52d3 100755
--- a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -73,13 +73,14 @@ def strtobool(val):
 
 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.')
       sys.exit(1)
-    result += '../'
-  return os.path.realpath(result)
+    result = parent
+  return result
 
 
 def make_absolute(f, directory):


        


More information about the cfe-commits mailing list