[cfe-dev] Automating Clang Tool (with CommonOptionsParser)
Sunny Billava via cfe-dev
cfe-dev at lists.llvm.org
Wed Dec 7 10:01:39 PST 2016
Thanks Alex!!
This worked! : ) Awesome.
Regards,
Sunny. R. Billava
From: Alex L [mailto:arphaman at gmail.com]
Sent: Wednesday, December 7, 2016 7:36 PM
To: Sunny Billava <Sunny.Billava at kpit.com>
Cc: cfe-dev at lists.llvm.org
Subject: Re: [cfe-dev] Automating Clang Tool (with CommonOptionsParser)
On 7 December 2016 at 13:52, Sunny Billava via cfe-dev <cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>> wrote:
Hello All,
We want to create a tool (in C# .NET, EXE) which invokes the clang tool (C++, DLL). While implementing we realized that the CommonOptionsParser only expects the call to the Clang tool to be in the form of command line options. Is there a way around this issue that someone has encountered earlier?
On the other hand, if I pass the c code as a string buffer to the tooling, the included .h files are not recognized by clang tooling. So somehow Common Options Parser was the choice.
int main(int argc, const char **argv) {
CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
ClangTool Tool(OptionsParser.getCompilations(),OptionsParser.getSourcePathList());
int result = Tool.run(newFrontendActionFactory<DFAMainClassAction>().get());
return result;
}
Any help would be greatly appreciated ☺
I think that you can use pass the arguments as an array of strings to your DLL and create the tool using the FixedCompilationDatabase, like in the example below:
std::vector<std::string> CommandLineArguments = { "-I", "includes" }; // Get the arguments
// Create the tool
std::unique_ptr<CompilationDatabase> Compilations(new FixedCompilationDatabase(".", CommandLineArguments));
ClangTool Tool(*Compilations, Filename);
Regards,
Sunny. R. Billava
This message contains information that may be privileged or confidential and is the property of the KPIT Technologies Ltd. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. KPIT Technologies Ltd. does not accept any liability for virus infected mails.
_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
This message contains information that may be privileged or confidential and is the property of the KPIT Technologies Ltd. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. KPIT Technologies Ltd. does not accept any liability for virus infected mails.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161207/caa8b481/attachment.html>
More information about the cfe-dev
mailing list