[PATCH] Fix replacements for files with relative paths are not applied.

Manuel Klimek klimek at google.com
Sun Sep 29 09:26:53 PDT 2013



================
Comment at: lib/Tooling/Refactoring.cpp:108-112
@@ -105,3 +107,7 @@
   const FileEntry *Entry = Sources.getFileEntryForID(DecomposedLocation.first);
-  this->FilePath = Entry != NULL ? Entry->getName() : InvalidLocation;
+  // Make FilePath absolute so replacements can be applied correctly when
+  // relative paths for files are used.
+  llvm::SmallString<256> FilePath(Entry->getName());
+  llvm::sys::fs::make_absolute(FilePath);
+  this->FilePath = FilePath.c_str();
   this->ReplacementRange = Range(DecomposedLocation.second, Length);
----------------
Ariel Bernal wrote:
> Manuel Klimek wrote:
> > 1. was it intentional that you removed the Entry != NULL check?
> > 2. please add a regression test
> No it wasn't, it was a mistake, I fixed it and added a regression test. The problem is that this patch breaks many other tests  in c-index-test and also some unit tests.
Which ones and why? The easiest way to review that would be if you included the fixes for all breaking tests in the patch :D


http://llvm-reviews.chandlerc.com/D1771



More information about the cfe-commits mailing list