llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-format Author: Robin Caloudis (robincaloudis) <details> <summary>Changes</summary> Closes https://github.com/llvm/llvm-project/issues/92688 --- Full diff: https://github.com/llvm/llvm-project/pull/92741.diff 2 Files Affected: - (modified) clang/lib/Format/TokenAnnotator.cpp (+2-1) - (modified) clang/unittests/Format/FormatTest.cpp (+7) ``````````diff diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 7c4c76a91f2c5..7786b85e8a1fc 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -5280,7 +5280,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, // handled. if (Left.is(tok::amp) && Right.is(tok::r_square)) return Style.SpacesInSquareBrackets; - return Style.SpaceAfterLogicalNot && Left.is(tok::exclaim); + return (Style.SpaceAfterLogicalNot && Left.is(tok::exclaim)) || + Right.is(TT_BinaryOperator); } // If the next token is a binary operator or a selector name, we have diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 6f57f10e12e88..ca0edd7b22630 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -24545,6 +24545,13 @@ TEST_F(FormatTest, STLWhileNotDefineChed) { "#endif // while"); } +TEST_F(FormatTest, BinaryOperatorAfterUnaryOperator) { + verifyFormat("void test(void) {\n" + " static void (*xor)(uint8_t *, size_t, uint8_t);\n" + " xor = resolve_xor_x86();\n" + "}"); +} + TEST_F(FormatTest, OperatorSpacing) { FormatStyle Style = getLLVMStyle(); Style.PointerAlignment = FormatStyle::PAS_Right; `````````` </details> https://github.com/llvm/llvm-project/pull/92741 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits