diff options
| author | Daniel Jasper <djasper@google.com> | 2015-09-29 07:53:08 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2015-09-29 07:53:08 +0000 |
| commit | 85c472dccdf536fb1853139f456a0763311a8a42 (patch) | |
| tree | eb2b58077b2ac928af88a1e962f22eb8838f8dae /clang/tools/clang-format | |
| parent | 98b3ee50ffd76e4df6e9e83c7466a4410d81ea6d (diff) | |
| download | bcm5719-llvm-85c472dccdf536fb1853139f456a0763311a8a42.tar.gz bcm5719-llvm-85c472dccdf536fb1853139f456a0763311a8a42.zip | |
clang-format: Extend #include sorting functionality
Recognize the main module header as well as different #include categories.
This should now mimic the behavior of llvm/utils/sort_includes.py as
well as clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp very
closely.
llvm-svn: 248782
Diffstat (limited to 'clang/tools/clang-format')
| -rw-r--r-- | clang/tools/clang-format/ClangFormat.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index ce9324e3049..3d6fef0d099 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -73,7 +73,7 @@ FallbackStyle("fallback-style", cl::init("LLVM"), cl::cat(ClangFormatCategory)); static cl::opt<std::string> -AssumeFilename("assume-filename", +AssumeFileName("assume-filename", cl::desc("When reading from stdin, clang-format assumes this\n" "filename to look for a style config file (with\n" "-style=file) and to determine the language."), @@ -239,13 +239,13 @@ static bool format(StringRef FileName) { std::vector<tooling::Range> Ranges; if (fillRanges(Code.get(), Ranges)) return true; - FormatStyle FormatStyle = getStyle( - Style, (FileName == "-") ? AssumeFilename : FileName, FallbackStyle); + StringRef AssumedFileName = (FileName == "-") ? AssumeFileName : FileName; + FormatStyle FormatStyle = getStyle(Style, AssumedFileName, FallbackStyle); Replacements Replaces; std::string ChangedCode; if (SortIncludes) { Replaces = - sortIncludes(FormatStyle, Code->getBuffer(), Ranges, FileName); + sortIncludes(FormatStyle, Code->getBuffer(), Ranges, AssumedFileName); ChangedCode = tooling::applyAllReplacements(Code->getBuffer(), Replaces); for (const auto &R : Replaces) Ranges.push_back({R.getOffset(), R.getLength()}); @@ -324,7 +324,7 @@ int main(int argc, const char **argv) { if (DumpConfig) { std::string Config = clang::format::configurationAsText(clang::format::getStyle( - Style, FileNames.empty() ? AssumeFilename : FileNames[0], + Style, FileNames.empty() ? AssumeFileName : FileNames[0], FallbackStyle)); llvm::outs() << Config << "\n"; return 0; |

