D1771 was supposed to fix this but it didn't, make_absolute can't be use to check if a file is virtual. I didn't break anything either.
This patch exposes virtual entries in the FileManager to check if a filepath is a virtual file that has already been allocated.
Details
- Reviewers
klimek revane tareqsiraj
Diff Detail
Event Timeline
I don't understand that yet. Why wouldn't make_absolute just do nothing for virtual files anyway?
A better look at make_absolute showed me that it doesn't check for the filepath to exists it just gets the current path (PWD) and then uses the current path for getting the root and relative paths, and append them to the file name. So you can actually get an absolute path to a virtual file :).
I think virtual files shouldn't be made absolute unless someone explicitly create them that way.
The test I created in D1771 is irrelevant to the patch, it doesn't hurt and in fact there should be a test to exercise the use of relative paths in a compilation database but clang-check is not creating any replacement. I'm now adding another test for this patch.
include/clang/Basic/FileManager.h | ||
---|---|---|
278 ↗ | (On Diff #4641) | If we decided we need this (see further down), this'll need approval from Doug... |
lib/Tooling/Refactoring.cpp | ||
108 | I'd always use {} if there's a more complex statement inside. | |
122 | Can't we instead just check whether the relative file exists? |
Apart from my remaining nits, LG. Thanks!
lib/Tooling/Refactoring.cpp | ||
---|---|---|
120 | Did you change files to file on purpose? I think this makes the sentence incorrect ;) | |
unittests/Tooling/RefactoringTest.cpp | ||
290 | I'd EXPECT_EQ(0, chdir(...)), as the type of the chdir is not bool, and EXPECT_FALSE reads like we'd expect the command to fail. |
unittests/Tooling/RefactoringTest.cpp | ||
---|---|---|
290 | Disregard this line, it should't be here |
unittests/Tooling/RefactoringTest.cpp | ||
---|---|---|
290 | It's still in the updated patch, though :) |
I'd always use {} if there's a more complex statement inside.