[cfe-dev] Issue using clang parsing in python

mats petersson mats at planetcatfish.com
Wed Jan 14 00:47:08 PST 2015


Not able to parse header files, or not able to FIND (the correct!)
header files? There is a distinct difference... Maybe you could output
the preprocessed data from libclang (using the -E option)

--
Mats

On 13 January 2015 at 21:59, Moiz Ali <moiz.ali at stonybrook.edu> wrote:
> Hello,
>
> I am trying to parse c file using clang. I have created python binding using
> libclang.so and passing my .c file as and argument to my python script.
>
> I see that it is not able to parse header file, due to which file
> linux/errno.h is also not parsed and hence it is not able to get values of
> macro definition of all error codes.
> Ex:
> ----
> file bcm63xx_wdt.c:
> #include <linux/bitops.h>
> #include <linux/errno.h>
> #include <linux/fs.h>
> #include <linux/io.h>
> ...
> ...
> static int bcm63xx_wdt_open(struct inode *inode, struct file *file)
> {
> if (test_and_set_bit(0, &bcm63xx_wdt_device.inuse))
> return -EBUSY;                     // not able to find value of EBUSY,hence
> returns error when I try to print node.spelling()
> }
>
> I try to parse same file using clang command directly in command prompt and
> I see that
>
> :~$ clang -Xclang -ast-dump -fsyntax-only bcm63xx_wdt.c
> O/P:
> |   | |-ReturnStmt 0x1c23858 <line:119:3,
> /usr/include/asm-generic/errno-base.h:19:16>
> |   | | `-UnaryOperator 0x1c23838 <bcm63xx_wdt.c:119:10,
> /usr/include/asm-generic/errno-base.h:19:16> 'int' prefix '-'
> |   | |   `-IntegerLiteral 0x1c23818 <col:16> 'int' 16
>
>
> Also if I include Macro definition in source file
> #define EBUSY           16      /* Device or resource busy */
>
> Then I get correct output
>
> I am searching for issues in libclang but not able to find reason for
> failiure, can you guide me some steps which can help.
>
> Thanks,
> Moiz Ali
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>



More information about the cfe-dev mailing list