diff --git a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py --- a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py +++ b/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.') sys.exit(1) - result += '../' - return os.path.realpath(result) + result = parent + return result def make_absolute(f, directory):