[PATCH] D47327: Check that memory allocation succeeds before use.

Sanjoy Das via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 24 13:39:59 PDT 2018


sanjoy added a comment.

In https://reviews.llvm.org/D47327#1111520, @trixirt wrote:

> As llvm is mostly an api, i assumed that it would be robust and this was a one-off.
>  Anything big should be done automagically, so i am going to look at sic-ing clang-tidy and/or the static analyzer at this problem.


Before spending time on this, I'd suggest asking on llvm-dev@ about whether we _should_ make LLVM robust against allocation failures.  I believe (but you should still ask) the consensus will be that it isn't worth the engineering complexity to make LLVM as a library robust against allocation failures, and that if you do want this, the right fix is to fork out to LLVM as a separate process.

> The lack of exception handling i can understand for performance reasons but it does put normal use of the std library in a bind if like this case the default uses exceptions.
> 
> It would be nice if there was project wide design on how to handle exceptions/errors.
>  If there is please point me at it.

https://llvm.org/docs/CodingStandards.html#do-not-use-rtti-or-exceptions


Repository:
  rL LLVM

https://reviews.llvm.org/D47327





More information about the llvm-commits mailing list