This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] distinguish multiplication after brace-init from pointer
ClosedPublic

Authored by krasimir on Jul 14 2022, 6:47 AM.

Details

Summary

After https://github.com/llvm/llvm-project/commit/b646f0955574c6ad4c156c9db522e46f597cfda9,
the added regression test started being formatted as-if the
multiplication * was a pointer. This adapts the heuristic to
distinguish between these two cases.

Diff Detail

Event Timeline

krasimir created this revision.Jul 14 2022, 6:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 14 2022, 6:47 AM
krasimir requested review of this revision.Jul 14 2022, 6:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 14 2022, 6:47 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
krasimir edited the summary of this revision. (Show Details)Jul 14 2022, 6:48 AM
krasimir added a reviewer: jackhong12.
krasimir edited projects, added Restricted Project; removed Restricted Project.
Herald added a project: Restricted Project. · View Herald TranscriptJul 14 2022, 6:48 AM
curdeius accepted this revision.Jul 14 2022, 8:31 AM
This revision is now accepted and ready to land.Jul 14 2022, 8:31 AM
jackhong12 accepted this revision.Jul 14 2022, 6:55 PM

I think we can also add new test cases in clang/unittests/Format/TokenAnnotatorTest.cpp.

Tokens = annotate("int i = int{42} * 34;");
...
owenpan accepted this revision.Jul 15 2022, 12:04 AM
owenpan added a subscriber: owenpan.
owenpan added inline comments.
clang/lib/Format/TokenAnnotator.cpp
2328
krasimir updated this revision to Diff 444921.Jul 15 2022, 2:41 AM
  • address review comments
krasimir marked an inline comment as done.Jul 15 2022, 2:42 AM

I think we can also add new test cases in clang/unittests/Format/TokenAnnotatorTest.cpp.

Tokens = annotate("int i = int{42} * 34;");
...

added a test.

This revision was landed with ongoing or failed builds.Jul 15 2022, 2:46 AM
This revision was automatically updated to reflect the committed changes.
This comment was removed by jackhong12.