[all-commits] [llvm/llvm-project] 4986f3: [clang-format] Correctly annotate operator free fu...

Emilia Kond via All-commits all-commits at lists.llvm.org
Thu Jun 29 09:53:31 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4986f3f2f220e4fd2fef4b08e550b399c9f45a9f
      https://github.com/llvm/llvm-project/commit/4986f3f2f220e4fd2fef4b08e550b399c9f45a9f
  Author: Emilia Kond <emilia at rymiel.space>
  Date:   2023-06-29 (Thu, 29 Jun 2023)

  Changed paths:
    M clang/lib/Format/TokenAnnotator.cpp
    M clang/unittests/Format/FormatTest.cpp
    M clang/unittests/Format/TokenAnnotatorTest.cpp

  Log Message:
  -----------
  [clang-format] Correctly annotate operator free function call

The annotator correctly annotates an overloaded operator call when
called as a member function, like `x.operator+(y)`, however, when called
as a free function, like `operator+(x, y)`, the annotator assumed it was
an overloaded operator function *declaration*, instead of a call.

This patch allows for a free function call to correctly be annotated as
a call, but only if the current like cannot be a declaration, usually
within the bodies of a function.

Fixes https://github.com/llvm/llvm-project/issues/49973

Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay, Nuullll

Differential Revision: https://reviews.llvm.org/D153798




More information about the All-commits mailing list