[llvm] r286177 - [LTO] Add error message on IO error in compileOptimizedToFile.

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 8 07:13:25 PST 2016


On Tue, Nov 8, 2016 at 3:30 AM, Rafael EspĂ­ndola via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> emitError takes a twine and I don't think it is safe to have a twine
> variable. Could this be just:
>
> emitError(Twine("could not write object file: ") + Filename);
>

Right, this isn't safe. Per Twine.h:
  /// A Twine is not intended for use directly and should not be stored, its
  /// implementation relies on the ability to store pointers to temporary
stack
  /// objects which may be deallocated at the end of a statement. Twines
should
  /// only be used accepted as const references in arguments, when an API
wishes
  /// to accept possibly-concatenated strings.

Please change to Rafael's suggestion.

Thanks!
Teresa


> Cheers,
> Rafael
>
>
> On 7 November 2016 at 18:43, Eli Friedman via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
> > Author: efriedma
> > Date: Mon Nov  7 17:43:07 2016
> > New Revision: 286177
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=286177&view=rev
> > Log:
> > [LTO] Add error message on IO error in compileOptimizedToFile.
> >
> > (No testcase because it's difficult to force an error here.)
> >
> > Differential Revision: https://reviews.llvm.org/D26371
> >
> >
> > Modified:
> >     llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
> >
> > Modified: llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
> > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOCo
> deGenerator.cpp?rev=286177&r1=286176&r2=286177&view=diff
> > ============================================================
> ==================
> > --- llvm/trunk/lib/LTO/LTOCodeGenerator.cpp (original)
> > +++ llvm/trunk/lib/LTO/LTOCodeGenerator.cpp Mon Nov  7 17:43:07 2016
> > @@ -257,6 +257,8 @@ bool LTOCodeGenerator::compileOptimizedT
> >    bool genResult = compileOptimized(&objFile.os());
> >    objFile.os().close();
> >    if (objFile.os().has_error()) {
> > +    Twine ErrMsg = "could not write object file: " + Filename.str();
> > +    emitError(ErrMsg.str());
> >      objFile.os().clear_error();
> >      sys::fs::remove(Twine(Filename));
> >      return false;
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>



-- 
Teresa Johnson |  Software Engineer |  tejohnson at google.com |  408-460-2413
<(408)%20460-2413>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161108/417a47dc/attachment.html>


More information about the llvm-commits mailing list