Ann R.
Ann R.

Reputation: 85

How do I pass an Argument to a Clang Plugin?

Seeing the existence of clang::FrontendOptions::PluginArgs I would think it is possible. But I've failed to find any documentation on exactly how to pass arguments to a plugin via command line.

I've tried preceding an argument with -Xclang, I've tried combining my plugin with the arguments (e.g., "test-plugin args"), and I've attempted to scour the internet. Anyone know the answer?

Upvotes: 2

Views: 3077

Answers (2)

Ramin Halavati
Ramin Halavati

Reputation: 107

You can use -Xclang if you are using clang++ and passing these parameters to clang:

clang++ -Xclang -load -Xclang ~/Path/to/your/library -Xclang -plugin -Xclang your-library-name -Xclang -plugin-arg-your-library-name -Xclang help

Upvotes: 3

Croustibaie
Croustibaie

Reputation: 66

To give arguments to a plugin, you should use the -plugin-arg-your-plugin command. For example, if your plugin's name is test-plugin and you want to give it the argument "help", the command would be :

clang -cc1 -load ~/Path/to/your/clang/library -plugin test-plugin -plugin-arg-test-plugin help

Hope it will help

Upvotes: 5

Related Questions