diff options
author | Antonio Maiorano <amaiorano@gmail.com> | 2016-12-22 05:10:07 +0000 |
---|---|---|
committer | Antonio Maiorano <amaiorano@gmail.com> | 2016-12-22 05:10:07 +0000 |
commit | 34c037641b74dda8d7c10d35ffa476162c0125a6 (patch) | |
tree | 4184426364087f8b6e63e47d48f76e7cb709bdf5 /clang/lib/Format/Format.cpp | |
parent | 7323b4b78898c2b7fbd8424d218e3a755946aae2 (diff) | |
download | bcm5719-llvm-34c037641b74dda8d7c10d35ffa476162c0125a6.tar.gz bcm5719-llvm-34c037641b74dda8d7c10d35ffa476162c0125a6.zip |
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
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r-- | clang/lib/Format/Format.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
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)) { |