[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
This commit is contained in:
Fangrui Song 2019-07-24 09:50:56 +00:00
parent 2ff40ca367
commit 5a43ba8a62
1 changed files with 7 additions and 4 deletions

View File

@ -2365,11 +2365,14 @@ tooling::Replacements sortUsingDeclarations(const FormatStyle &Style,
LangOptions getFormattingLangOpts(const FormatStyle &Style) {
LangOptions LangOpts;
FormatStyle::LanguageStandard LexingStd =
Style.Standard == FormatStyle::LS_Auto ? FormatStyle::LS_Cpp11
: Style.Standard;
LangOpts.CPlusPlus = 1;
LangOpts.CPlusPlus11 = Style.Standard >= FormatStyle::LS_Cpp11;
LangOpts.CPlusPlus14 = Style.Standard >= FormatStyle::LS_Cpp11;
LangOpts.CPlusPlus17 = Style.Standard >= FormatStyle::LS_Cpp11;
LangOpts.CPlusPlus2a = Style.Standard >= FormatStyle::LS_Cpp11;
LangOpts.CPlusPlus11 = LexingStd >= FormatStyle::LS_Cpp11;
LangOpts.CPlusPlus14 = LexingStd >= FormatStyle::LS_Cpp11;
LangOpts.CPlusPlus17 = LexingStd >= FormatStyle::LS_Cpp11;
LangOpts.CPlusPlus2a = LexingStd >= FormatStyle::LS_Cpp11;
LangOpts.LineComment = 1;
bool AlternativeOperators = Style.isCpp();
LangOpts.CXXOperatorNames = AlternativeOperators ? 1 : 0;