[libclang] Get the absolute path of argument in the compile database

Hello,

In compile database, the include path in the arguments is relative path, e.g., “-I./src/include” shown in the below example:

[
    {
        "arguments": [
            "clang",
            "-c",
            "-I./src/include",
            "-o",
            "obj/src/select/select.o",
            "src/select/select.c"
        ],
        "directory": "/home/musl/musl-1.2.2",
        "file": "src/select/select.c"
    }
]

When I use clang_parseTranslationUnit() by passing that arguments, it will report error, is there any method that I can let libclang get the absolute path of such arguments?

Thanks!

It should be relative to the “directory” entry. So I think the idea is that you should set the cwd to that and then execute the command. Otherwise you can smash those two together I guess!