Steffen Prohaska pointed out on cfe-dev that a condition is exactly
backwards in an error_code check in Replaceent::setFromSourceLocation.

The obvious fix of reversing the condition causes about 30 tests to
fail, so it looks to me like we actually rely on the path *not* being
made absolute. Furthermore, this has been broken like this for at least
a year, and before that it didn't try making the path absolute.

The attached patch simplifies the code such that it doesn't bother
calling make_absolute. This preserves the current behaviour, passes all
tests, and avoids the case where make_absolute fails and we use the
result anyway.

diff --git a/lib/Tooling/Refactoring.cpp b/lib/Tooling/Refactoring.cpp
index b2a02cb..a1fba00 100644
--- a/lib/Tooling/Refactoring.cpp
+++ b/lib/Tooling/Refactoring.cpp
@@ -106,15 +106,7 @@ void Replacement::setFromSourceLocation(const SourceManager &Sources,
   const std::pair<FileID, unsigned> DecomposedLocation =
       Sources.getDecomposedLoc(Start);
   const FileEntry *Entry = Sources.getFileEntryForID(DecomposedLocation.first);
-  if (Entry) {
-    // Make FilePath absolute so replacements can be applied correctly when
-    // relative paths for files are used.
-    llvm::SmallString<256> FilePath(Entry->getName());
-    std::error_code EC = llvm::sys::fs::make_absolute(FilePath);
-    this->FilePath = EC ? FilePath.c_str() : Entry->getName();
-  } else {
-    this->FilePath = InvalidLocation;
-  }
+  this->FilePath = Entry ? Entry->getName() : InvalidLocation;
   this->ReplacementRange = Range(DecomposedLocation.second, Length);
   this->ReplacementText = ReplacementText;
 }
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to