[cfe-dev] include path to a tool

ogzu rasa via cfe-dev cfe-dev at lists.llvm.org
Sun Jul 29 12:56:46 PDT 2018

I need to add include paths to ClangTool according to my tool input
Below a test code :

> #include "clang/Frontend/FrontendActions.h"
#include "clang/Tooling/CommonOptionsParser.h"
#include "clang/Tooling/Tooling.h"
// Declares llvm::cl::extrahelp.
#include "llvm/Support/CommandLine.h"

using namespace clang::tooling;
using namespace llvm;

static llvm::cl::OptionCategory MyToolCategory("my-tool options");

int main(int argc , char** argv) {
int argc_ = 5;
const char **argv_ = new const char*[5];
std::vector<std::string> Sources;
argv_[0] = argv[0];
argv_[1] = &Sources[0][0];
argv_[2] = "--";
argv_[3] = "c++";
argv_[4] = "-I\"path\\to\\external\\lib\\directory\"";
CommonOptionsParser OptionsParser(argc_, argv_, MyToolCategory);
// run the Clang Tool, creating a new FrontendAction (explained below)

ClangTool Tool(OptionsParser.getCompilations(), Sources);
int result =

return result;

ClangTool returns the compilation error : "my_include.h file not found".
I've tried with insert commands via appendArgumentsAdjuster but always the
same error.

Can someone help please ?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180729/62c24614/attachment.html>

More information about the cfe-dev mailing list