<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 - nullPointerConstant AST matcher triggers assert(!isNull()) in QualType::getCommonPtr"
   href="https://bugs.llvm.org/show_bug.cgi?id=46353">46353</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>nullPointerConstant AST matcher triggers assert(!isNull()) in QualType::getCommonPtr
          </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>All
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>release blocker
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>lukasza@chromium.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>REPRO STEPS:

1. Augment TEST(NullPointerConstants, Basic) in
clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp with the following
test code:

    2612   const char kTest[] = R"(
    2613       template <typename T>
    2614       struct MyTemplate {
    2615         MyTemplate() : field_(__null) {}
    2616         T* field_;
    2617       };
    2618   )";
    2619   EXPECT_TRUE(matches(kTest, expr(nullPointerConstant())));

2. Build the unit tests:
$ cd ~/src/llvm-project/build
$ ninja tools/clang/unittests/ASTMatchers/ASTMatchersTests

3. Run the unit tests:
$ python3.7 ~/src/llvm-project/build/bin/llvm-lit -sv --param USE_Z3_SOLVER=0
~/src/llvm-project/build/tools/clang/test --filter=.*NullPointerConstants.*


EXPECTED BEHAVIOR:
1) no asserts or crashes
2) the |__null| expression is matched

ACTUAL BEHAVIOR: assert:

ASTMatchersTests:
/usr/local/google/home/lukasza/src/llvm-project/clang/include/clang/AST/Type.h:671:
const clang::ExtQualsTypeCommonBase* clang::QualType::getCommonPtr() const:
Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed.

(I am sorry, but I don't know how to symbolize the callstack...)


NOTES:

*) The original repro used |NULL| rather than |__null|.  I've used |__null|
above, to avoid having to include <stddef.h> (which is rather difficult in unit
tests, which expect self-contained inputs).

*) It seems that recently there were some changes in the AST Matchers library
that have been highlighted in the release notes:
<a href="https://clang.llvm.org/docs/ReleaseNotes.html#ast-matchers">https://clang.llvm.org/docs/ReleaseNotes.html#ast-matchers</a></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>