LibTooling is a library to support writing standalone tools based on Clang.
Questions tagged [libtooling]
152 questions
0
votes
1 answer
Create a new LabelDecl and add to Clang AST
I have a problem inserting LabelDecl. My goal is to create a goto statement in the program and to do that, first I need to create LabelDecl and add it to Clang AST.
There is an API to Create Label, but I am not able to get the IdentifierInfo.
static…

Bernard Nongpoh
- 1,028
- 11
- 20
0
votes
1 answer
RecursiveASTVisitor not visiting clang::VarDecl
I have the following c code test1.c:
double multiply(double x, double y) {
return x * y * y;
}
int main(int argc, char const *argv[])
{
double a;
int b;
float d;
double x = 3.0;
double y = 5.0;
double z =…

puhniste
- 1
- 1
- 2
0
votes
1 answer
Libclang: Get Symbol (e.g. function) at SourceLocation
I want to write a refactor tool, where I want to move the function at the cursor(cursor is in the function name) to the source file.
I found the FunctionMover.cc in https://github.com/lanl/CoARCT which is a good starting point to move the…

veio
- 507
- 4
- 16
0
votes
1 answer
Clang libtooling header errors
My project which uses clang-libtooling fails to compile due to errors that come form the headers.
The error is: C:\llvm\llvm\include\llvm\Support\MathExtras.h(372,31): error C4146: unary minus operator applied to unsigned type, result still…

Kivi
- 77
- 1
- 8
0
votes
1 answer
Definition data of ClassTemplateSpecializationDecl is null
I recieve a class alt::VectorLayout for example, as a ClassTemplateSpecializationDecl and I'm trying to process the field and methods of the class, but it fails on an assertion where the definition data is null. I have the presumption that…

7Hazard
- 23
- 2
- 6
0
votes
1 answer
Clang libtooling: how to print compiler macro definitions
I have a LibTooling based utility and I would like to output a list of macro definitions for debug purposes. One can print compiler macro definitions with clang/gcc -dM -E -, but it does not seem to work if I pass -dM -E or -dD to ClangTool. Is it…

Victor K
- 529
- 2
- 16
0
votes
1 answer
Enable only syntactic parsing in clang
I am trying to implement a clang tool that does syntactic analysis using ASTMatcher API. I am trying to find out how to specify extra flags for clang to disable semantic checks. I know clang builds a giant AST which includes system headers. Is there…

gPats
- 315
- 2
- 17
0
votes
1 answer
Is it possible to use Clang libtooling with other compilers?
We have a product which targets a large variety of platforms. Compilation for some of those platforms is using MSVC rather than clang.
We are using the clang libtooling interface where we provide a compile_commands.json file to indicate how to…

Justin
- 447
- 4
- 10
- 33
0
votes
1 answer
Usage of ParentMap in Clang
There seems to be no examples online, according to the documentation Path, ParentMap's constructor accepts "Stmt *ASTRoot", which may means that later the ParentMap instance will find parents under the AST subtree under "ASTRoot". But how to get the…

jw_
- 1,663
- 18
- 32
0
votes
0 answers
How to enable try-catch in clang libtooling?
I wanted to use try catch statement in clang libtooling,but by default it is taking compiling options as -fno-rtti and -fno-exceptions
If I use the try-catch statement in clang libtooling , It is throwing error…

Jon marsh
- 279
- 7
- 12
0
votes
1 answer
Failing to dyn_cast Expression pointer to DeclRefExpr in clang
I m working on clang libtooling, I needed the left hand side of the assignment operation ,
So I used VisitBinaryOperator(BinaryOperator *B) to get the left hand side , I did some research on it and implemented in the following way
bool…

Jon marsh
- 279
- 7
- 12
0
votes
1 answer
How to get the macro and its expansion with clang libtooling?
I am working on clang libtooling.
So far I am managed to get the macro where it is getting referred in the source file through visitDeclRefExpr(DeclRefExpr *DR)
But can I get a list of macros with its name and its expansion as…

Jon marsh
- 279
- 7
- 12
0
votes
0 answers
Prebuilt libTooling (LLVM/Clang tools) headers and dlls for Windows with RTTI on
This might not be the right place to ask this question, but I could not find an answer anywhere else.
I want to create a static-analyzer with the libTooling library, outside of the llvm source tree. On the official llvm site, I only found prebuilt…

Bako
- 313
- 1
- 15
0
votes
0 answers
Is there any way I can find all macro expansion location?
I want to find all macro expansion location to replace the definition of macro.
I don't know what API I can use to get the macro expansion location.
#include
#define NUM 5
int main(void)
{
int i;
int j = NUM;
int a[NUM] = {0};
…

yxh
- 5
- 2
0
votes
1 answer
How to expand a complex typedef to its basic built-in form using clang?
I want to be able to get the original type from the complex typedef.
I'm using clang version 7.1.0
Look at the code below
typedef unsigned int uint32;
typedef uint32 * p_uint32;
p_uint32 p_uint_var;
I can extract type of p_uint_var using…

fskoras
- 68
- 7