X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;ds=sidebyside;f=lib%2FSupport%2FPathV2.cpp;h=46571c049f12d3be1e48026c85dbd872ba95e9ff;hb=b21d9aebba7e45ddcbce61dd501000049cefb335;hp=ce97b7f2ca20e773becb78ae222e10e43b8e4625;hpb=d1d721660edf3f4e76ea69fd5579f857b97a3150;p=oota-llvm.git diff --git a/lib/Support/PathV2.cpp b/lib/Support/PathV2.cpp index ce97b7f2ca2..46571c049f1 100644 --- a/lib/Support/PathV2.cpp +++ b/lib/Support/PathV2.cpp @@ -602,7 +602,7 @@ error_code make_absolute(SmallVectorImpl &path) { bool rootDirectory = path::has_root_directory(p), #ifdef LLVM_ON_WIN32 - rootName = has_root_name(p); + rootName = path::has_root_name(p); #else rootName = true; #endif @@ -654,12 +654,13 @@ error_code create_directories(const Twine &path, bool &existed) { StringRef p = path.toStringRef(path_storage); StringRef parent = path::parent_path(p); - bool parent_exists; - - if (error_code ec = fs::exists(parent, parent_exists)) return ec; + if (!parent.empty()) { + bool parent_exists; + if (error_code ec = fs::exists(parent, parent_exists)) return ec; - if (!parent_exists) - if (error_code ec = create_directories(parent, existed)) return ec; + if (!parent_exists) + if (error_code ec = create_directories(parent, existed)) return ec; + } return create_directory(p, existed); } @@ -743,6 +744,8 @@ error_code has_magic(const Twine &path, const Twine &magic, bool &result) { /// @brief Identify the magic in magic. file_magic identify_magic(StringRef magic) { + if (magic.size() < 4) + return file_magic::unknown; switch ((unsigned char)magic[0]) { case 0xDE: // 0x0B17C0DE = BC wraper if (magic[1] == (char)0xC0 && magic[2] == (char)0x17 &&