codinuum / cca

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

LinkageSpecification spans multiple pre-processor conditions #27

Closed petr-bauch closed 2 years ago

petr-bauch commented 2 years ago

Hey team. You are doing an amazing work. :heart: I'm not sure if this is an actual issue or a known "feature", but in the following code:

#ifdef __cplusplus
extern "C" {
#endif
struct foo;
#ifdef __cplusplus
} /* End extern "C".  */
#endif

The AST tree looks a bit weird. It looks like the linkage-specification has higher priority than the pre-processor conditionals. I understand that it's impossible to parse all non-pre-processed code. Just wanted to ask if this is known.

codinuum commented 2 years ago

Thank you for reporting! Indeed the resulting AST may look weird, but it is intended. To parse block-breaking branches in the example, the parser marks #endif (line 3) and #ifdef (line5) as "odd". The parser regards odd conditionals as null directives.

petr-bauch commented 2 years ago

I see, that makes sense. Thank you for explaining it.