This revision was automatically updated to reflect the committed changes. Closed by commit rGe21db15be812: [clang-format] Honour PointerAlignment in statements with initializers. (authored by curdeius).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D119814/new/ https://reviews.llvm.org/D119814 Files: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -8417,6 +8417,13 @@ verifyFormat( "/*comment*/ switch (int *p, *q; p != q) {\n default:\n break;\n}", Style); + + verifyFormat("if ([](int* p, int* q) {}()) {\n}", Style); + verifyFormat("for ([](int* p, int* q) {}();;) {\n}", Style); + verifyFormat("for (; [](int* p, int* q) {}();) {\n}", Style); + verifyFormat("for (;; [](int* p, int* q) {}()) {\n}", Style); + verifyFormat("switch ([](int* p, int* q) {}()) {\n default:\n break;\n}", + Style); } TEST_F(FormatTest, ConditionalExpressionsInBrackets) { Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -3142,7 +3142,8 @@ // initializers. if (Line.IsMultiVariableDeclStmt && (Left.NestingLevel == Line.First->NestingLevel || - startsWithInitStatement(Line))) + ((Left.NestingLevel == Line.First->NestingLevel + 1) && + startsWithInitStatement(Line)))) return false; return Left.Previous && !Left.Previous->isOneOf( tok::l_paren, tok::coloncolon, tok::l_square);
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -8417,6 +8417,13 @@ verifyFormat( "/*comment*/ switch (int *p, *q; p != q) {\n default:\n break;\n}", Style); + + verifyFormat("if ([](int* p, int* q) {}()) {\n}", Style); + verifyFormat("for ([](int* p, int* q) {}();;) {\n}", Style); + verifyFormat("for (; [](int* p, int* q) {}();) {\n}", Style); + verifyFormat("for (;; [](int* p, int* q) {}()) {\n}", Style); + verifyFormat("switch ([](int* p, int* q) {}()) {\n default:\n break;\n}", + Style); } TEST_F(FormatTest, ConditionalExpressionsInBrackets) { Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -3142,7 +3142,8 @@ // initializers. if (Line.IsMultiVariableDeclStmt && (Left.NestingLevel == Line.First->NestingLevel || - startsWithInitStatement(Line))) + ((Left.NestingLevel == Line.First->NestingLevel + 1) && + startsWithInitStatement(Line)))) return false; return Left.Previous && !Left.Previous->isOneOf( tok::l_paren, tok::coloncolon, tok::l_square);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits