<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">Comparing the getQualifier()->getAsRecordDecl()s of the two DeclRefExprs should do it I think (untested). Careful though, NNS::getAsRecordDecl() crashes instead of returning null if the qualifier is e.g. a namespace, check its implem for the permissible kinds (or maybe better to add a getAsRecordDeclUnsafe() method).<div><div dir="ltr"><br><blockquote type="cite">On Nov 23, 2021, at 11:03 AM, Benics Balázs via cfe-dev <cfe-dev@lists.llvm.org> wrote:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
(Resending from my personal email address)</div>
<div id="ms-outlook-mobile-signature">
<div dir="auto"><br>
</div>
</div>
<div id="id-55f9e2ca-f8f6-43bd-a783-9b031c3c0c46" class="ms-outlook-mobile-reference-message">
<div style="font-family: sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg"><strong>From:</strong> Balázs Benics <balazs.benics@sigmatechnology.se><br>
<strong>Sent:</strong> Tuesday, November 23, 2021, 14:45<br>
<strong>To:</strong> cfe-dev<br>
<strong>Subject:</strong> Same AST for is_same<char, int="">::value and is_same<char, long="">::value<br>
</char,></char,></div>
<br>
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style>
<!--
@font-face
{font-family:"Cambria Math"}
@font-face
{font-family:Calibri}
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif}
a:link, span.MsoHyperlink
{color:#0563C1;
text-decoration:underline}
span.EmailStyle17
{font-family:"Calibri",sans-serif;
color:windowtext}
.MsoChpDefault
{font-family:"Calibri",sans-serif}
@page WordSection1
{margin:72.0pt 72.0pt 72.0pt 72.0pt}
div.WordSection1
{}
-->
</style>
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">I seek some advice on the following AST scenario.</span></p>
<p class="MsoNormal"><span lang="EN-US"><a href="https://godbolt.org/z/WcTeoGcbG" style="">https://godbolt.org/z/WcTeoGcbG</a></span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">1 #include <type_traits></span></p>
<p class="MsoNormal"><span lang="EN-US">2 using std::is_same;</span></p>
<p class="MsoNormal"><span lang="EN-US">3 bool top() {</span></p>
<p class="MsoNormal"><span lang="EN-US">4 return is_same<char, int>::value || is_same<char, long>::value;</span></p>
<p class="MsoNormal"><span lang="EN-US">5 }</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">The `alpha.core.IdenticalExpr` static analyzer checker warns about that the two `..::value` are identical DeclRefExprs.</span></p>
<p class="MsoNormal"><span lang="EN-US">According to the AST, they are indeed identical:</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US"> BinaryOperator <col:10, col:60> 'bool' '||'</span></p>
<p class="MsoNormal"><span lang="EN-US"> |-ImplicitCastExpr <col:10, col:30> 'bool':'bool' <LValueToRValue></span></p>
<p class="MsoNormal"><span lang="EN-US"> | `-DeclRefExpr <col:10, col:30> 'const bool':'const bool' lvalue Var 0x563b67cde0a8 'value' 'const bool':'const bool'</span></p>
<p class="MsoNormal"><span lang="EN-US"> `-ImplicitCastExpr <col:39, col:60> 'bool':'bool' <LValueToRValue></span></p>
<p class="MsoNormal"><span lang="EN-US"> `-DeclRefExpr <col:39, col:60> 'const bool':'const bool' lvalue Var 0x563b67cde0a8 'value' 'const bool':'const bool'</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">Both of them refers to the same `VarDecl`, corresponding (probably) to the `std::false_type::value`.</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">How can I detect that even though the `values` look similar, they correspond to different template instances in that sense?</span></p>
<p class="MsoNormal"><span lang="EN-US">What do you suggest?</span></p>
<p class="MsoNormal"><span lang="EN-US">In the end, I want to suppress these reports in the static analyzer.</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">Balázs</span></p>
</div>
<br>
</div>
<span>_______________________________________________</span><br><span>cfe-dev mailing list</span><br><span>cfe-dev@lists.llvm.org</span><br><span>https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</span><br></div></blockquote></div></body></html>