This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Detect pointer qualifiers in cast expressions
ClosedPublic

Authored by arichardson on Aug 27 2020, 8:14 AM.

Details

Summary

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;

Diff Detail