clang-format: Problem with BreakBeforeBinaryOperators

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

clang-format: Problem with BreakBeforeBinaryOperators

Nathan Ridge via cfe-dev
(Possibly wrong mailing list?)


I'm trying to get the formatting for binary operators and constructor arguments the way our group would like it. Currently the style is based on llvm. For operator alignment it currently returns:
bool Derived::equals(const Base *n)
{
 if (false == Base::equals(n))
   return false;
 Derived *an = ( Derived * )n;
 return (m_num_nodes == an->m_num_nodes && m_num_slices == an->m_num_slices &&
         m_num_nodeslices == an->m_num_nodeslices && m_is_selstar == an->m_is_selstar);
}
We would prefer it return the following:
bool Derived::equals(const Base *n)
{
 if (false == Base::equals(n))
   return false;
 Derived *an = (Derived *)n;
 return (m_num_nodes == an->m_num_nodes &&
         m_num_slices == an->m_num_slices &&
         m_num_nodeslices == an->m_num_nodeslices &&
         m_is_selstar == an->m_is_selstar);
}

What is interesting is that the preferred output is almost correct if I use -style=none. But some details about curly-brace locating don't match. The full style is at the end of this message.

The alignment we would prefer for function arguments is to have 1 per line, with a leading ','. Based on LLVM
We have
inline
void Mgr::retag
 /// Helper method to request retagging of an address range rather than a
 /// base and count.
 ( void* base          ///< Huge page aligned range begin
 , void* end           ///< Randomly aligned range end
 , qx::TxTag newTag    ///< New tag (to be assigned)
 )
But the formatter does this. Again -style=none doesn't have the problem.
inline void Mgr::deallocate
   /// Helper method to request freeing of an address range rather than a
   /// base and count.
   (void *base ///< Huge page aligned range begin
    ,
    void *end ///< Randomly aligned range end
    ,
    bool noError ///< Crux of the _one-shot_ mechanism
   )

If I could get guidance on how to set switches for these 2 options it would go a long way in getting our code.

CSI.CSI <http://clang-developers.42468.n3.nabble.com/file/t497788/CSI.CSI>  

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev