[PATCH] D103589: [Format] Fix incorrect pointer detection

Yilong Guo via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 2 22:12:05 PDT 2021


Nuullll created this revision.
Nuullll added a project: clang-format.
Nuullll requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Before:

  void foo() { bar(float(1), a *b); }

After:

  void foo() { bar(float(1), a * b); }

Signed-off-by: Yilong Guo <yilong.guo at intel.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103589

Files:
  clang/lib/Format/TokenAnnotator.cpp


Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -399,7 +399,7 @@
         HasMultipleParametersOnALine = true;
       if ((CurrentToken->Previous->isOneOf(tok::kw_const, tok::kw_auto) ||
            CurrentToken->Previous->isSimpleTypeSpecifier()) &&
-          !CurrentToken->is(tok::l_brace))
+          !CurrentToken->isOneOf(tok::l_brace, tok::l_paren))
         Contexts.back().IsExpression = false;
       if (CurrentToken->isOneOf(tok::semi, tok::colon)) {
         MightBeObjCForRangeLoop = false;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103589.349452.patch
Type: text/x-patch
Size: 652 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210603/db3b6dfe/attachment.bin>


More information about the cfe-commits mailing list