[all-commits] [llvm/llvm-project] 1908da: [clang-format] Parse volatile as a pointer qualifier

Alexander Richardson via All-commits all-commits at lists.llvm.org
Fri Aug 28 03:32:17 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 1908da2658fc26154e4103a50faeeca804c7c57d
      https://github.com/llvm/llvm-project/commit/1908da2658fc26154e4103a50faeeca804c7c57d
  Author: Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>
  Date:   2020-08-28 (Fri, 28 Aug 2020)

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

  Log Message:
  -----------
  [clang-format] Parse volatile as a pointer qualifier

Before: void f() { MACRO(A * volatile a); }
After:  void f() { MACRO(A *volatile a); }

Also check that the __volatile and __volatile__ aliases are handled.

Reviewed By: JakeMerdichAMD

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


  Commit: 4f103695646bb9e16609a276072781f5a933570d
      https://github.com/llvm/llvm-project/commit/4f103695646bb9e16609a276072781f5a933570d
  Author: Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>
  Date:   2020-08-28 (Fri, 28 Aug 2020)

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

  Log Message:
  -----------
  [clang-format] Parse restrict as a pointer qualifier

Before: void f() { MACRO(A * restrict a); }
After:  void f() { MACRO(A *restrict a); }

Also check that the __restrict and __restrict__ aliases are handled.

Reviewed By: JakeMerdichAMD

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


  Commit: 37cdabdb82e33e0d659c92a6cbb7049c31e0acbc
      https://github.com/llvm/llvm-project/commit/37cdabdb82e33e0d659c92a6cbb7049c31e0acbc
  Author: Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>
  Date:   2020-08-28 (Fri, 28 Aug 2020)

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

  Log Message:
  -----------
  [clang-format] Parse __attribute((foo)) as a pointer qualifier

Before: void f() { MACRO(A * __attribute((foo)) a); }
After:  void f() { MACRO(A *__attribute((foo)) a); }

Also check that the __attribute__ alias is handled.

Reviewed By: MyDeveloperDay

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


  Commit: d304360decefae3fa5c807a8cd0d7d4501a1cc4b
      https://github.com/llvm/llvm-project/commit/d304360decefae3fa5c807a8cd0d7d4501a1cc4b
  Author: Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>
  Date:   2020-08-28 (Fri, 28 Aug 2020)

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

  Log Message:
  -----------
  [clang-format] Parse nullability attributes as a pointer qualifier

Before:
void f() { MACRO(A * _Nonnull a); }
void f() { MACRO(A * _Nullable a); }
void f() { MACRO(A * _Null_unspecified a); }

After:
void f() { MACRO(A *_Nonnull a); }
void f() { MACRO(A *_Nullable a); }
void f() { MACRO(A *_Null_unspecified a); }

Reviewed By: JakeMerdichAMD

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


  Commit: 96824abe7d80fc499032dab598968436132fcfb5
      https://github.com/llvm/llvm-project/commit/96824abe7d80fc499032dab598968436132fcfb5
  Author: Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>
  Date:   2020-08-28 (Fri, 28 Aug 2020)

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

  Log Message:
  -----------
  [clang-format] Detect pointer qualifiers in cast expressions

When guessing whether a closing paren is then end of a cast expression also
skip over pointer qualifiers while looking for TT_PointerOrReference.
This prevents some address-of and dereference operators from being parsed
as a binary operator.

Before:
x = (foo *const) * v;
x = (foo *const volatile restrict __attribute__((foo)) _Nonnull _Null_unspecified _Nonnull) & v;

After:
x = (foo *const)*v;
x = (foo *const volatile restrict __attribute__((foo)) _Nonnull _Null_unspecified _Nonnull)&v;

Reviewed By: MyDeveloperDay

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


Compare: https://github.com/llvm/llvm-project/compare/43aa7227dfab...96824abe7d80


More information about the All-commits mailing list