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

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 31 13:01:06 PDT 2020


MaskRay added inline comments.


================
Comment at: llvm/lib/Support/ErrorHandling.cpp:172
   char OOMMessage[] = "LLVM ERROR: out of memory\n";
   ssize_t written = ::write(2, OOMMessage, strlen(OOMMessage));
+  written = ::write(2, Reason, strlen(Reason));
----------------
If the return value is to be ignored, the variable can be removed, i.e. `(void)::write(...)`


================
Comment at: llvm/lib/Support/SmallVector.cpp:52
   if (MinCapacity > SizeTypeMax())
-    report_bad_alloc_error("SmallVector capacity overflow during allocation");
+    report_fatal_error("SmallVector unable to grow. Requested capacity (" +
+                       std::to_string(MinCapacity) +
----------------
This can continue to use `report_bad_alloc_error` for a bit more context


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