[PATCH] D65183: [Format] Make it easy to add new format::FormatStyle::LanguageStandard. NFCI
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 24 01:29:21 PDT 2019
sammccall added inline comments.
================
Comment at: lib/Format/Format.cpp:2369
LangOpts.CPlusPlus = 1;
- LangOpts.CPlusPlus11 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;
- LangOpts.CPlusPlus14 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;
- LangOpts.CPlusPlus17 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;
- LangOpts.CPlusPlus2a = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;
+ LangOpts.CPlusPlus11 = Style.Standard >= FormatStyle::LS_Cpp11;
+ LangOpts.CPlusPlus14 = Style.Standard >= FormatStyle::LS_Cpp11;
----------------
Looking at this more, this is pretty subtle: `Style` *can* be `LS_Auto` here. So we're relying on the fact that Auto is the max value in the enum.
It's probably worth making this more explicit, e.g.
```
LanguageStandard LexingStd = Style.Standard == LS_Auto ? LS_Cpp20 : Style.Standard;
LangOpts.CPlusPlus11 = LexingStd >= FormatStyle::LS_Cpp11;
etc
```
(a comment would also be fine, but I think the code is at least as clear here)
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65183/new/
https://reviews.llvm.org/D65183
More information about the cfe-commits
mailing list