[all-commits] [llvm/llvm-project] 07157d: [clang][tidy] Ensure rewriter has the correct CWD ...
Jan Svoboda via All-commits
all-commits at lists.llvm.org
Tue Dec 5 15:36:09 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 07157db81d4421ced9fcf9a2002255c2a3a80d49
https://github.com/llvm/llvm-project/commit/07157db81d4421ced9fcf9a2002255c2a3a80d49
Author: Jan Svoboda <jan_svoboda at apple.com>
Date: 2023-12-05 (Tue, 05 Dec 2023)
Changed paths:
M clang-tools-extra/clang-tidy/ClangTidy.cpp
M clang-tools-extra/test/clang-tidy/infrastructure/Inputs/compilation-database/template.json
M clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-run-with-database.cpp
M clang/lib/Rewrite/Rewriter.cpp
Log Message:
-----------
[clang][tidy] Ensure rewriter has the correct CWD (#67839)
This patch replaces use of the deprecated `FileEntry::getName()` with
`FileEntryRef::getName()`. This means the code now uses the path that
was used to register file entry in `SourceManager` instead of the
absolute path that happened to be used in the last call to
`FileManager::getFile()` some place else.
This caused some test failures due to the fact that some paths can be
relative and thus rely on the VFS CWD. The CWD can change for each TU,
so when we run `clang-tidy` on a compilation database and try to perform
all the replacements at the end, relative paths won't resolve the same.
This patch takes care to reinstate the correct CWD and make the path
reported by `FileEntryRef` absolute before passing it to
`llvm::writeToOutput()`.
More information about the All-commits
mailing list