summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-06-28 03:49:04 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-06-28 03:49:04 +0000
commit157f34bd310917e74d0716865fee73a5b05b63c6 (patch)
tree03a1498e024abfcc91d1bfc8e245f4d6a8d2378e /clang/lib/Frontend
parente79a87226aa5d557ca07325db99264747e56d4fb (diff)
downloadbcm5719-llvm-157f34bd310917e74d0716865fee73a5b05b63c6.tar.gz
bcm5719-llvm-157f34bd310917e74d0716865fee73a5b05b63c6.zip
Update for llvm::sys::fs::unique_file not creating directories.
llvm-svn: 185127
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp34
1 files changed, 21 insertions, 13 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index ec1f9590606..5ffee3032df 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -539,24 +539,27 @@ CompilerInstance::createOutputFile(StringRef OutputPath,
}
if (UseTemporary) {
- SmallString<256> AbsPath(OutputPath);
- llvm::sys::fs::make_absolute(AbsPath);
-
- // If the parent directory doesn't exist and we can't create it, fail.
- bool ParentExists =
- llvm::sys::fs::exists(llvm::sys::path::parent_path(AbsPath.str()));
- if (!CreateMissingDirectories && !ParentExists) {
- Error = "Parent directory doesn't exist";
- return 0;
- }
-
// Create a temporary file.
SmallString<128> TempPath;
TempPath = OutFile;
TempPath += "-%%%%%%%%";
int fd;
- if (!llvm::sys::fs::unique_file(TempPath.str(), fd, TempPath,
- /*makeAbsolute=*/false, 0664)) {
+ llvm::error_code EC = llvm::sys::fs::unique_file(
+ TempPath.str(), fd, TempPath, /*makeAbsolute=*/ false, 0664);
+
+ if (CreateMissingDirectories &&
+ (EC == llvm::errc::no_such_file_or_directory ||
+ EC == llvm::windows_error::file_not_found ||
+ EC == llvm::windows_error::path_not_found)) {
+ StringRef Parent = llvm::sys::path::parent_path(OutputPath);
+ EC = llvm::sys::fs::create_directories(Parent);
+ if (!EC) {
+ EC = llvm::sys::fs::unique_file(TempPath.str(), fd, TempPath,
+ /*makeAbsolute=*/ false, 0664);
+ }
+ }
+
+ if (!EC) {
OS.reset(new llvm::raw_fd_ostream(fd, /*shouldClose=*/true));
OSFile = TempFile = TempPath.str();
}
@@ -780,6 +783,11 @@ static void compileModule(CompilerInstance &ImportingInstance,
SourceLocation ImportLoc,
Module *Module,
StringRef ModuleFileName) {
+ // FIXME: have LockFileManager return an error_code so that we can
+ // avoid the mkdir when the directory already exists.
+ StringRef Dir = llvm::sys::path::parent_path(ModuleFileName);
+ llvm::sys::fs::create_directories(Dir);
+
llvm::LockFileManager Locked(ModuleFileName);
switch (Locked) {
case llvm::LockFileManager::LFS_Error:
OpenPOWER on IntegriCloud