Skip to content

0x6675636b796f75676974687562/libclang-example

Repository files navigation

Sample code showing how libclang can be used to parse C++

License: MIT

OverflowDB can produce both GraphML and DOT files. So, the following C source code:

#include <stdio.h>

int main(int argc, char *argv[]) {
    int integers[] = {1, 2, 3, 4, 5};

    int first = integers[0];
    printf("%d\n", first);

    const int second = integers[1];
    printf("%d\n", second);

    int third = (int) integers[2];
    printf("%d\n", third);

    printf("%d\n", integers[3]);

    printf("%d\n", 4[integers]);

    const char *string = "ABCD";
    printf("%c\n", string[0]);

    printf("%c\n", 1[string]);

    printf("%c\n", "ABCD"[2]);

    printf("%c\n", 3["ABCD"]);

    return 0;
}

can be exported into the following graph (DOT, converted to SVG using GVEdit):

Export from DOT using GVEdit

Alternative rendering (GraphML, converted to SVG using yEd):

Export from GraphML using yEd

About

Shows how libclang can be used to parse C++ source code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages