<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">fwd to cfe-dev list.</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-11-24 19:34 GMT+08:00 Dimitar Dobrev via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-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">Hello all.<br>
<br>
I need your advice about a fix I am thinking about. See this code:<br>
<br>
<a href="https://clang.llvm.org/doxygen/SemaOverload_8cpp_source.html#l12230" rel="noreferrer" target="_blank">https://clang.llvm.org/<wbr>doxygen/SemaOverload_8cpp_<wbr>source.html#l12230</a><br>
<br>
I think that if the found function is invalid<br>
(clang::Decl::isInvalidDecl()) this case should fall through to<br>
<a href="https://clang.llvm.org/doxygen/SemaOverload_8cpp_source.html#l12338" rel="noreferrer" target="_blank">https://clang.llvm.org/<wbr>doxygen/SemaOverload_8cpp_<wbr>source.html#l12338</a> .<br>
<br>
I am afraid I don’t know enough about the code of Clang and about<br>
compilers in general in order to think of a test myself. Instead, I<br>
could explain the problem I have and why I think something like this<br>
would help.<br>
<br>
So, I work on <a href="https://github.com/mono/CppSharp" rel="noreferrer" target="_blank">https://github.com/mono/<wbr>CppSharp</a> , it’s a generator for<br>
language bindings to C++.<br>
<br>
I need to get symbols of template specialisations so that I can compile<br>
them and invoke them from the target language. So I parse the input<br>
headers and use the Clang API to instantiate each specialisation I need:<br>
<br>
Sema::<wbr>InstantiateClassTemplateSpecia<wbr>lization<br>
<br>
However, in many cases functions of specialisations are invalid. For<br>
example, the body of the templated function uses == while the T type<br>
argument does not support this operator. In order to find such<br>
functions, I use a custom DiagnosticConsumer combined with<br>
Sema::<wbr>InstantiateFunctionDefinition for each function.<br>
<br>
I am now going to explain the actual problem.<br>
Some of these functions are inlined and use each other. A typical<br>
example is != which uses == internally, as in != { return !==; }. Let’s<br>
say the == is invalid. InstantiateFunctionDefinition detects that but it<br>
adds the == as a valid overload anyway. So when the != is parsed, Clang<br>
says: I have found a valid overload for the == inside and I am returning<br>
it so there’s no error in this function.<br>
This problem also affects your stack traces because they show the CPP<br>
the == was originally requested from but do now show it for the !=.<br>
<br>
Please share your opinions about the fix I have suggested and about the<br>
problem in general.<br>
<br>
<br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><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>