[PATCH] D86892: Improve error handling for SmallVector programming errors.

Geoffrey Martin-Noble via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 31 17:25:11 PDT 2020


GMNGeoffrey added inline comments.


================
Comment at: llvm/lib/Support/ErrorHandling.cpp:175
+  (void)::write(2, Reason, strlen(Reason));
+  (void)::write(2, newline, strlen(newline));
   abort();
----------------
MaskRay wrote:
> `(void)::write(2, "\n", 1);`
The way I had it seems more explicit about what's going on here (same reason OOMMessage is a separate variable, I assume). It's obviously easier to count bytes in newline, but seems better to let the compiler do it. I figured the compiler should optimize it to the same thing anyway, but fiddling with godbolt, it seems that's not actually the case. The `char[]` is still allocated. This actually applies to the `OOMMessage` variable too. Switching it to `const char*` (or `auto`, which deduces this) makes the compiled instructions the same, and the source code more explicit, I think. https://godbolt.org/z/q5KzhK


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86892/new/

https://reviews.llvm.org/D86892



More information about the llvm-commits mailing list