Skip to content

Can't use parameter pack llvm::isa inside assert #160672

@lukel97

Description

@lukel97

I noticed this in #160274, where I had an assert like

    assert(isa<InsertElementInst>(VecI) ||
           isa<InsertValueInst>(VecI) &&
               "Packed operands must generate an insertelement or insertvalue");

But there's a handy version of llvm::isa that uses parameter packs so you can pass multiple types to check against, however this seems to fail when used inside of the assert:

    assert(isa<InsertElementInst, InsertValueInst>(VecI) &&
               "Packed operands must generate an insertelement or insertvalue");
llvm-project/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:3271:35: error: too many arguments provided to function-like macro invocation
 3271 |     assert(isa<InsertElementInst, InsertValueInst>(VecI) &&
      |                                   ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/assert.h:71:9: note: macro 'assert' defined here
   71 | #define assert(e) \
      |         ^
llvm-project/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:3271:5: error: use of undeclared identifier 'assert'
 3271 |     assert(isa<InsertElementInst, InsertValueInst>(VecI) &&
      |     ^
2 errors generated.

The parameter pack overload works fine outside of the assert. I'm not sure if this specific to the MacOSX toolchain or not. Running into this on clang version 21.1.2, arm64-apple-darwin24.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    llvm:supportquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions