<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 7 December 2016 at 13:52, Sunny Billava via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">





<div lang="EN-US">
<div class="gmail-m_6760364092021031016WordSection1">
<p class="MsoNormal"><span style="font-size:10pt;color:rgb(64,64,64)">Hello All,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;color:rgb(64,64,64)">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?
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;color:rgb(64,64,64)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;color:rgb(64,64,64)">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.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:consolas;color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:consolas;color:blue">int</span><span style="font-size:9.5pt;font-family:consolas;color:black"> main(</span><span style="font-size:9.5pt;font-family:consolas;color:blue">int</span><span style="font-size:9.5pt;font-family:consolas;color:black">
</span><span style="font-size:9.5pt;font-family:consolas;color:gray">argc</span><span style="font-size:9.5pt;font-family:consolas;color:black">,
</span><span style="font-size:9.5pt;font-family:consolas;color:blue">const</span><span style="font-size:9.5pt;font-family:consolas;color:black">
</span><span style="font-size:9.5pt;font-family:consolas;color:blue">char</span><span style="font-size:9.5pt;font-family:consolas;color:black"> **</span><span style="font-size:9.5pt;font-family:consolas;color:gray">argv</span><span style="font-size:9.5pt;font-family:consolas;color:black">)
 {<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:consolas;color:black">      
<u></u><u></u></span></p>
<p class="MsoNormal" style="text-indent:0.5in"><span style="font-size:9.5pt;font-family:consolas;color:rgb(43,145,175)">CommonOptionsParser</span><span style="font-size:9.5pt;font-family:consolas;color:black"> OptionsParser(</span><span style="font-size:9.5pt;font-family:consolas;color:gray">argc</span><span style="font-size:9.5pt;font-family:consolas;color:black">,
</span><span style="font-size:9.5pt;font-family:consolas;color:gray">argv</span><span style="font-size:9.5pt;font-family:consolas;color:black">, MyToolCategory);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:consolas;color:black">      
</span><span style="font-size:9.5pt;font-family:consolas;color:rgb(43,145,175)">ClangTool</span><span style="font-size:9.5pt;font-family:consolas;color:black"> Tool(OptionsParser.<wbr>getCompilations(),<wbr>OptionsParser.<wbr>getSourcePathList());<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:consolas;color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:consolas;color:black">      
</span><span style="font-size:9.5pt;font-family:consolas;color:blue">int</span><span style="font-size:9.5pt;font-family:consolas;color:black"> result = Tool.run(<wbr>newFrontendActionFactory<</span><span style="font-size:9.5pt;font-family:consolas;color:rgb(43,145,175)">DFAMa<wbr>inClassAction</span><span style="font-size:9.5pt;font-family:consolas;color:black">>().get());      <wbr>      
</span><span style="font-size:9.5pt;font-family:consolas;color:blue"><u></u><u></u></span></p>
<p class="MsoNormal" style="text-indent:0.5in"><span style="font-size:9.5pt;font-family:consolas;color:blue">return</span><span style="font-size:9.5pt;font-family:consolas;color:black"> result;<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:consolas;color:black">}</span><span style="font-size:10pt;color:rgb(64,64,64)"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;color:rgb(64,64,64)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;color:rgb(64,64,64)">Any help would be greatly appreciated
</span><span style="font-size:10pt;font-family:wingdings;color:rgb(64,64,64)">J</span></p></div></div></blockquote><div><br></div><div>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:</div><div><br></div><div>   std::vector<std::string> CommandLineArguments = { "-I", "includes" }; // Get the arguments</div><div>   // Create the tool</div><div>   std::unique_ptr<CompilationDatabase> Compilations(new FixedCompilationDatabase(".", CommandLineArguments));</div><div>   ClangTool Tool(*Compilations, Filename);</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div lang="EN-US"><div class="gmail-m_6760364092021031016WordSection1"><p class="MsoNormal"><span style="font-size:10pt;color:rgb(64,64,64)"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:'segoe ui',sans-serif;color:gray"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:'segoe ui',sans-serif;color:gray">Regards,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:'segoe ui',sans-serif;color:gray">Sunny. R. Billava</span><span style="font-size:4pt;font-family:'segoe ui',sans-serif;color:gray"><u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
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.
</div>

<br>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>