[llvm-bugs] [Bug 47037] New: apiModeling.llvm.CastValue checker crashes on every isa_and_nonnull<>()

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Aug 7 06:58:22 PDT 2020


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

            Bug ID: 47037
           Summary: apiModeling.llvm.CastValue checker crashes on every
                    isa_and_nonnull<>()
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: Static Analyzer
          Assignee: dcoughlin at apple.com
          Reporter: adam.balogh at ericsson.com
                CC: dcoughlin at apple.com, llvm-bugs at lists.llvm.org

isa_and_nonnull<>() is a variadic template:

template <typename... X, class Y>
LLVM_NODISCARD inline bool isa_and_nonnull(const Y &Val) {
  if (!Val)
    return false;
  return isa<X...>(Val);
}

This calls the variadic version of isa<>():

template <typename First, typename Second, typename... Rest, typename Y>
LLVM_NODISCARD inline bool isa(const Y &Val) {
  return isa<First>(Val) || isa<Second, Rest...>(Val);
}

The main difference is that variadic version of isa<>() expects at least two
template parameters explicitly. For isa_and_nonnull<>() the first template
parameter is already a variadic one.

The checker does not checks variadic_isa<>() correctly (it only checks the
first parameter) and crashes on isa_and_nonnull<>() because it tries to
retrieve the template parameter as a type which is a pack instead. This causes
an assertion.

In the test files there are no tests for isa_and_nonnull<>() and in the LLVM
test header the isa_and_nonnull<>() is implemented in a non-variadic way.

-- 
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/20200807/7699740e/attachment.html>


More information about the llvm-bugs mailing list