@@ -62,13 +62,13 @@ static void extractDeclarations(const SwiftExtractorConfiguration& config,
6262 // TODO: find a more robust approach to avoid collisions?
6363 llvm::StringRef filename = primaryFile ? primaryFile->getFilename () : module .getModuleFilename ();
6464 std::string tempTrapName = filename.str () + ' .' + std::to_string (getpid ()) + " .trap" ;
65- llvm::SmallString<PATH_MAX> tempTrapPath (config.trapDir );
65+ llvm::SmallString<PATH_MAX> tempTrapPath (config.tempTrapDir );
6666 llvm::sys::path::append (tempTrapPath, tempTrapName);
6767
68- llvm::StringRef trapParent = llvm::sys::path::parent_path (tempTrapPath);
69- if (std::error_code ec = llvm::sys::fs::create_directories (trapParent )) {
70- std::cerr << " Cannot create trap directory '" << trapParent .str () << " ': " << ec. message ()
71- << " \n " ;
68+ llvm::StringRef tempTrapParent = llvm::sys::path::parent_path (tempTrapPath);
69+ if (std::error_code ec = llvm::sys::fs::create_directories (tempTrapParent )) {
70+ std::cerr << " Cannot create temp trap directory '" << tempTrapParent .str ()
71+ << " ': " << ec. message () << " \n " ;
7272 return ;
7373 }
7474
@@ -117,6 +117,13 @@ static void extractDeclarations(const SwiftExtractorConfiguration& config,
117117 llvm::SmallString<PATH_MAX> trapPath (config.trapDir );
118118 llvm::sys::path::append (trapPath, trapName);
119119
120+ llvm::StringRef trapParent = llvm::sys::path::parent_path (trapPath);
121+ if (std::error_code ec = llvm::sys::fs::create_directories (trapParent)) {
122+ std::cerr << " Cannot create trap directory '" << trapParent.str () << " ': " << ec.message ()
123+ << " \n " ;
124+ return ;
125+ }
126+
120127 // TODO: The last process wins. Should we do better than that?
121128 if (std::error_code ec = llvm::sys::fs::rename (tempTrapPath, trapPath)) {
122129 std::cerr << " Cannot rename temp trap file '" << tempTrapPath.str ().str () << " ' -> '"
0 commit comments