From: Eric Liu Date: Wed, 16 May 2018 20:10:10 +0000 (+0000) Subject: [clang-move] Fix a potential bug where realpath doesn't work on VFS. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ad3fed62a9f59f92705d7dc5cd077fd3d72bd87c;p=platform%2Fupstream%2Fllvm.git [clang-move] Fix a potential bug where realpath doesn't work on VFS. llvm-svn: 332518 --- diff --git a/clang-tools-extra/clang-move/ClangMove.cpp b/clang-tools-extra/clang-move/ClangMove.cpp index 16b0f72..7626d1c 100644 --- a/clang-tools-extra/clang-move/ClangMove.cpp +++ b/clang-tools-extra/clang-move/ClangMove.cpp @@ -95,12 +95,16 @@ std::string MakeAbsolutePath(const SourceManager &SM, StringRef Path) { llvm::sys::path::parent_path(AbsolutePath.str())); if (Dir) { StringRef DirName = SM.getFileManager().getCanonicalName(Dir); - SmallVector AbsoluteFilename; - llvm::sys::path::append(AbsoluteFilename, DirName, - llvm::sys::path::filename(AbsolutePath.str())); - return llvm::StringRef(AbsoluteFilename.data(), AbsoluteFilename.size()) - .str(); + // FIXME: getCanonicalName might fail to get real path on VFS. + if (llvm::sys::path::is_absolute(DirName)) { + SmallVector AbsoluteFilename; + llvm::sys::path::append(AbsoluteFilename, DirName, + llvm::sys::path::filename(AbsolutePath.str())); + return llvm::StringRef(AbsoluteFilename.data(), AbsoluteFilename.size()) + .str(); + } } + llvm::sys::path::remove_dots(AbsolutePath, /*remove_dot_dot=*/true); return AbsolutePath.str(); }