Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/0x6675636b796f75676974687562/libclang-example

Shows how libclang can be used to parse C++ source code
https://github.com/0x6675636b796f75676974687562/libclang-example

Last synced: about 2 months ago
JSON representation

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

Awesome Lists containing this project

README

        

= Sample code showing how `libclang` can be used to parse C++
:toc:
:imagesdir: docs/images

[.float-group]
--
[.left]
image::https://img.shields.io/badge/License-MIT-yellow.svg[License: MIT,link="https://opensource.org/licenses/MIT"]
--

link:https://github.com/ShiftLeftSecurity/overflowdb[_OverflowDB_] can produce
both link:http://graphml.graphdrawing.org/primer/graphml-primer.html[_GraphML_]
and link:https://graphviz.org/doc/info/lang.html[_DOT_] files.
So, the following C source code:

[source,c]
--
#include

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 link:https://graphviz.org[_GVEdit_]):

image::array-subscript-dot.svg[Export from DOT using GVEdit,link="https://raw.githubusercontent.com/0x6675636b796f75676974687562/libclang-example/master/docs/images/array-subscript-dot.svg"]

Alternative rendering (_GraphML_,
converted to _SVG_ using link:https://www.yworks.com/products/yed[_yEd_]):

image::array-subscript-radial.svg[Export from GraphML using yEd,link="https://raw.githubusercontent.com/0x6675636b796f75676974687562/libclang-example/master/docs/images/array-subscript-radial.svg"]