[llvm-commits] [PATCH] llvm-c dump IL to file
Carlo Kok
ck at remobjects.com
Tue May 8 12:51:12 PDT 2012
Op 8-5-2012 18:47, Jim Grosbach schreef:
>
> On May 8, 2012, at 8:23 AM, Carlo Kok<ck at remobjects.com> wrote:
>
>> Op 5/8/2012 5:09 PM, Hans Wennborg schreef:
>>> 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.
>>>>
>>>
>>> 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.
>>
>> Hi Thomas,
>>
>> Thanks. All changes are applied in attached updated patch.
>>
>
> Hi Carlo,
>
> One other style nit; '*' binds to the identifier in a declaration.
> That is, use "char *foo", not "char* foo".
Indeed that was a mistake, I fixed that in the last patch.
>
> I'd prefer to something w/ move semantics for the error string to
> avoid the strdup(), but I don't know if we have an interface
> available for that sort of thing available. Since it's on the error
> path, I don't see that as blocking this going in, just a thought to
> consider.
This copy pattern is used pretty much through all of llvm-c. The caller
would then have to call LLVMDisposeMessage to get rid of the memory.
More information about the llvm-commits
mailing list