Questions tagged [libclang]

LibClang is a stable high level C interface to the clang compiler.

LibClang is a stable high level C interface to clang.

When in doubt, LibClang is probably the best clang interface to use, since it:

  • can be called from any language interfaced with C (python bindings come out of the box),
  • is stable,
  • provides high enough abstraction over clang's implementation details.

LibClang provides the following features:

  • C/C++/ObjC/ObjC++ code parsing and syntax checking,
  • AST indexing and cross-referencing,
  • source code tokenization (e.g. for syntax highlighting),
  • code completion.

Useful links

Related tags

230 questions
0
votes
1 answer

Cancel libclang task

It is a short question. I believe there is no way to cancel a job submitted to libclang through python bindings (for example code completion task). Can anybody prove me wrong? I am interested in using libclang in a multi threaded environment but it…
niosus
  • 738
  • 8
  • 22
0
votes
0 answers

libclang: no cursor for standard library functions

There is a problem with libclang — it does not seem to be able to get cursor for standard library functions. I have following Python code: import clang.cindex def traverse(node, depth=0): depth += 1 print depth * '--', node.spelling or…
unsigned
  • 11
  • 2
0
votes
1 answer

How to use cmake build config to run llvm libclang tool that is not a plugin over my whole code base?

I have written a llvm plugin and made a cmake object library that runs the plugin over each source file, but I need to have data from the whole compilation, whereas a plugin is run again for each compilation unit. My build environment is fairly…
xaxxon
  • 19,189
  • 5
  • 50
  • 80
0
votes
1 answer

sublime text 3 plugin host crash recovery

I develop a plugin for Sublime Text 3 and my python code uses c type bindings to clang. Sometimes calling libclang would segfault with libclang: crash detected during reparsing (I don't understand the reason yet, but it is irrelevant to this…
0
votes
0 answers

Undefined base classes not found in CXXRecordDecl

When using clang::ParseAST on this code only (no more, no less) class A : public B, public C { int field; }; I'm not able to get informations about B and C, they seem completely ignored and are not present when looping with…
Juicebox
  • 442
  • 4
  • 11
0
votes
1 answer

Parsing namespace functions with libclang

I am unable to parse the body of a namespace function in c++ with libclang. I have a class in a namespace like so: namespace outer { namespace inner { class MyClass { public: short myMethod(){ …
BrockLee
  • 931
  • 2
  • 9
  • 24
0
votes
0 answers

Java -> JNA -> libclang: fatalerror with clang_visitChildren invocation

I wrote java wrappers for LibClang API. Wrapper for clang_visitChildren works good for comparatively small c-source files (less than 200 first level childs). But it crashed for more large source file in area of 550-560 first level child. My callback…
0
votes
1 answer

Libclang parse error

I use libclang with qt in order to create auto-complete feature for my custom IDE. I made this function: QList CodeTool::autocompletion(QString content, QTextCursor cursor, QString filepath, QStringList options) { …
Intelligide
  • 279
  • 2
  • 14
0
votes
0 answers

How to get the literal place of variable definition with clang

I have following scenario. some_header.h #define SOME_VARS \ int first_var; \ char other_var; source_file.c #include "some_header.h" SOME_VARS Now with clang I can dump the AST and see that it knows where those variables are literally…
RedX
  • 14,749
  • 1
  • 53
  • 76
0
votes
0 answers

Clang c-api total memory usage

How to get total memory usage of clang c-api for a given translation unit? There is clang_getCXTUResourceUsage but it returns memory usage broken into entries where each entry describes certain category. UPDATE1: Documentation states the units of…
Evgeny Timoshenko
  • 3,119
  • 5
  • 33
  • 53
0
votes
1 answer

clang, libtooling add new canonical builtin data type

In a program using libtooling, is there a way to make some types recognized as "built-in type" ? For example, I'd like to make int16_t, uint32_t etc. recognized as canonical built-in types rather than it's typedef to short, unsigned etc.
hl037_
  • 3,520
  • 1
  • 27
  • 58
0
votes
1 answer

libclang clang_getSpellingLocation access violation

I'm trying to start a tutorial about libclang library, but I get an access violation when calling the function clang_getSpellingLocation(). Other information about the error is correctly reported with error count, line and column. My environment:…
AngeloDM
  • 397
  • 1
  • 8
0
votes
1 answer

Includes in libclang headers

I was looking through the libclang headers here(http://llvm.org/svn/llvm-project/cfe/trunk/include/clang-c/) where in I noticed that almost all of the headers have imports as in #include "clang-c/Platform.h" // in CXString.h // in Index.h #include…
evanescent
  • 1,373
  • 13
  • 20
0
votes
0 answers

can't catch exception after creating CXIndex

Why does this program #include #include #include int main() { try { throw std::exception("threw"); } catch (const std::exception& e) { std::cout << e.what() << "\n"; } CXIndex…
0
votes
1 answer

How to find lines of objective c method implementations using libclang

I want to get the line numbers where the implementation of objective c method start. 1 #include "foobar.h" 2 -(void)Foo{ 3 ... 4 } 5 6 +(NSInteger *)bar{ 7 ... 8 } The output should be: 2,6 How can i achieve it with libclang. I do not want to use…
mc_plectrum
  • 363
  • 4
  • 12
1 2 3
15
16