sbinet / go-clang Goto Github PK
View Code? Open in Web Editor NEWDEPRECATED. use https://github.com/go-clang. CGo bindings to the C-api of libclang.
License: Other
DEPRECATED. use https://github.com/go-clang. CGo bindings to the C-api of libclang.
License: Other
Gentoo installs libclang, etc in /usr/lib/llvm
. This means that when you try and build go-clang
you get:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/../../../../x86_64-pc-linux-gnu/bin/ld: warning: libLLVM-3.1.so, needed by /usr/lib64/llvm/libclang.so, not found (try using -rpath or -rpath-link)
/usr/lib64/llvm/libclang.so: undefined reference to `llvm::sys::fs::make_absolute(llvm::SmallVectorImpl<char>&)'
/usr/lib64/llvm/libclang.so: undefined reference to `llvm::EnableStatistics()'
... [and many more]
.. this is sort of fixed by doing:
CGO_LDFLAGS="-Wl,-rpath,$(llvm-config --libdir) $(llvm-config --ldflags)" go get
... in that you get a binary, but then:
$ ldd ./goclang
linux-vdso.so.1 (0x00007fff15bd3000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f01d0a2b000)
libffi.so.6 => /usr/lib64/libffi.so.6 (0x00007f01d0823000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f01d061f000)
libm.so.6 => /lib64/libm.so.6 (0x00007f01d032a000)
libclang.so => not found
libc.so.6 => /lib64/libc.so.6 (0x00007f01cff80000)
/lib64/ld-linux-x86-64.so.2 (0x00007f01d0c48000)
Will update if I find a solution.
it should be possible to use go-clang
(or python-cindex
) to generate most of the go-clang code, starting from a parsed representation of a given CIndex
API version.
This would tremendously reduce the maintenance load of keeping up with the LLVM/CIndex API churn.
Ideally, just running go generate
in go-clang
repository would generate the whole set of stubs (and possibly the complete bindings?) for each CIndex
version.
I hope you don't mind me creating this issue. I'd like to track the test failure.
1: error: 'clang_Cursor_getNumArguments' undeclared (first use in this function)
1: note: each undeclared identifier is reported only once for each function it appears in
1: error: 'clang_Cursor_getArgument' undeclared (first use in this function)
1: error: 'clang_getEnumConstantDeclValue' undeclared (first use in this function)
1: error: 'clang_getEnumConstantDeclUnsignedValue' undeclared (first use in this function)
1: error: 'clang_getEnumDeclIntegerType' undeclared (first use in this function)
1: error: 'clang_getTypedefDeclUnderlyingType' undeclared (first use in this function)
On all (developer) OSX systems I think this would be a more sane default;
#cgo darwin LDFLAGS: -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib
The previous value would be the one to use when you install clang yourself I think?
I am wondering how I can check if a variable declaration (Type == VarDecl) is static. There is method called "isStaticLocal" in the Clang documentation http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html#a513c56596b4d12e99dd42a4f3ff646d4 but I do not see it in go-clang.
How can I add and use isStaticLocal in go-clang? Can you please document the steps of enhancing go-clang so that I can do it on my own, and send pull request. I am currently a little baffled on how to do that.
consider using gopkg.in
for go get
-able multiple versions of the clang
C-API
, instead of "just" git branches.
the alternative being the creation and curation of a Makefile
to discover the user's clang
version, creating go build
tags...
Hi,
https://github.com/sbinet/go-clang/blob/master/cursor.go#L798
it seems like this line causes issues when passed a closure if building with go 1.6. Using GODEBUG=cgocheck=0
when running works but that's not really a good idea. Passing it a closure is the only way to actually pass arguments to your visitor I think, e.g.
// collectMatchKind collects all or one element name(s) in the sub AST-tree rooted at
// the provided cursor.
func collectMatchKind(entityCursor clang.Cursor, kind clang.CursorKind,
collectAll bool) (names []string) {
// Invoke the visitor with this closure.
entityCursor.Visit(func(cursor, parent clang.Cursor) (
status clang.ChildVisitResult) {
if cursor.Kind() == kind {
names = append(names, cursor.DisplayName())
if !collectAll {
return clang.CVR_Break
}
}
return clang.CVR_Continue
})
return // named
}
panic: runtime error: cgo argument has Go pointer to Go pointer
goroutine 1 [running]:
panic(0x42247c0, 0xc82000eae0)
/usr/local/Cellar/go/1.6/libexec/src/runtime/panic.go:464 +0x3e6
github.com/sbinet/go-clang._cgoCheckPointer0(0x41c8c80, 0xc82002c050, 0xc82000ead0, 0x1, 0x1, 0xc82002c048)
??:0 +0x4d
github.com/sbinet/go-clang.Cursor.Visit(0xb, 0x6e24080, 0x1, 0x6095c30, 0xc820014ec0, 0x4236f20)
/Users/dzan/Source/go/src/github.com/sbinet/go-clang/cursor.go:798 +0x12f
main.collectMatchKind(0xb, 0x6e24080, 0x1, 0x6095c30, 0x28, 0x0, 0x0, 0x0)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.