[PATCH] D22811: [ELF] Linkerscript: allow setting custom output section for common symbols, instead of .bss

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 27 07:13:44 PDT 2016


grimar added inline comments.

================
Comment at: ELF/LinkerScript.cpp:111
@@ +110,3 @@
+
+  if (llvm::find(Patterns, "COMMON") && Common->getSize())
+    Ret.push_back(Common);
----------------
evgeny777 wrote:
> grimar wrote:
> > llvm::find(Patterns, "COMMON") returns iterator. Condition is always true,
> > for cases when Patterns does not contain COMMON it is equal to
> > 
> > ```
> > if (Patterns.end() && ... )
> > ```
> > You probably want to update testcase also.
> I think you're not right. This is ArrayRef<T>, which iterator is a pointer to element. This means that if pointer is nullptr then there is no such element in the array. If you try to do this with STL container, for example std::vector you'll get compilation error, because STL iterator does not define operator bool().
Right, I missed that it is ArrayRef, but it is even simpler than:
you are searching pointer among pointers, it will always return true
since when find return end() it will be some non-zero pointer.


https://reviews.llvm.org/D22811





More information about the llvm-commits mailing list