[PATCH] D145262: [clang-format] Treat AttributeMacros more like attribute macros

Jared Grubb via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 12 16:50:57 PDT 2023


jaredgrubb added inline comments.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:5329
+  if (Right.is(tok::l_square) && Right.is(TT_AttributeSquare))
     return !Left.is(TT_AttributeSquare);
 
----------------
I broke this `if` into two pieces and restored an original `return true` for this part of the `if` that was changed in 2020 (via 5a4ddbd69db2b0e09398214510501d0e59a0c30b).

The `return !Left...` was added to avoid breaking `[[` apart when reflowing a function-arg with C++11-style attribute (eg, `[[unused]]`). As far as I can tell, this check _really_ only matters if the code-path is the second-half of the original if (`Right.is(tok::l_square)...`). 

I couldn't imagine how there `Right.is(tok::kw___attribute)` needs the `Left`-check, so I think that patch is better split to differentiate (even though originally it didn't really have any conflicting effect).

Please let me know if my logic here is wrong (or I'm not making sense :) )


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145262/new/

https://reviews.llvm.org/D145262



More information about the cfe-commits mailing list