[PATCH] D115050: [clang-format] PR48916 PointerAlignment not working when using C++20 init-statement in for loop

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 3 10:37:06 PST 2021


MyDeveloperDay added inline comments.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:3052
+    // & 1
+    if (Right.Tok.isLiteral())
+      return true;
----------------
HazardyKnusperkeks wrote:
> Is this valid code? Or did we just wrongly assign PointerOrReference? I'd say after that there can not be a literal in valid code, thus we do not need to handle it.
Ok so as you see I broken out the compound statement, to be honest I find these compound if's unreadable and I can't for the life of me work out what case they are trying to handle. (I want to do this more)..

Please no one say doing it separately is slower! without measuring it..we are talking ns difference if anything at all.

I agree I truly believe we are mis assigning PointerOrReference/BinaryOperator this as I mentioned  in
https://lists.llvm.org/pipermail/cfe-dev/2021-December/069486.html is a major issue and I think from time to time these rules try to correct that situation, in this case & is the logical operation on a reference.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:3065
+    // for (auto a = 0, b = 0; const auto& c : {1, 2, 3})
+    if (Left.Previous && Left.Previous->is(tok::kw_auto) &&
+        Right.is(tok::identifier))
----------------
HazardyKnusperkeks wrote:
> Do we need this just for `auto`? What when `auto` is replaced with `int`?
Man! you right...duh how did I miss that...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115050



More information about the cfe-commits mailing list