[PATCH] D155783: [clang-format] Fix variable lacks of blank when previous operator is star

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 20 12:23:51 PDT 2023


HazardyKnusperkeks added a comment.

Please provide a diff with the full context (`-U999999` will do the trick).

And another context is needed, just `x * y` will never be (meaningful) be formatted. At least a `;` is missing, and I'd argue if your example is just

  ... something ...
  x * y;
  ... something ...

Your patch is wrong. While it is of course possible to just multiply something and drop the result, that's nonsense.
If the overloaded `operator*` has side effects, that's also possible, but bad code.
But defining a pointer `y` pointing to type `x` and not initializing it directly is more often the case:

  struct x;
  x* y;
  ... something ...



================
Comment at: clang/unittests/Format/FormatTest.cpp:96
   EXPECT_EQ(0, ReplacementCount);
+  EXPECT_EQ("x*y",
+            format("x * y"));
----------------
This is the wrong place.

You want a TokenAnnotatorTests, there is UnderstandStarAmp or something like that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155783



More information about the cfe-commits mailing list