<html><head></head><body><div dir="auto">I've realized now that the vector is not a Small String equivalent but is a vector of separate char pointers (argv).<br></div>
<div dir="auto">Still, for some reason executing an EmitLLVMOnlyAction from a clang tool seems to fail for some reason.<br><br></div>
<div dir="auto">Lldb always exits in CommandLineParser::ParseCommandLineOptions (lib/Support/CommandLine.cpp)<br></div>
<div dir="auto">Line 1088 (clang 6.0.1):<br><br></div>
<div dir="auto">'Program Name = sys::path::filename(StringRef(argv[0]));' <br><br></div>
<div dir="auto">The error... <br><br></div>
<div dir="auto">'Clang: Not enough positional command line arguments specified!' <br><br></div>
<div dir="auto">...makes no sense at this particular line.<br><br></div>
<div dir="auto">The only usage of EmitLLVMOnlyAction in the llvm/clang repos seems to be in the clang-interpreter example and for some reason it works there.<br><br></div>
<div dir="auto">Is there some setup missing or present in the ClangTool that screws something up?<br><br></div>
<div dir="auto"><a href="http://gist.github.com/MaliusArth/876db831fca43288bfa6fb78ab6921df">gist.github.com/MaliusArth/876db831fca43288bfa6fb78ab6921df</a><br><br></div>
<div dir="auto">Cheers,<br></div>
<div dir="auto">Viktor</div>
<div class="gmail_quote" >On Apr 30, 2019, at 03:33, Viktor Was BSc via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div dir="auto">When trying to run an EmitLLVMOnlyAction via ClangTool::run(act_factory) I get the following error:<br></div>
<div dir="auto">Clang: Not enough positional command line arguments specified!<br><br></div>
<div dir="auto">Stepping through the code I found that there seems to be a problem in setCommandLineOpts in clang/lib/CodeGen/BackendUtils.cpp, the BackendArgs.push_back with literals doesn't seem to work and a corrupt SmallVector is passed to ParseCommandLineOptions.<br></div>
<div dir="auto">Why is setCommandLineOpts even called, isn't EmitLLVMOnlyAction supposed to create llvm::Module in memory only without without outputting it to a file? Did I misinterpret the Emit_Nothing flag? What does EmitLLVMOnlyAction do?<br></div>
<div dir="auto">What command line args does EmitLLVMOnlyAction expect?<br><br></div>
<div dir="auto">Cmd line: mytool test.cpp -p=compile_commands.json<br><br></div>
<div dir="auto">Compile_commands:<br></div>
<div dir="auto">{<br></div>
<div dir="auto">"directory":"path/to/build",<br></div>
<div dir="auto">"command": "/usr/local/bin/clang++ -Ipath/to/include - std=c++11 -Wall -o path/to/test.cpp.o -c /path/to/test.cpp",<br></div>
<div dir="auto">"file": "/path/to/test.cpp"<br></div>
<div dir="auto">}<br><br></div>
<div dir="auto">Thanks, <br></div>
<div dir="auto">Viktor<br></div>
<pre class="blue"><hr><br>cfe-dev mailing list<br>cfe-dev@lists.llvm.org<br><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br></pre></blockquote></div></body></html>