[llvm-commits] [PATCH] llvm-c dump IL to file

Hans Wennborg hans at chromium.org
Tue May 8 08:09:16 PDT 2012


On Fri, May 4, 2012 at 7:55 PM, Carlo Kok <ck at remobjects.com> wrote:
> In this patch:
>
> Newly introduced llvm-c function LLVMPrintModuleToFile lets you save the
> textual representation of the LLVM IR to a file.
>
>
>
> Before this patch it could only be printed to STDERR from llvm-c.
>
>
> Thanks,
>
>
> Carlo Kok

Hi Carlo,

Some comments:

> + * Print a representation of a module to a file. The ErrorMessage needs to be disposed with LLVMDisposeMessage.
Lines should be <= 80 columns wide.

> +LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename, char** ErrorMessage);
The * should be on the variable name also for ErrorMessage.

> +LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename, char** ErrorMessage) {
> +  std::string error;
> +  raw_fd_ostream dest(Filename, error);
I think you'll need to check 'error' here (as well as below) to see if
there were problems opening the file.

Thanks,
Hans



More information about the llvm-commits mailing list