Questions tagged [libtooling]

LibTooling is a library to support writing standalone tools based on Clang.

152 questions
1
vote
0 answers

How to extract types and names from CXXMemberCallExpr?

I would like to extract the types and names of the entire caller object and parameter types of member call expressions made from the A::WriteData method definition. class ostream { public: void write(char* c, unsigned int i) { } }; struct…
kushaldsouza
  • 710
  • 5
  • 12
  • 36
1
vote
1 answer

Clang tooling, check if final or override

Is there a "clang way" to check if CXXMethodDecl is specified with override or final keywords? I can check it by std::string::find(" override") for the string representing CXXMethodDecl, but this way looks a little ugly.
Yuriy
  • 701
  • 4
  • 18
1
vote
0 answers

Clang AST differentiate between implicit int and invalid type

I am working on clang lib-tooling project using clang and front-end and RecursiveASTVisitor. for the following code (from llvm-clang test) // RUN: %clang_cc1 -fsyntax-only %s -verify -pedantic foo() { // expected-warning {{type specifier missing,…
Hemant
  • 767
  • 6
  • 20
1
vote
0 answers

"auto" type not deduced in clang libtooling 3.8.1

I am using clang 3.8.1 libtooling library. I have written visitor for c++ auto types. When I try to get the deduced type I get NULL-TYPE. Did anybody face a similar issue? Please enlighten me on auto type deduction in clang as it is leading me…
Hemant
  • 767
  • 6
  • 20
1
vote
1 answer

clang ast visitor for single line multiple variable declaration

I am new to Clang libTooling development. consider the following variable declaration int i, j, k = 10; ^ ^ For my project requirement, I want to capture the whole declaration expression including "i", "j" and "k". How to capture the…
Hemant
  • 767
  • 6
  • 20
1
vote
0 answers

Match Objective-C object pointer type with nullability specificator in Clang's LibTooling

Lets say I have such code: A* a = [[A alloc] init]; B* _Null_unspecified b = [[B alloc] init]; C* _Nullable c = [[C alloc] init]; D* _Nonnull d = [[D alloc] init]; Now, I want to create a matcher to match variables declaration. Currently I have…
Alfred Zien
  • 1,025
  • 1
  • 11
  • 31
1
vote
1 answer

How to check if a Decl is inside a scope of #if directive?

i am building a clang libtool, how can i get the preprocessor information that will tell me if a given Decl is inside a scope of #if #ifdef #ifndef ?
gregOS
  • 21
  • 2
1
vote
1 answer

Traverse specific parts of AST Tree

I have dump the AST Tree of a simple C++ codes. Is it possible to only visit the nodes selected and ignore everything else including the children using libTooling or ASTMatchers?
HiWorld
  • 31
  • 7
1
vote
2 answers

Why is the source location end off by two characters for a statement ending in a semicolon?

I'm trying to write a source to source translator using libTooling. I'm using ASTMatchers to try to find if statements that don't have curly braces and then use a rewriter to add the braces. The matcher I'm using…
Farzad Sadeghi
  • 105
  • 2
  • 10
1
vote
0 answers

Get full source of multiple macro definitions using clang libtooling

Ultimately I'm trying to pull out relevant structures from thousands of existing c and c++ header files. I've been able to use libtooling to pull out a structure and all of the structures/enums/typedefs etc it relies on from various different…
john
  • 239
  • 3
  • 14
1
vote
1 answer

How can I make the LLVM IR of a function available to my program?

I'm working on a library which I'd like certain introspection features to be available. Let's say I'm compiling with clang, so I have access to libtooling or whatever. What I'd like specifically is for someone to be able to view the LLVM IR of an…
user2333829
  • 1,301
  • 1
  • 15
  • 25
1
vote
1 answer

CLang LibTooling handling function Template arguments

I want to handle template arguments diffrently so for the code: template class A { public: A() {} }; void faa(A& param); I would like to know that param is a template specialisation and get access it's parameters. So I wrote…
MarcinG
  • 840
  • 6
  • 21
1
vote
1 answer

How to print a line on Terminal Using Clang Libtooling?

I am relatively new to CLang and Libtooling. I want to display a Line from the source code on the terminal. I have a *VisitFunctionDecl(FunctionDecl func) in the RecursiveASTVisitor. For every function I get the SourceRange and from that the…
Awaid Shaheen
  • 95
  • 1
  • 9
1
vote
0 answers

get live variables in a refactoring tool

I'm writing a refactoring tool with clang libtooling. What I need is to rewrite source code according to live variable information. For example, for each basic block in a function, dump its live-out variables. I know it would be quite easily if I'm…
0
votes
0 answers

using libClang or libTooling to list function declarations

I am developing a windows C++ tool to analyze and mutate C code. I need help to use libClang or preferably libTooling get a list of C function declarations from a source tree of C files (translation units) with their headers. Eventually, I would…
johnco3
  • 2,401
  • 4
  • 35
  • 67