Skip to content

Commit 5a43ba8

Browse files
committed
[Format] getFormattingLangOpts: make LS_Auto uses LS_Cpp11 lexing rule
Suggested by sammccall in post-commit review of D65183 Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D65194 llvm-svn: 366883
1 parent 2ff40ca commit 5a43ba8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

clang/lib/Format/Format.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2365,11 +2365,14 @@ tooling::Replacements sortUsingDeclarations(const FormatStyle &Style,
23652365

23662366
LangOptions getFormattingLangOpts(const FormatStyle &Style) {
23672367
LangOptions LangOpts;
2368+
FormatStyle::LanguageStandard LexingStd =
2369+
Style.Standard == FormatStyle::LS_Auto ? FormatStyle::LS_Cpp11
2370+
: Style.Standard;
23682371
LangOpts.CPlusPlus = 1;
2369-
LangOpts.CPlusPlus11 = Style.Standard >= FormatStyle::LS_Cpp11;
2370-
LangOpts.CPlusPlus14 = Style.Standard >= FormatStyle::LS_Cpp11;
2371-
LangOpts.CPlusPlus17 = Style.Standard >= FormatStyle::LS_Cpp11;
2372-
LangOpts.CPlusPlus2a = Style.Standard >= FormatStyle::LS_Cpp11;
2372+
LangOpts.CPlusPlus11 = LexingStd >= FormatStyle::LS_Cpp11;
2373+
LangOpts.CPlusPlus14 = LexingStd >= FormatStyle::LS_Cpp11;
2374+
LangOpts.CPlusPlus17 = LexingStd >= FormatStyle::LS_Cpp11;
2375+
LangOpts.CPlusPlus2a = LexingStd >= FormatStyle::LS_Cpp11;
23732376
LangOpts.LineComment = 1;
23742377
bool AlternativeOperators = Style.isCpp();
23752378
LangOpts.CXXOperatorNames = AlternativeOperators ? 1 : 0;

0 commit comments

Comments
 (0)