aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Format/WhitespaceManager.cpp4
-rw-r--r--clang/unittests/Format/FormatTest.cpp18
2 files changed, 21 insertions, 1 deletions
diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp
index a31874a..fd4a40a 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -469,7 +469,9 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
// except if the token is equal, then a space is needed.
if ((Style.PointerAlignment == FormatStyle::PAS_Right ||
Style.ReferenceAlignment == FormatStyle::RAS_Right) &&
- CurrentChange.Spaces != 0 && CurrentChange.Tok->isNot(tok::equal)) {
+ CurrentChange.Spaces != 0 &&
+ !CurrentChange.Tok->isOneOf(tok::equal, tok::r_paren,
+ TT_TemplateCloser)) {
const bool ReferenceNotRightAligned =
Style.ReferenceAlignment != FormatStyle::RAS_Right &&
Style.ReferenceAlignment != FormatStyle::RAS_Pointer;
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index a383a62..7a0c7e2 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -19314,6 +19314,24 @@ TEST_F(FormatTest, AlignConsecutiveAssignments) {
"X = func<Type, Type>(looooooooooooooooooooooooong,\n"
" arrrrrrrrrrg);",
Alignment);
+
+ Alignment.ColumnLimit = 80;
+ Alignment.SpacesInAngles = FormatStyle::SIAS_Always;
+ verifyFormat("void **ptr = reinterpret_cast< void ** >(unkn);\n"
+ "ptr = reinterpret_cast< void ** >(ptr[0]);",
+ Alignment);
+ verifyFormat("quint32 *dstimg = reinterpret_cast< quint32 * >(out(i));\n"
+ "quint32 *dstmask = reinterpret_cast< quint32 * >(outmask(i));",
+ Alignment);
+
+ Alignment.SpacesInParens = FormatStyle::SIPO_Custom;
+ Alignment.SpacesInParensOptions.InCStyleCasts = true;
+ verifyFormat("void **ptr = ( void ** )unkn;\n"
+ "ptr = ( void ** )ptr[0];",
+ Alignment);
+ verifyFormat("quint32 *dstimg = ( quint32 * )out.scanLine(i);\n"
+ "quint32 *dstmask = ( quint32 * )outmask.scanLine(i);",
+ Alignment);
}
TEST_F(FormatTest, AlignConsecutiveBitFields) {