diff options
author | Hans Wennborg <hans@hanshq.net> | 2013-09-10 15:41:12 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2013-09-10 15:41:12 +0000 |
commit | 9f6581bb88c5e2575c0cbd07103c76a528065192 (patch) | |
tree | c4a45148c311b9862cddb825586e0bab3b42e346 /clang/tools/clang-format/ClangFormat.cpp | |
parent | d532cb6bedb6e3e9742197c97972857640afca64 (diff) | |
download | bcm5719-llvm-9f6581bb88c5e2575c0cbd07103c76a528065192.tar.gz bcm5719-llvm-9f6581bb88c5e2575c0cbd07103c76a528065192.zip |
Allow _clang-format as alternative to .clang-format config filename
Dotfiles are impractical on Windows. This makes clang-format search
for the style configuration file as '_clang-format' in addition to
the usual '.clang-format'. This is similar to how VIM searches for
'_vimrc' on Windows.
Differential Revision: http://llvm-reviews.chandlerc.com/D1629
llvm-svn: 190413
Diffstat (limited to 'clang/tools/clang-format/ClangFormat.cpp')
-rw-r--r-- | clang/tools/clang-format/ClangFormat.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index 2d415b358fc..592d46a530c 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -132,12 +132,22 @@ FormatStyle getStyle(StringRef StyleName, StringRef FileName) { !Directory.empty(); Directory = llvm::sys::path::parent_path(Directory)) { SmallString<128> ConfigFile(Directory); + llvm::sys::path::append(ConfigFile, ".clang-format"); DEBUG(llvm::dbgs() << "Trying " << ConfigFile << "...\n"); bool IsFile = false; // Ignore errors from is_regular_file: we only need to know if we can read // the file or not. llvm::sys::fs::is_regular_file(Twine(ConfigFile), IsFile); + + if (!IsFile) { + // Try _clang-format too, since dotfiles are not commonly used on Windows. + ConfigFile = Directory; + llvm::sys::path::append(ConfigFile, "_clang-format"); + DEBUG(llvm::dbgs() << "Trying " << ConfigFile << "...\n"); + llvm::sys::fs::is_regular_file(Twine(ConfigFile), IsFile); + } + if (IsFile) { OwningPtr<MemoryBuffer> Text; if (error_code ec = MemoryBuffer::getFile(ConfigFile, Text)) { |