| 62 | } |
| 63 | |
| 64 | std::error_code create_directories(const llvm::Twine& path) |
| 65 | { |
| 66 | using namespace llvm; |
| 67 | using namespace llvm::sys; |
| 68 | SmallString<128> path_storage; |
| 69 | StringRef p = path.toStringRef(path_storage); |
| 70 | StringRef parent = path::parent_path(p); |
| 71 | if (!parent.empty()) { |
| 72 | bool parent_exists; |
| 73 | #if CLANG_VERSION_MAJOR==3 && CLANG_VERSION_MINOR<=5 |
| 74 | if (auto ec = fs::exists(parent, parent_exists)) { |
| 75 | #if CLANG_VERSION_MAJOR==3 && CLANG_VERSION_MINOR<=4 |
| 76 | return std::error_code(ec.value(), std::system_category()); |
| 77 | #else |
| 78 | return ec; |
| 79 | #endif |
| 80 | } |
| 81 | #else |
| 82 | parent_exists = fs::exists(parent); |
| 83 | #endif |
| 84 | |
| 85 | if (!parent_exists) |
| 86 | if (auto ec = create_directories(parent)) return ec; |
| 87 | } |
| 88 | |
| 89 | return create_directory(p); |
| 90 | } |
| 91 | |
| 92 | |
| 93 | /** |
no test coverage detected