aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInstance.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index b187bdc..995c94b 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -781,12 +781,7 @@ void CompilerInstance::clearOutputFiles(bool EraseFiles) {
continue;
}
- // If '-working-directory' was passed, the output filename should be
- // relative to that.
- SmallString<128> NewOutFile(OF.Filename);
- FileMgr->FixupRelativePath(NewOutFile);
-
- llvm::Error E = OF.File->keep(NewOutFile);
+ llvm::Error E = OF.File->keep(OF.Filename);
if (!E)
continue;
@@ -849,6 +844,15 @@ CompilerInstance::createOutputFileImpl(StringRef OutputPath, bool Binary,
assert((!CreateMissingDirectories || UseTemporary) &&
"CreateMissingDirectories is only allowed when using temporary files");
+ // If '-working-directory' was passed, the output filename should be
+ // relative to that.
+ Optional<SmallString<128>> AbsPath;
+ if (OutputPath != "-" && !llvm::sys::path::is_absolute(OutputPath)) {
+ AbsPath.emplace(OutputPath);
+ FileMgr->FixupRelativePath(*AbsPath);
+ OutputPath = *AbsPath;
+ }
+
std::unique_ptr<llvm::raw_fd_ostream> OS;
Optional<StringRef> OSFile;