diff options
author | Jordan Rupprecht <rupprecht@google.com> | 2019-02-28 19:16:45 +0000 |
---|---|---|
committer | Jordan Rupprecht <rupprecht@google.com> | 2019-02-28 19:16:45 +0000 |
commit | 48d130f239a8fc9dfeda5226608f056acb7188f3 (patch) | |
tree | 513cbe2ee687358bd81315d25dbe2a745f86259d /lib/Format/Format.cpp | |
parent | 87a9db53d1be4c83e3e6b669ed663fd776ad0ece (diff) |
[clang-format][NFC] Allow getLLVMStyle() to take a language
Summary:
getLLVMStyle() sets the default style, but doesn't take the language as a parameter, so can't set default parameters when they differ from C++. This change adds LanguageKind as an input to getLLVMStyle so that we can start doing that.
See D55964 as a motivation for this, where we want Tablegen to be formatted differently than C++.
Reviewers: djasper, krasimir, MyDeveloperDay
Reviewed By: MyDeveloperDay
Subscribers: jdoerfert, MyDeveloperDay, kristina, cfe-commits, arphaman
Tags: #clang
Differential Revision: https://reviews.llvm.org/D56943
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355123 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/Format.cpp')
-rw-r--r-- | lib/Format/Format.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 9feffeb96c..d8751a36d7 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -618,9 +618,9 @@ static FormatStyle expandPresets(const FormatStyle &Style) { return Expanded; } -FormatStyle getLLVMStyle() { +FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) { FormatStyle LLVMStyle; - LLVMStyle.Language = FormatStyle::LK_Cpp; + LLVMStyle.Language = Language; LLVMStyle.AccessModifierOffset = -2; LLVMStyle.AlignEscapedNewlines = FormatStyle::ENAS_Right; LLVMStyle.AlignAfterOpenBracket = FormatStyle::BAS_Align; @@ -729,8 +729,7 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) { return GoogleStyle; } - FormatStyle GoogleStyle = getLLVMStyle(); - GoogleStyle.Language = Language; + FormatStyle GoogleStyle = getLLVMStyle(Language); GoogleStyle.AccessModifierOffset = -1; GoogleStyle.AlignEscapedNewlines = FormatStyle::ENAS_Left; @@ -2344,8 +2343,7 @@ llvm::Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName, if (!FS) { FS = llvm::vfs::getRealFileSystem().get(); } - FormatStyle Style = getLLVMStyle(); - Style.Language = guessLanguage(FileName, Code); + FormatStyle Style = getLLVMStyle(guessLanguage(FileName, Code)); FormatStyle FallbackStyle = getNoStyle(); if (!getPredefinedStyle(FallbackStyleName, Style.Language, &FallbackStyle)) |