Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [libclang]

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

libclang
2 votes
1 answer
41 views

How do I get the enum type of a clang::EnumConstantDecl?

I'm trying to write a clang tool that finds all calls to a function with a variable number of arguments, and returns the type of each argument. When I pass in a constant enumerator value, for example: ...
shaharhoch's user avatar
2 votes
1 answer
46 views

Get relative include path for file with clang tooling

I'm using clang tooling to auto generate some code from an existing code base. In some cases I have an enum type that I want to use, so I want to include it. I'm able to get the path to the file to ...
shaharhoch's user avatar
1 vote
1 answer
52 views

Get function call argument enum type with libclang

I'm using libclang to parse some code, and I want to find calls to a specific function and the types of its arguments. For example, let's say the code is: void foo(int a, ...) {} enum test { ...
shaharhoch's user avatar
1 vote
1 answer
36 views

How to parse multi-dimensional arrays with python libclang bindings

I'm having a difficult time with what, in my mind, should be a fairly simple task: Using the python bindings to libclang I want to get the dimensions for a multi-dimensional array field of a POD C++ ...
Dudeman McGuybro's user avatar
2 votes
2 answers
60 views

Using libclang, is there a way to know if a closure type was introduced in the context of the initialization of a inline variable?

Given the following C++ code: inline auto v = []{ return 1; }(); The context of the closure type is the initializer of an inline variable. This leads to a special mangling rule in the Itanium ABI (...
Dorian's user avatar
  • 552
1 vote
1 answer
33 views

libclang CXTranslationUnit_DetailedPreprocessingRecord doesn't affect parse

While trying to use the C libclang bindings to parse some sources, I have found that preprocessor directives do not show up in the AST. Following recommendations from this previous question, and ...
senor-tomate's user avatar
1 vote
1 answer
52 views

How to parse AST of C/C++ program having OpenACC pragma directives using clang and its Python bindings?

I want to parse the AST of a C/C++ program that has OpenACC pragma directives (see example below). My eventual goal is to generate a JSON file having all the pairs of pragma-block of code the pragma ...
Samyak Jhaveri's user avatar
1 vote
2 answers
37 views

clang AST for single line multiple variable declaration

I'm trying to use libclang from python to traverse the AST for the following snippet of C: /* simple.c */ bool LED0 = 0; /* state0 */ bool LED1 = 0; /* state1 */ bool LED2 = 1; /* ...
aneccodeal's user avatar
  • 8,793
1 vote
1 answer
69 views

Clang LibTooling doesn't process any source files

I'm trying to run a minimal LibTooling example, but must be missing something obvious, because my AST visitor isn't getting called at all, and any errors in the input files aren't getting diagnosed. ...
HolyBlackCat's user avatar
  • 91.2k
0 votes
1 answer
124 views

libClang.dll DllNotFoundException on Visual Studio Extensibility (VSX) project

Hellow there ! I am trying to use "CppAst.Net" nugget in a visual studio extensibility project, So far, when doing it in a classic c# project everything work fine, but when trying in a VSX ...
Tamaho's user avatar
  • 1
2 votes
0 answers
121 views

Libclang way slower to parse AST than -ast-dump option

I'm generating code by parsing the AST of my header files with libclang and I'm experiencing very long parsing time (30+ seconds on every files). I've tried -ast-dump=json and it's way faster. I start ...
Jazzwave06's user avatar
  • 1,851
0 votes
0 answers
53 views

How to expand macros with python and libclang

Say I have the following C code. #define A 0x1800 #define MACRO_FUNC(in) (A | (in)) #define B 6 #define MY_MACRO MACRO_FUNC(B) How would I use libclang python bindings to expand MY_MACRO to (0x1800 |...
Sam P's user avatar
  • 701
2 votes
1 answer
215 views

How can I get the fully qualified names of return types and argument types using libclang's python bindings?

Consider the following example. I use python clang_example.py to parse the header my_source.hpp for function and method declarations. my_source.hpp #pragma once namespace ns { struct Foo { ...
joergbrech's user avatar
  • 2,742
1 vote
0 answers
102 views

How do I get entire Data Layout for a class, using libclang?

I am trying to generate the Data Layout for a class. Specifically, I want the size of an object of type X the alignment of an object of type X the offset within an object of type X of each data ...
Jody Hagins's user avatar
  • 28.2k
2 votes
1 answer
163 views

Using Libclang python bindings, how do you retrieve annotations added to C++ class/struct?

Using the following C++ struct as an example: __attribute__((annotate("MyAttribute"))) struct TestComponent { __attribute__((annotate("MyAttribute"))) int32_t testInt; ...
HateDread's user avatar
  • 141

15 30 50 per page
1
2 3 4 5
17