<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - AST should explain the implicitness of the casts better"
   href="https://bugs.llvm.org/show_bug.cgi?id=38166">38166</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>AST should explain the implicitness of the casts better
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>lebedev.ri@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Related to #38017.
We can't actually distinguish whether the implicit cast is implicit in source
code, or is part of explicit cast.
We can't use ASTContext::getParents() (partly performance, partly semantics).
But we also sometimes don't visit the ExplicitCastExpr.

<zygoloid> CodeGenFunction::EmitMaterializeTemporaryExpr calls
skipRValueSubobjectAdjustments, which steps over the CK_NoOp cast

<zygoloid> OK, so we could fix that, or we could add some state to the CastExpr
so you can tell whether it's an "implicitly doing bad things" cast kind

<zygoloid> or maybe a CastKind; we could use CK_UncheckedIntegralCast for
"integral cast where the user explicitly asked for it" versus CK_IntegralCast
for "integral cast that was performed implicitly"

<zygoloid> i don't think "is part of explicit cast" is quite right; given
"struct X { X(char); }", X(some_int) should still be checked

<zygoloid> but perhaps "enum E : char {}; E(some_int)" is more borderline
<LebedevRI> which solution does sound best to you? the ast one, or something
involving skipRValueSubobjectAdjustments() ? /me needs to know how to title the
bug

<zygoloid> I think it makes sense to make skipRValueSubobjectAdjustments skip
the minimum amount of stuff necessary to get to the expression constructing the
temporary
<zygoloid> but I'd be OK with having a new cast kind for this, because in the
generalized Clang model (including UBSan) the cast has different semantics</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>