[clang] [clang-format] Keep compound literals stable in macro bodies (PR #173771)

via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 28 06:45:14 PST 2025


================
@@ -491,6 +491,31 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) {
   SmallVector<StackEntry, 8> LBraceStack;
   assert(Tok->is(tok::l_brace));
 
+  constexpr int MaxLookBack = 64;
+  const auto IsAddressOfParenExpression = [](const FormatToken *RightParen) {
+    if (!RightParen || RightParen->isNot(tok::r_paren))
----------------
Lane0218 wrote:

Thanks for the feedback! I made the precondition explicit at the call site  (only call the helper when PrevTok is present and tok::r_paren) and replaced the redundant null/kind checks inside the helper with an assert to document the contract. 

https://github.com/llvm/llvm-project/pull/173771


More information about the cfe-commits mailing list