Menu

#198 incorrect defines parsing with doxygen block comment

Undefined
fixed
ollydbg
Bug_Report
2015-08-28
2015-08-24
DmitryStu
No

In example

#define FOO  uint32_t(0x30000000)          /*!< Mask A descr. */
#define BAR  uint32_t(0x00070000)          /*!< Mask B descr  */

CC takes description for FOO from BAR. For BAR CC takes no description. All correct when single line comment style used.
using C::B SVN10341 both Windows and Linux

Discussion

  • ollydbg

    ollydbg - 2015-08-24
    • labels: doxygen --> doxygen, CodeCompletion
     
  • ollydbg

    ollydbg - 2015-08-24

    It is really hard to determin which is the end of a macro definition in this case, the Ticket 41, I can simply stop reading the macro definition if I meet a C++ style comments, but here, if I see /!< Mask A descr. /, I still need to go further to see whether there are some statement after this C style comment.

    #define FOO  uint32_t(0x30000000)     /*!< Mask A descr. */  valid_code here
    

    This is equally to the code:

    #define FOO  uint32_t(0x30000000)    valid_code here
    

    I don't know a correct way to fix this issue.

     
  • ollydbg

    ollydbg - 2015-08-24

    If you write the below code, then the first comment will attach to the aaa token.

    int aaa;
    #define FOO  uint32_t(0x30000000)          /*!< Mask A descr. */
    #define BAR  uint32_t(0x00070000)          /*!< Mask B descr  */
    
     
  • ollydbg

    ollydbg - 2015-08-24

    I think this patch should fix your prolem, I don't extensivedly tested it, so please test and give feedback, thanks.

     
  • ollydbg

    ollydbg - 2015-08-24
    • assigned_to: ollydbg
    • Type: Undefined --> Bug_Report
     
  • DmitryStu

    DmitryStu - 2015-08-24

    Thanks for the patch. Now it looks ok, at least on stm32 includes.
    Let's the extensive test starts.

     
  • DmitryStu

    DmitryStu - 2015-08-26

    Here is the some results. I found no problems with #defines. But the similar problem with enum's, struct's, union's (incl typedefs) appears after this patch. Members descriptions looks shifted down and 1'st member has an empty description. Tried for both line-style and block-style comments.

     
  • ollydbg

    ollydbg - 2015-08-26

    Thanks for the test and feedback. I will look into this regression in the next days. Sounds like a bit hard than I original thought.

     
  • ollydbg

    ollydbg - 2015-08-27

    But the similar problem with enum's, struct's, union's (incl typedefs) appears after this patch.

    I just tested with such example, but it works correctly with my patch applied.

    class AAA
    {
    public:
        int m_aaa;  /*!< Mask A descr. */
        int m_bbb;  /*!< Mask B descr. */
        int m_ccc;  /*!< Mask C descr. */
    };
    
    AAA obj;
    
    obj.
    

    so, what is your test code? Thanks.

     
  • DmitryStu

    DmitryStu - 2015-08-27

    Yes. Your example works correctly.
    I forgot about one condition. Put the doxygened macro definition first.
    I did not attach importance to this. This is my mistake.

    #define MACRO1  MACRO_1   /*!< produce an incorrect AAA members desc. */
    
    class AAA
    {
    public:
        int m_aaa;  /*!< Mask A descr. */
        int m_bbb;  /*!< Mask B descr. */
        int m_ccc;  /*!< Mask C descr. */
    };
    
    AAA obj;
    
    obj.
    
     
  • ollydbg

    ollydbg - 2015-08-28

    Oh, thanks for the example code, I found a mistake in my patch file, see the patched file, in function

    wxString Tokenizer::ReadToEOL(bool nestBraces, bool stripUnneeded)
    

    You see that in the beginning of the function, I set a variable

    m_ReadingMacroDefinition = true;
    

    But the variable should be set false before the return statement. I put the statement in the wrong place, so put them before the return statement. Patch against my original patch could be:

     src/plugins/codecompletion/parser/tokenizer.cpp | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/src/plugins/codecompletion/parser/tokenizer.cpp b/src/plugins/codecompletion/parser/tokenizer.cpp
    index c7df4ce..1bafa7a 100644
    --- a/src/plugins/codecompletion/parser/tokenizer.cpp
    +++ b/src/plugins/codecompletion/parser/tokenizer.cpp
    @@ -533,16 +533,16 @@ wxString Tokenizer::ReadToEOL(bool nestBraces, bool stripUnneeded)
             TRACE(_T("ReadToEOL(): (END) We are now at line %u, CurrentChar='%c', PreviousChar='%c', NextChar='%c'"),
                   m_LineNumber, CurrentChar(), PreviousChar(), NextChar());
             TRACE(_T("ReadToEOL(): %s"), str.wx_str());
    -
    +        m_ReadingMacroDefinition = false;
             return str;
         }
         else
         {
             const unsigned int idx = m_TokenIndex;
             SkipToEOL(nestBraces);
    +        m_ReadingMacroDefinition = false;
             return m_Buffer.Mid(idx, m_TokenIndex - idx);
         }
    -    m_ReadingMacroDefinition = false;
     }
    
     void Tokenizer::ReadParentheses(wxString& str)
    

    Thanks again for your test.

     
  • ollydbg

    ollydbg - 2015-08-28

    The modifed patch is in trunk now r10430, thanks for your contribution.

     
  • ollydbg

    ollydbg - 2015-08-28
    • status: open --> fixed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.