Questions tagged [clang-plugin]

Questions regarding Clang Plugins

Clang Plugins extend the Clang compiler

Clang Plugins make it possible to run extra user defined actions during a compilation

Wiki: https://wiki.documentfoundation.org/Development/Clang_plugins

Docs: https://clang.llvm.org/docs/ClangPlugins.html

10 questions
6
votes
1 answer

clang plugin: modify AST during compilation

I'm developing a clang plugin for externalising log-strings (in order to reduce the binary size for an embedded project), which needs to modify the AST (so after preprocessor, before compilation). Currently, I'm successfully able to match the nodes…
Mark K Cowan
  • 1,755
  • 1
  • 20
  • 28
3
votes
1 answer

Ensure every string literal is wrapped inside macro

I want to wrap every string literal in my project with a macro. I want to make sure every string literal in my project is wrapped with a macro, and have some external tool help provide me the location in which there's a string literal not wrapped in…
Curve25519
  • 654
  • 5
  • 17
2
votes
0 answers

Add deprecated tag to declaration using a Clang Plugin

I have a sample file with a function declaration that I want to deprecate. I want to add this C++ tag to make the compiler emit warnings when this function is being called like this one: ...simple_test.cpp:45:5: warning: 'free_fun' is deprecated…
1
vote
0 answers

use-after-poison error on libtooling example

When testing libtooling example(https://clang.llvm.org/docs/RAVFrontendAction.html) of clang with address-sanitizer, I've encountered use-after-poison error. I've used following source codes and instructions to test it. I'm using prebuilt version of…
1
vote
1 answer

How can I bypass dependency builds while building my clang plugin?

Is it possible to build a clang plugin using an already built version of clang? I've done all the steps to download and build clang but I don't know how to set up a tool so that the Makefile doesn't traverse the entire llvm and clang directories…
Gregory
  • 1,205
  • 10
  • 17
1
vote
1 answer

In a clang plugin, how do you see whether there was an error compiling the translation unit?

I want my clang plugin to not actually do anything if there was an error compiling the code for the AST my plugin is going to run on. However, I can't figure out what object contains the list of errors generated during compilation. Is there…
xaxxon
  • 19,189
  • 5
  • 50
  • 80
0
votes
0 answers

compiling a clang plugin

I'm trying to learn how to use clang plugins. When I used the example code for a plugin and tried to compile it using Makefile (I prefer it better than cmake) it compiled fine but in linking stage it says that it could not find the clang libraries…
0
votes
0 answers

Clang plugin to print function call locations

Here is a minimal Clang plugin to print location of function calls. I have a RecursiveASTVisitor visitor named FuncCallVisitor that is initialized with an ASTContext and tries to print the source location of the CallExpr. #include…
Xlv
  • 53
  • 1
  • 6
0
votes
2 answers

How to build and run a Clang plugin in windows

I have cloned the llvm-project repository. Then I have generated a Visual Studio solution for the project using cmake -G "Visual Studio 16" -DLLVM_ENABLE_PROJECTS="clang;lld" -DLLVM_EXPORT_SYMBOLS_FOR_PLUGINS=ON -DLLVM_TARGETS_TO_BUILD=X86…
Lambda
  • 133
  • 1
  • 13
0
votes
0 answers

Is it possible to write a CLang plugin to warn on usage of RAW pointers?

Need to stop(or minimize) usage of raw C/C++ pointers in our source base (i.e. instead other options like references or smart pointers should be used). Is it possible to write a CLang plugin to warn on use of Raw pointers (as local/global/member…
aKumara
  • 395
  • 1
  • 12