diff options
Diffstat (limited to 'clang/lib/Format')
-rw-r--r-- | clang/lib/Format/Format.cpp | 23 | ||||
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 11 |
2 files changed, 4 insertions, 30 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index ff326dc78478..10fe35c79a4f 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -504,22 +504,6 @@ struct ScalarEnumerationTraits<FormatStyle::QualifierAlignmentStyle> { } }; -template <> -struct MappingTraits< - FormatStyle::SpaceBeforeParensCustom::AfterPlacementOperatorStyle> { - static void - mapping(IO &IO, - FormatStyle::SpaceBeforeParensCustom::AfterPlacementOperatorStyle - &Value) { - IO.enumCase(Value, "Always", - FormatStyle::SpaceBeforeParensCustom::APO_Always); - IO.enumCase(Value, "Never", - FormatStyle::SpaceBeforeParensCustom::APO_Never); - IO.enumCase(Value, "Leave", - FormatStyle::SpaceBeforeParensCustom::APO_Leave); - } -}; - template <> struct MappingTraits<FormatStyle::RawStringFormat> { static void mapping(IO &IO, FormatStyle::RawStringFormat &Format) { IO.mapOptional("Language", Format.Language); @@ -1388,12 +1372,9 @@ static void expandPresetsSpaceBeforeParens(FormatStyle &Expanded) { return; // Reset all flags Expanded.SpaceBeforeParensOptions = {}; + Expanded.SpaceBeforeParensOptions.AfterPlacementOperator = true; switch (Expanded.SpaceBeforeParens) { - case FormatStyle::SBPO_Never: - Expanded.SpaceBeforeParensOptions.AfterPlacementOperator = - FormatStyle::SpaceBeforeParensCustom::APO_Never; - break; case FormatStyle::SBPO_ControlStatements: Expanded.SpaceBeforeParensOptions.AfterControlStatements = true; Expanded.SpaceBeforeParensOptions.AfterForeachMacros = true; @@ -1405,8 +1386,6 @@ static void expandPresetsSpaceBeforeParens(FormatStyle &Expanded) { case FormatStyle::SBPO_NonEmptyParentheses: Expanded.SpaceBeforeParensOptions.BeforeNonEmptyParentheses = true; break; - case FormatStyle::SBPO_Always: - break; default: break; } diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 25fcceb87864..d0c4273cfc7e 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -2488,6 +2488,8 @@ private: (Tok.Next->Next->is(tok::numeric_constant) || Line.InPPDirective)) { return false; } + if (Line.InPPDirective && Tok.Next->is(tok::minus)) + return false; // Search for unexpected tokens. for (FormatToken *Prev = Tok.Previous; Prev != Tok.MatchingParen; Prev = Prev->Previous) { @@ -4272,14 +4274,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, Left.isOneOf(tok::kw_new, tok::kw_delete) && Right.isNot(TT_OverloadedOperatorLParen) && !(Line.MightBeFunctionDecl && Left.is(TT_FunctionDeclarationName))) { - if (Style.SpaceBeforeParensOptions.AfterPlacementOperator == - FormatStyle::SpaceBeforeParensCustom::APO_Always || - (Style.SpaceBeforeParensOptions.AfterPlacementOperator == - FormatStyle::SpaceBeforeParensCustom::APO_Leave && - Right.hasWhitespaceBefore())) { - return true; - } - return false; + return Style.SpaceBeforeParensOptions.AfterPlacementOperator; } if (Line.Type == LT_ObjCDecl) return true; |