clang-format: Align asterisk (*) of pointer declaration with variable name

前端 未结 1 934
天涯浪人
天涯浪人 2020-12-29 06:59

I am using the following options in my .clang-format file:

AlignConsecutiveDeclarations: true
PointerAlignment: Right

The curr

相关标签:
1条回答
  • 2020-12-29 07:09

    PointerAlignment: Right is unfortunately not implemented yet.

    See https://github.com/llvm/llvm-project/blob/master/clang/lib/Format/WhitespaceManager.cpp#L643

    void WhitespaceManager::alignConsecutiveDeclarations() {
      if (!Style.AlignConsecutiveDeclarations)
        return;
    
      // FIXME: Currently we don't handle properly the PointerAlignment: Right
      // The * and & are not aligned and are left dangling. Something has to be done
      // about it, but it raises the question of alignment of code like:
      //   const char* const* v1;
      //   float const* v2;
      //   SomeVeryLongType const& v3;
    
      AlignTokens(Style, [](Change const &C) { return C.IsStartOfDeclName; },
                  Changes);
    }
    
    0 讨论(0)
提交回复
热议问题