[PATCH] D151047: [clang-format] Fix indent for selective formatting.

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 18 12:46:37 PDT 2023


owenpan added inline comments.


================
Comment at: clang/unittests/Format/FormatTestSelective.cpp:643-646
+  Style.FixNamespaceComments = false;
+  Code = "namespace ns {\n"
+         "#define REF(alias) alias alias_var;\n"
+         "}"; // Format this line only
----------------
Sedeniono wrote:
> owenpan wrote:
> > Then I'd remove `Style.FixNamespaceComments` as a factor by formatting a non-brace line.
> The problem I observed did not trigger by formatting some arbitrary line. It triggered when formatting specifically the line with the closing `}`. Formatting any other line makes therefore no sense. I just tried it again.
> `FixNamespaceComments = false` means that the expected result is that the code fragment remains unchanged. With `FixNamespaceComments = true`, the formatter would change it (by adding the `// namespace ns` comment after the brace).
> 
> If you are still offended by the test, I will give up and will remove it. There are still the clang rename tests after all that execute the particular code path and uncovered the problem originally.
Got it! I didn’t know the assertion was triggered by formatting the closing brace. We should keep the test as is then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151047



More information about the cfe-commits mailing list