LibTooling is a library to support writing standalone tools based on Clang.
Questions tagged [libtooling]
152 questions
0
votes
2 answers
Clang does not parse a template with partial specialization: template < class T, class U = TYPE_A > class TYPE_B;
I have example of code with template with template partial specialization. And where clang while parsing ,return result invalid declaration.
template < class T> class TYPE_A
{
};
template < class T, class U> class TYPE_B
{
};
template < class T,…

Ivan Solovei
- 1
- 2
0
votes
2 answers
Why clang AST shows two CXXRecordDecl for a single class?
I'm trying to build tools with libtooling.
when using clang to dump AST, i found that two CXXRecordDecl were reported for class Foo.
It seems that the outer CXXRecordDecl has a CXXRecordDecl child which says it's implicit class Foo.
Why is that?

Joker
- 19
- 3
0
votes
1 answer
Is there a final Visit method to the Clang RecursiveASTVisitor?
I couldn't find one looking at the API, but essentially I want the following: after all of the Visit* methods, I'd call a final method that does some postprocessing on my data members. I'd assume it'd be something similar to visiting a…

srujzs
- 340
- 3
- 14
0
votes
1 answer
Is it possible LibTooling doesn't change headers?
I have an LibTooling (TimeFlag), which is used to add an flag for every forstmt/whilestmt. And I use ./TimeFlag lalala.cpp -- to insert flags in lalala.cpp
Unfortunately, this tool also will change the headers, even system library.
So is there some…

Aries_Liu
- 95
- 1
- 10
0
votes
1 answer
call graph(.dot) generated by clang libtooling has no node labels
I'm a beginner of clang libtooling.
I'm trying to use clang::CallGraph viewGraph to generate a .dot file of my call graph.
here is the code:
clang::CallGraph mCG;
for (unsigned i = 0 ; i < DeclsSize ; ++i) {
clang::FunctionDecl *FnDecl =…

ignorer
- 327
- 1
- 11
0
votes
1 answer
How to exculde build-in / system function during function analysis by clang libtooling
I'm trying to analyze functions by using clang libtooling.
Here is the source code that I want to analyze:
#include
int main(){
int a = 100;
printf("a==%d", a);
}
when I run my tool to get all the function decl in above files, I…

ignorer
- 327
- 1
- 11
0
votes
0 answers
Clang Source to Source Transformation
I am working on some Clang source-to-source transformation. I am doing it from Clang source code: clang/tools/extra. What I do is that I am adding a printf("Hello World\n"); at the beginning of the main method. It works perfectly, I run my tool as…

Mustakimur Khandaker
- 715
- 6
- 24
0
votes
1 answer
Exception during running custom clang Frontend tool on some input files
I have written a custom clang Frontend tool according to the following link.
http://clang.llvm.org/docs/RAVFrontendAction.html
Now I am giving clang source code itself to my frontend tool for static analysis.
My tool is throwing an exception for…

Hemant
- 767
- 6
- 20
0
votes
1 answer
How to run LibTool?
Currently I have tested my tool with clang-llvm installed on the machine I'm developing it on. All I have to do is go into build/bin to run my tool.
However, I now want to try running this tool on another machine.
What should I be doing here to run…

Jeremy Kuah
- 519
- 1
- 6
- 18
0
votes
1 answer
Skipping statements inside an IfStatements
I have created an if(isa(s)) and if(isa(s)) which prints something if found. I have created this simple c++ codes which contains return statement inside an if statement
#include
int main(int argc, char** argv) {
int…

HiWorld
- 31
- 7
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
Keep my Clang Based tool from analyzing header files in source code?
I'm writing a stand alone tool based on LibTooling with a RecursiveASTVistor, and I don't want to have to go through the contents of header files stored in source code. Do I need to change the compilation database? I've been using this little hack…

Alex
- 1
- 2
0
votes
1 answer
How can I get the name of a statement in Clang LibTooling?
I am playing around with LibTooling: What I want to do is output all the locations of all variables in a source file.
To find all occurences of variables, I overloaded the RecursiveASTVisitor and the method "bool VisitStmt(Stmt)" (see below), but…

Alex H.
- 73
- 1
- 8
0
votes
1 answer
Testing if class is copy constructable using libtooling
I would like to use libtooling to test whether the defined by a CXXRecordDecl is copy constructable.
I have already tried :
hasCopyConstructorWithConstParam()
hasTrivialCopyConstructor() || hasNonTrivialCopyConstructor()
Unfortunately, both of…

Michael Koval
- 8,207
- 5
- 42
- 53
0
votes
1 answer
Run the ClangTool on certain files specified in the command line
I am working with Clang Libtooling. I need to run my clang MyFrontendAction on certain files specified in the command line.
CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
ClangTool Tool(OptionsParser.getCompilations(),…

Awaid Shaheen
- 95
- 1
- 9