[PATCH] D30033: [ELF] - Do not crash when discarding sections that are referenced by others.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 17 00:42:13 PST 2017


grimar added inline comments.


================
Comment at: lld/trunk/ELF/LinkerScript.cpp:282
+    InputSection<ELFT> *IS = dyn_cast<InputSection<ELFT>>(S);
+    if (!IS || IS->DependentSections.empty())
+      continue;
----------------
ruiu wrote:
> You don't need to check if a container is empty before passing it to a for-each-ish function, just like you don't check for emptiness foo before doing `for (auto bar : foo)`.
I know. And even applied that for simplicity in D29273.
But there I do not have cast. Since in this patch I had to do cast and anyways had to check !IS condition, I see nothing wrong in checking empty container to exit early. Code would not became simpler here, early continue still simplifies reading.


Repository:
  rL LLVM

https://reviews.llvm.org/D30033





More information about the llvm-commits mailing list