This patch fixes replacements that are not applied when relative paths are
specified. In particular it makes sure that relative paths for non-virtual files aren't made absolute. Added unittest. llvm-svn: 192992
This commit is contained in:
@@ -107,10 +107,16 @@ void Replacement::setFromSourceLocation(SourceManager &Sources,
|
||||
const FileEntry *Entry = Sources.getFileEntryForID(DecomposedLocation.first);
|
||||
if (Entry != NULL) {
|
||||
// Make FilePath absolute so replacements can be applied correctly when
|
||||
// relative paths for files are used.
|
||||
llvm::SmallString<256> FilePath(Entry->getName());
|
||||
llvm::error_code EC = llvm::sys::fs::make_absolute(FilePath);
|
||||
this->FilePath = EC ? FilePath.c_str() : Entry->getName();
|
||||
// relative paths for files are used. But we don't want to change virtual
|
||||
// files.
|
||||
if (llvm::sys::fs::exists(Entry->getName())) {
|
||||
llvm::SmallString<256> FilePath(Entry->getName());
|
||||
llvm::sys::fs::make_absolute(FilePath);
|
||||
this->FilePath = FilePath.c_str();
|
||||
}
|
||||
else {
|
||||
this->FilePath = Entry->getName();
|
||||
}
|
||||
} else {
|
||||
this->FilePath = InvalidLocation;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user