<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 11, 2014 at 6:23 PM, Rafael Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: rafael<br>
Date: Tue Nov 11 20:23:37 2014<br>
New Revision: 221756<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=221756&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=221756&view=rev</a><br>
Log:<br>
Use a function_ref now that it works (r221753). </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
Modified:<br>
    llvm/trunk/include/llvm/Linker/Linker.h<br>
<br>
Modified: llvm/trunk/include/llvm/Linker/Linker.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Linker/Linker.h?rev=221756&r1=221755&r2=221756&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Linker/Linker.h?rev=221756&r1=221755&r2=221756&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Linker/Linker.h (original)<br>
+++ llvm/trunk/include/llvm/Linker/Linker.h Tue Nov 11 20:23:37 2014<br>
@@ -11,8 +11,8 @@<br>
 #define LLVM_LINKER_LINKER_H<br>
<br>
 #include "llvm/ADT/SmallPtrSet.h"<br>
+#include "llvm/ADT/STLExtras.h"<br>
<br>
-#include <functional><br>
<br>
 namespace llvm {<br>
 class DiagnosticInfo;<br>
@@ -25,7 +25,7 @@ class StructType;<br>
 /// something with it after the linking.<br>
 class Linker {<br>
   public:<br>
-    typedef std::function<void(const DiagnosticInfo &)><br>
+    typedef function_ref<void(const DiagnosticInfo &)><br>
         DiagnosticHandlerFunction;<br></blockquote><div><br>I think this usage is wrong, unfortunately.<br><br>I haven't managed to look at all the Linker code, but at least looking at "<span style="color:rgb(0,0,0)">Linker::Linker(Module *M)" this seems as if it'll have problems.<br></span><br>That ctor initializes the member function_ref with a lambda. That' means the function_ref will point to the lambda (unlike std::function which would copy the lambda into itself) - but once the variable's initializer in the ctor finishes, the lambda will be destroyed, leaving the function_ref dangling, I think?<br><br>Any other caller that does something like:<br><br>Linken L([] { ... });<br>L.functionThatUsesTheMemberFunctionRef();<br><br>Will be equally problematic - as the lambda will be destroyed at the end of the Linker variable's initialization, and the member function_ref will be left dangling.<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
     Linker(Module *M, DiagnosticHandlerFunction DiagnosticHandler);<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>