Skip to content

Commit

Permalink
run-clang-tidy: Fix infinite loop on windows
Browse files Browse the repository at this point in the history
`find_compilation_database` checked only for "/" as exit point, but on Windows, this root is impossible.
Fixes llvm#53642

Authored By: Febbe
Reviewed By: JonasToth
Differential Revision: https://reviews.llvm.org/D119481
  • Loading branch information
JonasToth committed Apr 24, 2022
1 parent 49aeeaf commit 3f0f203
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 3f0f203

Please sign in to comment.