FrontendAction output

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

FrontendAction output

Mike Miller
Hi,

I want to have the output of a FrontendAction(specifically an EmitObjAction) piped into a MemoryBuffer, instead of a file. What's the most straightforward way to do this?

Thanks,
Mike

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: FrontendAction output

Mike Miller
Some folks on #llvm helped me with this - the solution is to create a virtual file using FileManager::getVirtualFile, and populate it with the buffer's contents using SourceManager::overrideFileContents, then pass the virtual file to the FrontendAction.

Hope that helps,
Mike

On Fri, May 7, 2010 at 3:30 PM, Mike Miller <[hidden email]> wrote:
Hi,

I want to have the output of a FrontendAction(specifically an EmitObjAction) piped into a MemoryBuffer, instead of a file. What's the most straightforward way to do this?

Thanks,
Mike


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: FrontendAction output

Mike Miller
Whoops, just realized I was replying to the wrong email :). The solution to _THIS_ problem is to modify CodeGenAction to have a setOutputStream method, and to modify CodeGenAction::CreateASTConsumer to construct a BackendAction corresponding to the stream specified by the user(the default, if the user doesn't specify a stream, is the same: a new output file is created).

After this modification, you can just create a stream pointing to a buffer, and set the CodeGenAction to point to that stream.

Not sure that it's the most elegant solution, but it works.

Hope that helps,
Mike

On Mon, May 10, 2010 at 1:49 PM, Mike Miller <[hidden email]> wrote:
Some folks on #llvm helped me with this - the solution is to create a virtual file using FileManager::getVirtualFile, and populate it with the buffer's contents using SourceManager::overrideFileContents, then pass the virtual file to the FrontendAction.

Hope that helps,
Mike

On Fri, May 7, 2010 at 3:30 PM, Mike Miller <[hidden email]> wrote:
Hi,

I want to have the output of a FrontendAction(specifically an EmitObjAction) piped into a MemoryBuffer, instead of a file. What's the most straightforward way to do this?

Thanks,
Mike



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev