clang-power-tools icon indicating copy to clipboard operation
clang-power-tools copied to clipboard

CLang Format Configurator: C++ Macro Definition destroyed

Open DrGierth opened this issue 9 months ago • 0 comments

Hello,

first, thanks to the community providing this tool.

I figured out that following Input:

#define SCS_DEF_SIGSLOT_SIGNAL_CHAIN_LOOP_INHIBIT_RETVALDEFAULT( ... /* default return value / SCS_RETOPT_XXX, default return value */) \
        auto FunctionID = __FUNCSIG__;                                                                                                  \
        auto MF2S_Iter =  m_umap_FunctionID2SignalID_loop_inhibit .find( FunctionID );                                                  \
        auto Signal_ID =  ms_umap_Thread_2_Signal_ID[GetCurrentThreadId()];                                                             \
        if ( MF2S_Iter == m_umap_FunctionID2SignalID_loop_inhibit .end() )                                                              \
        {                                                                                                                               \
          m_umap_FunctionID2SignalID_loop_inhibit [ FunctionID ] = Signal_ID .m_Signal_ID;                                              \
        }                                                                                                                               \
        else                                                                                                                            \
        {                                                                                                                               \
          if ( MF2S_Iter->second == Signal_ID.m_Signal_ID )  /* second entry with same signal? */                                       \
          {                                                                                                                             \
            DRG_OUTPUT_FILE_LINE_THIS_FUNC(_T("SIGNAL CHAIN ABORTED <______________________________________________________________")   \
                                           _T("____________________________________________________________________________________")   \
                                          );                                                                                            \
            BOOST_PP_IF                                                                                                                 \
            ( BOOST_PP_IS_EMPTY ( __VA_ARGS__ )                                                                                         \
            , return;                                                                                                                   \
            , BOOST_PP_IF                                                                                                               \
              ( BOOST_PP_EQUAL ( 1, BOOST_PP_VARIADIC_SIZE ( __VA_ARGS__ ) )                                                            \
              , SCS_RetVal = BOOST_PP_VARIADIC_ELEM ( 0, __VA_ARGS__); return;                                                          \
              , BOOST_PP_IF                                                                                                             \
                ( BOOST_PP_EQUAL( SCS_RETOPT_RETURN_RETVAL_IF_RETVAL_DEFINED, BOOST_PP_VARIADIC_ELEM ( 0, __VA_ARGS__) )                \
                , return BOOST_PP_VARIADIC_ELEM ( 1, __VA_ARGS__);                                                                      \
                , SCS_RetVal = BOOST_PP_VARIADIC_ELEM ( 1, __VA_ARGS__); return;                                                        \
                )                                                                                                                       \
              )                                                                                                                         \
            )                                                                                                                           \
          }                                                                                                                             \
                                                                                                                                        \
          MF2S_Iter ->second = Signal_ID.m_Signal_ID;     /* remember signal as processed for this function */                          \
        }                                                                                                                               \

by only activating "Standard c++11"

leads to following output:

#define SCS_DEF_SIGSLOT_SIGNAL_CHAIN_LOOP_INHIBIT_RETVALDEFAULT(

               \
    ... /* default return value / SCS_RETOPT_XXX, default return value */)     \
  auto FunctionID = __FUNCSIG__;                                               \
  auto MF2S_Iter = m_umap_FunctionID2SignalID_loop_inhibit.find(FunctionID);   \
  auto Signal_ID = ms_umap_Thread_2_Signal_ID[GetCurrentThreadId()];           \
  if (MF2S_Iter == m_umap_FunctionID2SignalID_loop_inhibit.end()) {            \
    m_umap_FunctionID2SignalID_loop_inhibit[FunctionID] =                      \
        Signal_ID.m_Signal_ID;                                                 \
  } else {                                                                     \
    if (MF2S_Iter->second ==                                                   \
        Signal_ID.m_Signal_ID) /* second entry with same signal? */            \
    {                                                                          \
      DRG_OUTPUT_FILE_LINE_THIS_FUNC(                                          \
          _T("SIGNAL CHAIN ABORTED ")                                          \
          _T("<_____________________________________________________________") \
          _T("_")                                                              \
          _T("______________________________________________________________") \
          _T("______________________"));                                       \
      BOOST_PP_IF(                                                             \
          BOOST_PP_IS_EMPTY(__VA_ARGS__), return;

\
          ,                                                                    \
          BOOST_PP_IF(                                                         \
              BOOST_PP_EQUAL(1, BOOST_PP_VARIADIC_SIZE(__VA_ARGS__)),          \
              SCS_RetVal = BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__);             \
              return;                                                          \
              , BOOST_PP_IF(                                                   \
                    BOOST_PP_EQUAL(SCS_RETOPT_RETURN_RETVAL_IF_RETVAL_DEFINED, \
                                   BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__)),    \
                    return BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__);             \
                    , SCS_RetVal = BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__);     \
                    return;)))                                                 \
    }                                                                          \
                                                                               \
    MF2S_Iter->second =                                                        \
        Signal_ID                                                              \
            .m_Signal_ID; /* remember signal as processed for this function */ \
  }\


The preprocessable and compilable c++ macro is destroyed.

Am I right that this is an error or do I have to put in some other clang configuration parameters?

Regards Michael

DrGierth avatar Jul 10 '25 09:07 DrGierth