llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-format Author: MyDeveloperDay (mydeveloperday) <details> <summary>Changes</summary> No need to add an extract space if merging the characters doesn't cause a problem, hence ) and ! as well as ( do not require the extraneous space. Fixes #<!-- -->78166 --- Full diff: https://github.com/llvm/llvm-project/pull/78176.diff 2 Files Affected: - (modified) clang/lib/Format/TokenAnnotator.cpp (+1-1) - (modified) clang/unittests/Format/FormatTest.cpp (+2) ``````````diff diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 227aa0b97af6ba..e45271809e8085 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -4842,7 +4842,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, return true; } if (Left.is(TT_UnaryOperator)) { - if (Right.isNot(tok::l_paren)) { + if (!Right.isOneOf(tok::r_paren, tok::l_paren, tok::exclaim)) { // The alternative operators for ~ and ! are "compl" and "not". // If they are used instead, we do not want to combine them with // the token to the right, unless that is a left paren. diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 8f115fb8cbf0fb..54b8593fb98d42 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -24159,6 +24159,8 @@ TEST_F(FormatTest, AlternativeOperators) { verifyFormat("int a compl(5);"); verifyFormat("int a not(5);"); + verifyFormat("v(not)"); + verifyFormat("v(not!)"); /* FIXME handle alternate tokens * https://en.cppreference.com/w/cpp/language/operator_alternative `````````` </details> https://github.com/llvm/llvm-project/pull/78176 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits