[PATCH] D88227: [clang-format] Add a SpaceBeforePointerQualifiers style option

Alexander Richardson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 24 07:01:02 PDT 2020


arichardson added inline comments.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2874-2889
+  if (Left.is(TT_PointerOrReference)) {
+    if (Style.SpaceBeforePointerQualifiers &&
+        Right.canBePointerOrReferenceQualifier())
+      return true;
     return Right.Tok.isLiteral() || Right.is(TT_BlockComment) ||
            (Right.isOneOf(Keywords.kw_override, Keywords.kw_final) &&
             !Right.is(TT_StartOfName)) ||
----------------
jrtc27 wrote:
> 
I feel like moving it here could in theory miss some cases. Also the condition is already barely comprehensible (I didn't attempt to understand which special cases all these conditions are for) and I don't feel like making it more complex.

If clang-format has identified that this */& token is a pointer/reference, and the next token is something that can be paresed as a pointer qualifier, shouldn't we trust the parser and simply look at the format option? It also IMO makes the code slightly easier to understand.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88227/new/

https://reviews.llvm.org/D88227



More information about the cfe-commits mailing list