Questions tagged [libtooling]

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

152 questions
1
vote
1 answer

How to get ASTContext from an Expr in Clang LibTooling?

For Decl, there is getASTContext(), but being AST node as Decl, why doesn't Expr have the function like that and how to get ASTContext from an Expr? Note: Decl is https://clang.llvm.org/doxygen/classclang_1_1Decl.html, Expr is…
jw_
  • 1,663
  • 18
  • 32
1
vote
1 answer

Use Clang LibTooling to scan C++ source that has call to local class in a templated parent class

Source code to scan: template class HB { T m; public: void HBfunc1(); }; template void HB::HBfunc1() { class HC { public: void HCfunc2() { }; }; HC().HCfunc2(); } void…
jw_
  • 1,663
  • 18
  • 32
1
vote
0 answers

How to write our own DiagnosticConsumer in clang libtooling?

I want to capture the source files error and warnings when I give it as a input to my libtooling tool. For example consider the program main.c int main() { printf("hello"); return 0; } so clang throws warning implicitly declaring library…
Jon marsh
  • 279
  • 7
  • 12
1
vote
1 answer

How to get all the function names where the global variables are used?

I am working on libtooling with clang. I have developed a tools to find the global variables and where those global variables are referred. Now, i want to get the function name which uses those Global variables. Here is the Sample Code int Var; int…
1
vote
1 answer

Print a fully qualified type of a parameter (ParmVarDecl) or a field (FieldDecl) with clang Libtooling API

Similar to this question: Print the type of a parameter (ParmVarDecl) with clang API, I want to get parameter/field type as a string, but importantly I want the type to be fully qualified, e.g. for namespace n { class A {}; class B { void…
Victor K
  • 529
  • 2
  • 16
1
vote
0 answers

Error in Parsing functions Calling Conventions using Libtooling ASTFrontendAction

I'm using Libtooling to parse Windows SDK headers but there is a problem in getting functions calling conventions, The libtooling always return __cdell for WINAPI or __stdcall calling convention which is the defualt calling convention of Win32…
1
vote
1 answer

How to print fully qualified Expr in clang?

I'm working on my reflection tool with clang 8.0.1. And right now I need to print Expr with all names fully qualified. I already tried builtin prettyPrint function with FullyQualifiedName bit set to true. But it still gives incorrect result. For…
VioletOil
  • 63
  • 5
1
vote
0 answers

Clang tool SIGBUS on multiple files using a clang::rewriter

I want to run some source to source transformation using clang. Instead of using the commonoptions for input Im using a JSONCompilationDatabase. It runs fine for a single file but it receives a SIGBUS when run on multiple files and specifically…
EvanKaraf
  • 11
  • 1
1
vote
0 answers

Is it possible to run custom clang tool on a translation unit and compile it at the same time?

As I stated in the title. I want to run custom clang tool on the translation unit while the compilation process is running. I want to take over this translation process and do a static analysis when it runs. I know that it is possible to perform…
fskoras
  • 68
  • 7
1
vote
1 answer

Error when parsing system headers with RecursiveASTVisitor

I am building a standalone tool with libtooling. I have a basic boilerplate code for a FrontendAction, Consumer and a Visitor. The visitor only visits ClassTemplateSpecializationDecl where I just save some information. Everything works fine, but if…
Bako
  • 313
  • 1
  • 15
1
vote
1 answer

Get AST Nodes of objective-C class without resolving dependencies

I am trying to create a refactoring tool that would allow me to get a syntax tree from an objective-c class so that I can change the structure of the class and output a different version of it that matches my criteria. I am looking at Clang's…
1
vote
1 answer

clang tool : include path

I would like to change my clang tool's include path according to input. When I run the below code on a sample test file I have a compilation error "header not found". #include "clang/Frontend/FrontendActions.h" #include…
ogzu rasa
  • 31
  • 5
1
vote
0 answers

Clang libtooling with MatchFinder

I'm beginner with libtooling, I try to learn with easy c++ code. I try to parse/print typedef expression like below lines: namespace DEBUG { typedef void(*function_pointer_t)(int&); typedef int myInt; } clang++ -Xclang -ast-dump…
ogzu rasa
  • 31
  • 5
1
vote
1 answer

Reparse an ASTUnit with relative header include paths fails

I'm using libclang's LibTooling to get code completion data from C++ source files. The ASTUnits are generated from a compile_commands.json file created via CMake with Ninja as the generator. In the compiler invocation commands, there are relative…
1
vote
0 answers

Segmentation fault (core dumped) when running clang libtooling

I implemented a simple refactoring tool which can replace a function name to a user-specific name. When I run the tool over the test code (without any header files), it works well. However, if I include a header files in the test code, e.g. #include…
ignorer
  • 327
  • 1
  • 11