codinuum / cca

Code Continuity Analysis Framework
https://codinuum.github.io/gallery-cca/
Apache License 2.0
20 stars 5 forks source link

[cpp] Regression in cpp parsing of marcros #38

Closed petr-bauch closed 7 months ago

petr-bauch commented 7 months ago

Hey team. I noticed that recent changed introduced a small regression specifically

int main() {
  P *p = new P();
  foreach (QString arg, options->args)
    p->play(arg);
}

Crashes the parser with

PARSING ERROR: File "cpp_tree.ml", line 248, characters 22-28: Assertion failed

Somehow the fact that p was declared and then used in the macro confuses the hash table in the visitor.

codinuum commented 7 months ago

Thank you for reporting. We will look into it.

codinuum commented 7 months ago

We think we have fixed the issue.

petr-bauch commented 7 months ago

This looks great. It may be intentional but we noticed that parsing some macro definitions now gives up sooner, e.g.

#define CC_BITS_NZC   (CC_BIT_N | CC_BIT_Z | CC_BIT_C)

now does not go into the bit-or and just has STMTS as the child of the object-like-macro.

or

#define CONTINUE_UNWINDING \
  do                                \
    {                               \
      if (__gnu_unwind_frame (ue_header, context) != _URC_OK)   \
    return _URC_FAILURE;                    \
      return _URC_CONTINUE_UNWIND;              \
    }                               \
  while (0)

used to contain the loop.

codinuum commented 7 months ago

We have just fixed the regression.

petr-bauch commented 7 months ago

Perfect. Thank you.