From 8edfd52e3c7191e77fd5751c8ae10416917b6c93 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 24 Jul 2019 09:50:56 +0000 Subject: [PATCH] [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@366883 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/Format.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index f3688aa7ee..96f0211028 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -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; -- 2.40.0