forked from OSchip/llvm-project
Revert "Added support for different VFSs in format::getStyle."
This reverts commit r264253. It is breaking the buildbot http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/2203 llvm-svn: 264276
This commit is contained in:
parent
295915ceb7
commit
d47583232a
|
@ -2099,10 +2099,7 @@ static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
FormatStyle getStyle(StringRef StyleName, StringRef FileName,
|
FormatStyle getStyle(StringRef StyleName, StringRef FileName,
|
||||||
StringRef FallbackStyle, vfs::FileSystem *FS) {
|
StringRef FallbackStyle) {
|
||||||
if (!FS) {
|
|
||||||
FS = vfs::getRealFileSystem().get();
|
|
||||||
}
|
|
||||||
FormatStyle Style = getLLVMStyle();
|
FormatStyle Style = getLLVMStyle();
|
||||||
Style.Language = getLanguageByFileName(FileName);
|
Style.Language = getLanguageByFileName(FileName);
|
||||||
if (!getPredefinedStyle(FallbackStyle, Style.Language, &Style)) {
|
if (!getPredefinedStyle(FallbackStyle, Style.Language, &Style)) {
|
||||||
|
@ -2133,35 +2130,28 @@ FormatStyle getStyle(StringRef StyleName, StringRef FileName,
|
||||||
llvm::sys::fs::make_absolute(Path);
|
llvm::sys::fs::make_absolute(Path);
|
||||||
for (StringRef Directory = Path; !Directory.empty();
|
for (StringRef Directory = Path; !Directory.empty();
|
||||||
Directory = llvm::sys::path::parent_path(Directory)) {
|
Directory = llvm::sys::path::parent_path(Directory)) {
|
||||||
|
if (!llvm::sys::fs::is_directory(Directory))
|
||||||
auto Status = FS->status(Directory);
|
|
||||||
if (!Status ||
|
|
||||||
Status->getType() != llvm::sys::fs::file_type::directory_file) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
SmallString<128> ConfigFile(Directory);
|
SmallString<128> ConfigFile(Directory);
|
||||||
|
|
||||||
llvm::sys::path::append(ConfigFile, ".clang-format");
|
llvm::sys::path::append(ConfigFile, ".clang-format");
|
||||||
DEBUG(llvm::dbgs() << "Trying " << ConfigFile << "...\n");
|
DEBUG(llvm::dbgs() << "Trying " << ConfigFile << "...\n");
|
||||||
|
bool IsFile = false;
|
||||||
// Ignore errors from is_regular_file: we only need to know if we can read
|
// Ignore errors from is_regular_file: we only need to know if we can read
|
||||||
// the file or not.
|
// the file or not.
|
||||||
Status = FS->status(ConfigFile.str());
|
llvm::sys::fs::is_regular_file(Twine(ConfigFile), IsFile);
|
||||||
bool IsFile =
|
|
||||||
Status && (Status->getType() == llvm::sys::fs::file_type::regular_file);
|
|
||||||
if (!IsFile) {
|
if (!IsFile) {
|
||||||
// Try _clang-format too, since dotfiles are not commonly used on Windows.
|
// Try _clang-format too, since dotfiles are not commonly used on Windows.
|
||||||
ConfigFile = Directory;
|
ConfigFile = Directory;
|
||||||
llvm::sys::path::append(ConfigFile, "_clang-format");
|
llvm::sys::path::append(ConfigFile, "_clang-format");
|
||||||
DEBUG(llvm::dbgs() << "Trying " << ConfigFile << "...\n");
|
DEBUG(llvm::dbgs() << "Trying " << ConfigFile << "...\n");
|
||||||
Status = FS->status(ConfigFile.str());
|
llvm::sys::fs::is_regular_file(Twine(ConfigFile), IsFile);
|
||||||
IsFile = Status &&
|
|
||||||
(Status->getType() == llvm::sys::fs::file_type::regular_file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsFile) {
|
if (IsFile) {
|
||||||
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Text =
|
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Text =
|
||||||
FS->getBufferForFile(ConfigFile.str());
|
llvm::MemoryBuffer::getFile(ConfigFile.c_str());
|
||||||
if (std::error_code EC = Text.getError()) {
|
if (std::error_code EC = Text.getError()) {
|
||||||
llvm::errs() << EC.message() << "\n";
|
llvm::errs() << EC.message() << "\n";
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue