Commit d82adf32 authored by mydeveloperday's avatar mydeveloperday Committed by paulhoad
Browse files

Allow space after C-style cast in C# code

Reviewed By: MyDeveloperDay, krasimir

Patch By: jbcoe

Differential Revision: https://reviews.llvm.org/D72150
parent 4612e48d
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1640,8 +1640,9 @@ private:

  /// Determine whether ')' is ending a cast.
  bool rParenEndsCast(const FormatToken &Tok) {
    // C-style casts are only used in C++ and Java.
    if (!Style.isCpp() && Style.Language != FormatStyle::LK_Java)
    // C-style casts are only used in C++, C# and Java.
    if (!Style.isCSharp() && !Style.isCpp() &&
        Style.Language != FormatStyle::LK_Java)
      return false;

    // Empty parens aren't casts and there are no casts at the end of the line.
+9 −0
Original line number Diff line number Diff line
@@ -374,5 +374,14 @@ TEST_F(FormatTestCSharp, CSharpSpaceBefore) {
               Style);
}

TEST_F(FormatTestCSharp, CSharpSpaceAfterCStyleCast) {
  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);

  verifyFormat("(int)x / y;", Style);

  Style.SpaceAfterCStyleCast = true;
  verifyFormat("(int) x / y;", Style);
}

} // namespace format
} // end namespace clang