]> granicus.if.org Git - clang/commitdiff
[Format] getFormattingLangOpts: make LS_Auto uses LS_Cpp11 lexing rule
authorFangrui Song <maskray@google.com>
Wed, 24 Jul 2019 09:50:56 +0000 (09:50 +0000)
committerFangrui Song <maskray@google.com>
Wed, 24 Jul 2019 09:50:56 +0000 (09:50 +0000)
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

index f3688aa7ee475a953e5179f4a8767f92ded08601..96f021102809018613642d06fb6e5f4c173588db 100644 (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;