[clang-apply-replacements] Correctly handle relative paths
authorAdrian Vogelsgesang <avogelsgesang@tableau.com>
Thu, 11 Nov 2021 18:19:54 +0000 (18:19 +0000)
committerYitzhak Mandelbaum <yitzhakm@google.com>
Thu, 11 Nov 2021 18:28:43 +0000 (18:28 +0000)
commit8188484daa4195a2c8b5253765036fa2c6da7263
tree8cb139252415a7991f13d04733b08d3c7eaea853
parentbc84b2857f5bd1550f0be4b0961d6a3ebecfa15d
[clang-apply-replacements] Correctly handle relative paths

The fixes from the YAML file can refer to relative paths.
Those relative paths are meant to be resolved relative to the
corresponding `build directory`.
However, `clang-apply-replacements` currently interprets all
paths relative to its own working directory. This causes issues,
e.g., when `clang-apply-replacements` is run from outside of
the original build directory.

This commit adjusts `clang-apply-replacements` to take the build
directory into account when resolving relative file paths.

Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D112647
clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/basic.h [new file with mode: 0644]
clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/file1.yaml [new file with mode: 0644]
clang-tools-extra/test/clang-apply-replacements/Inputs/relative-paths/file2.yaml [new file with mode: 0644]
clang-tools-extra/test/clang-apply-replacements/relative-paths.cpp [new file with mode: 0644]