From 34c037641b74dda8d7c10d35ffa476162c0125a6 Mon Sep 17 00:00:00 2001 From: Antonio Maiorano Date: Thu, 22 Dec 2016 05:10:07 +0000 Subject: Make FormatStyle.GetStyleOfFile test work on MSVC Modify getStyle to use vfs::FileSystem::makeAbsolute just like FS.addFile does, rather than sys::fs::make_absolute. The latter gets the CWD from the platform, while the former expects it to be set by the client, causing a mismatch when converting relative paths to absolute. Differential Revision: https://reviews.llvm.org/D27971 llvm-svn: 290319 --- clang/lib/Format/Format.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'clang/lib/Format/Format.cpp') diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index ffe41c224ae..61c904cc7fe 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -1917,7 +1917,11 @@ FormatStyle getStyle(StringRef StyleName, StringRef FileName, // Look for .clang-format/_clang-format file in the file's parent directories. SmallString<128> UnsuitableConfigFiles; SmallString<128> Path(FileName); - llvm::sys::fs::make_absolute(Path); + if (std::error_code EC = FS->makeAbsolute(Path)) { + llvm::errs() << EC.message() << "\n"; + return Style; + } + for (StringRef Directory = Path; !Directory.empty(); Directory = llvm::sys::path::parent_path(Directory)) { -- cgit v1.2.3