-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
51 lines (35 loc) · 1.13 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
Package libclang provides a means to parse a compilation unit with libclang,
and walk the unit's Cursors.
It's mostly a fairly thin wrapper around some of the C api provided by libclang.
The C api is documented at https://clang.llvm.org/doxygen/group__CINDEX.html.
Note that only a small very small subset of libclang's api is currently supported.
It's enough to parse C and C++ header files, and extract some basic information about
functions, constants, enums, structs, and so on.
# pre-requisites
The clang dev package (with header files) needs to be installed.
[sudo] dnf install clang-devel
or
[sudo] apt install clang-dev
# example
A simple example, that just visits a unit's top level cursors.
package main
import (
"fmt"
"log"
lc "github.com/pekim/libclang"
)
func main() {
unit, err := lc.ParseUnit("/usr/include/clang-c/Index.h")
if err != nil {
log.Fatal(err)
}
lc.VisitChildren(unit.Cursor(), func(cursor, parent lc.Cursor) lc.ChildVisitResult {
typ := cursor.Type()
fmt.Println(cursor.Spelling(), "==>", typ.Spelling())
return lc.ChildVisit_Continue
})
unit.Destroy()
}
*/
package libclang