<div dir="ltr"><div class="gmail_default"><font face="arial, helvetica, sans-serif">Probably you can `grep -r "EnterTokenStream" lib/*` to see how pass unique_ptr to</font><br></div><div class="gmail_default"><font face="arial, helvetica, sans-serif">EnterTokenStream. Seem you need to use std::move.</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif">HTH,</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif">chenwj</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"><br></font></div>







</div><div class="gmail_extra"><br><div class="gmail_quote">2017-06-15 0:43 GMT+08:00 Masoud Ataei via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello all,<div><br></div><div>I have the following lines of code. To run it, I need to change the rule of the function "EnterTokenStream" from private to a public function in "/usr/local/include/clang/<wbr>Lex/Preprocessor.h". In this case this code will working with raw pointer "*Toks".</div><div><div>------------------------------<wbr>------</div><div>PP.Lex(Tok);<br></div><div><div>SmallVector<Token, 4> Pragma;<br></div><div>Pragma.push_back(Tok);</div><div><br></div><div>Token *Toks = new Token[Pragma.size()];</div><div>std::copy(Pragma.begin(), Pragma.end(), Toks);</div><div>PP.EnterTokenStream(Toks, Pragma.size(), true, true);</div></div><div>------------------------------<wbr>------------------------------<wbr>--</div><div><br></div><div>But default rule for the function "EnterTokenStream" is private. So I cannot call this function, and I should call this one:</div><div>------------------------------<wbr>---------------</div><div>void EnterTokenStream(std::unique_<wbr>ptr<Token[]> Toks, unsigned NumToks, bool DisableMacroExpansion)</div><div>------------------------------<wbr>---------------</div><div><br></div><div><br></div><div>First argument of this function needs  "std::unique_ptr<Token[]> Toks". So I have tried to define Toks as a unique pointer. I did like this:</div><div>------------------------------<wbr>--------------</div><div><div>PP.Lex(Tok);<br></div><div><div>SmallVector<Token, 4> Pragma;<br></div><div>Pragma.push_back(Tok);</div><div><br></div><div>unique_ptr<Token[]> Toks(new Token[Pragma.size()]);</div><div>std::copy(Pragma.begin(), Pragma.end(), Toks);</div><div>PP.EnterTokenStream(Toks, Pragma.size(), true);</div></div></div><div>------------------------------<wbr>------------------</div><div><br></div><div>but it gives me the following error for std::copy:</div><div>------------------------------<wbr>---------------</div><div><div> error: use of deleted function ‘std::unique_ptr<_Tp [], _Dp>::unique_ptr(const std::unique_ptr<_Tp [], _Dp>&) [with _Tp = clang::Token; _Dp = std::default_delete<clang::<wbr>Token []>]’</div><div>    std::copy(Pragma.begin(), Pragma.end(), Toks);</div></div><div>------------------------------<wbr>----------------------------</div><div><br></div><div>and the same error for EnterTokenStream:</div><div>------------------------------<wbr>------------------------</div><div><div>error: use of deleted function ‘std::unique_ptr<_Tp [], _Dp>::unique_ptr(const std::unique_ptr<_Tp [], _Dp>&) [with _Tp = clang::Token; _Dp = std::default_delete<clang::<wbr>Token []>]’</div><div>    PP.EnterTokenStream(Toks, Pragma.size(), true);</div></div><div>------------------------------<wbr>------------------------------</div><div><br></div><div>Can anyone help me how to fix this errors? How can I change my original code to something that I can use the new EnterTokenStream function?</div><div><br></div><div>Thank you.</div><span class="HOEnZb"><font color="#888888"><div><br>-- </div><div class="m_-5040403231299086829gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div>------<br>----------<br>Masoud Ataei (Mr.)<br><div><div><br></div></div></div></div></div></div></div></div></div></div></div></div>
</font></span></div></div>
<br>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Wei-Ren Chen (陳韋任)<br>Homepage: <a href="https://people.cs.nctu.edu.tw/~chenwj" target="_blank">https://people.cs.nctu.edu.tw/~chenwj</a></div></div></div>
</div>