Author: ioeric Date: Wed May 16 13:10:10 2018 New Revision: 332518 URL: http://llvm.org/viewvc/llvm-project?rev=332518&view=rev Log: [clang-move] Fix a potential bug where realpath doesn't work on VFS.
Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=332518&r1=332517&r2=332518&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original) +++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Wed May 16 13:10:10 2018 @@ -95,12 +95,16 @@ std::string MakeAbsolutePath(const Sourc llvm::sys::path::parent_path(AbsolutePath.str())); if (Dir) { StringRef DirName = SM.getFileManager().getCanonicalName(Dir); - SmallVector<char, 128> 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<char, 128> 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(); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits