Clang parser - ignore directive #ifdef, parse everything
11:39 25 Feb 2016

I need to find calls of some functions in C source codes. I'm using Clang Python bindings for this.

The problem is, that this parser ignores code inside of "inactive" #ifdef directives. I understand, that this behaviour is correct (if the condition result is False), but now I need it simply to find all the calls, because of some automatic editing.


Example:

#define CONST2

#ifdef CONST
f90()
#endif

f90()

#ifdef CONST2
f90()
#endif

The parser will find just the second and the third call of the function f90(), but not the first one, because CONST is undefined. But I need Clang to find even the first one.


Is there any way to change this Clang behaviour?

EDIT:

I don't have a problem with source codes. The problem is in the settings of Clang parser - I need it simply to parse the WHOLE code, regardless of unmet conditions.

EDIT 2:

Ok, I don't think there's a bug in Clang... My question is, if there's some setting (possibly some flag) in Clang, so it'll ignore #ifdef conditions during code parsing.

c parsing clang llvm-clang