[cfe-users] [libclang 5] Header files not found

D G via cfe-users cfe-users at lists.llvm.org
Wed Mar 28 15:23:53 PDT 2018


I use python bindings of libclang.


Source files are correct. Build works fine.

I pass compile_commands.json to libclang parser.


And I've written this snippet in python :


def do_cparse(srcFile : str, index : clang.cindex.Index, compDB : CompilationDatabase, additional_args : list):
    def clean_commandLine(args : list):
        del args[0]
        i = 0
        while i < len(args):
            if args[i] == '-c' or args[i] == '-o':
                del args[i]
                del args[i]
            else:
                i += 1
        return args

    if compDB is not None:
        compileCommands = compDB.getCompileCommands(srcFile)
        if compileCommands is None:
            args = []
        else:
            args = compileCommands.__getitem__(0).arguments
            args = [arg for arg in args]
            args = clean_commandLine(args)
    else:
        args = []
    try:
        tu = index.parse(srcFile, args.extend(additional_args))
    except TranslationUnitLoadError:
        pass
    #from pprint import pprint
    #pprint(('nodes', get_info(tu.cursor)))

    for diagnostic in tu.diagnostics:
        print(diagnostic.format() +  '\n')



But diagnostics deliver this :

/usr/include/limits.h:123:16: fatal error: 'limits.h' file not found
/usr/include/stdio.h:33:11: fatal error: 'stddef.h' file not found
/usr/include/stdlib.h:32:10: fatal error: 'stddef.h' file not found
/usr/include/unistd.h:229:10: fatal error: 'stddef.h' file not found


It seems libclang goes wrong. Is it a known issue ?


More, project C-headers are also affected while -I<path to myheaders> is passed to Index.parse().


Thanks a lot for your contributions.


Regards

Didier.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20180328/fb43f1b3/attachment.html>


More information about the cfe-users mailing list