[llvm-bugs] [Bug 46353] New: nullPointerConstant AST matcher triggers assert(!isNull()) in QualType::getCommonPtr

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 16 16:29:27 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46353

            Bug ID: 46353
           Summary: nullPointerConstant AST matcher triggers
                    assert(!isNull()) in QualType::getCommonPtr
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: lukasza at chromium.org
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

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:
https://clang.llvm.org/docs/ReleaseNotes.html#ast-matchers

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200616/c3e5ce82/attachment.html>


More information about the llvm-bugs mailing list