<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 - Verifier - nullptr dereference warning"
   href="https://bugs.llvm.org/show_bug.cgi?id=45118">45118</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Verifier - nullptr dereference warning
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>Core LLVM classes
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>llvm-dev@redking.me.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>anemet@apple.com, aprantl@apple.com, llvm-bugs@lists.llvm.org, orlando.hyams@sony.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre><a href="http://lab.llvm.org:8080/coverage/coverage-reports/llvm/coverage/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/IR/Verifier.cpp.html">http://lab.llvm.org:8080/coverage/coverage-reports/llvm/coverage/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/IR/Verifier.cpp.html</a>

Static analysis warns that the SP variable is dereferenced as null:

    DILocalScope *Scope = DL->getInlinedAtScope();
    if (Scope && !Seen.insert(Scope).second)
      return;

    DISubprogram *SP = Scope ? Scope->getSubprogram() : nullptr;

    // Scope and SP could be the same MDNode and we don't want to skip
    // validation in that case
    if (SP && ((Scope != SP) && !Seen.insert(SP).second))
      return;

    AssertDI(SP->describes(&F),
             "!dbg attachment points at wrong subprogram for function", N, &F,
             &I, DL, Scope, SP);

AFAICT the Scope variable will always be non-null (and we should just assert
that it is), allowing us to simplify the code to something like the below (my
main concern is I'm not sure on how the verifier assertions are supposed to be
implemented):

    DILocalScope *Scope = DL->getInlinedAtScope();
    assert(Scope && "Unknown inlined scope"); <-- NOT FAMILIAR WITH THE
VERIFIER ASSERTION MECHANISM
    if (!Seen.insert(Scope).second)
      return;

    DISubprogram *SP = Scope->getSubprogram();
    assert(SP && "Unknown scope subprogram"); <-- NOT FAMILIAR WITH THE
VERIFIER ASSERTION MECHANISM

    // Scope and SP could be the same MDNode and we don't want to skip
    // validation in that case
    if (((Scope != SP) && !Seen.insert(SP).second))
      return;

    AssertDI(SP->describes(&F),
             "!dbg attachment points at wrong subprogram for function", N, &F,
             &I, DL, Scope, SP);</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>