Hi,<div><br></div><div>I'm currently using the following code(excerpted) to execute a FrontendAction(an EmitObjAction specifically) on source code contained in a MemoryBuffer:</div><div><br></div><div><div>llvm::MemoryBuffer* Buffer = llvm::MemoryBuffer::getMemBuffer(Source);</div>
<div>SourceManager& SM = Clang.getSourceManager();</div><div>FileID MainFileID = SM.createMainFileIDForMemBuffer(Buffer);</div><div><br></div><div>EmitObjAction E;</div><div>E.setCompilerInstance(&Clang);</div><div>
E.Execute();</div></div><div><br></div><div>The code fails at "E.Execute()" with:</div><div><br></div><div><div>Assertion failed: (!CurrentFile.empty() && "No current file!"), function isCurrentFileAST, file /Volumes/Data/Users/mike/llvm/tools/clang/lib/Frontend/../../include/clang/Frontend/FrontendAction.h, line 95.</div>
</div><div><br></div><div><br></div><div>I looked up the FrontendAction::setCurrentFile method, but it takes in a StringRef to a path. Since I don't have a path to a file, as I'm only operating on source code in memory, I'm not able to set the current file.</div>
<div><br></div><div>How can I set the current file to point to a MemoryBuffer?</div><div><br></div><div>Thanks!</div><div>Mike</div>