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 | 9a7a50eef777765e4d20e3b1f3670b32582114fb (patch) | |
tree | 65ffa709a3a39fce2c7bf0dfe72e59d2bd368dc6 /tools/clang-format/ClangFormat.cpp | |
parent | daa07e9ee76d438efa3c7e2c54b4d3d3ed19ea27 (diff) | |
download | clang-9a7a50eef777765e4d20e3b1f3670b32582114fb.tar.gz clang-9a7a50eef777765e4d20e3b1f3670b32582114fb.tar.bz2 clang-9a7a50eef777765e4d20e3b1f3670b32582114fb.tar.xz |
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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190413 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/clang-format/ClangFormat.cpp')
-rw-r--r-- | tools/clang-format/ClangFormat.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/clang-format/ClangFormat.cpp b/tools/clang-format/ClangFormat.cpp index 2d415b358f..592d46a530 100644 --- a/tools/clang-format/ClangFormat.cpp +++ b/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)) { |