[PATCH] D65194: [Format] Make getFormattingLangOpts clear LS_Auto uses LS_Cpp11 lexing rule

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 24 02:14:21 PDT 2019


MaskRay added a comment.

`getFormattingLangOpts` is called with unadjusted FormatStyle (`deriveLocalStyle` doesn't modify `Style`). For example, GoogleStyle uses `FormatStyle::LS_Auto`. We're relying on `FormatStyle::LS_Auto` being larger than `FormatStyle::LS_Cpp11`, which is brittle.

Below is a case `getFormattingLangOpts` is called with `LS_Auto`:

  TEST_F(CleanUpReplacementsTest, InsertMultipleIncludesGoogleStyle) {
  ...
    Style = format::getGoogleStyle(format::FormatStyle::LanguageKind::LK_Cpp);
    EXPECT_EQ(Expected, apply(Code, Replaces));


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65194/new/

https://reviews.llvm.org/D65194





More information about the cfe-commits mailing list