Skip to content

[Clang][ByteCode] Add numeric-only TYPE_SWITCH to avoid Pointer/MemberPointer instantiation in vector handlers #161685

@AdityaC4

Description

@AdityaC4

In InterpBuiltin.cpp, TYPE_SWITCH expands over all PrimTypes (incl. PT_Ptr/PT_MemberPtr). For vector extract/insert we need a numeric-only dispatch (ints + float). Pointer types don’t have toAPSInt() and cause compile errors.

Repro (sketch):

PrimType PT = Vec.getFieldDesc()->getPrimType();
TYPE_SWITCH(PT, {
  // Integer path needs toAPSInt(); float path pushes Floating.
  // Pointer/MemberPointer cases get instantiated and don’t compile.
});

Error:

error: no member named 'toAPSInt' in 'clang::interp::Pointer'
error: no member named 'toAPSInt' in 'clang::interp::MemberPointer'

Expected: A macro that dispatches over ints + float only, excluding Bool/Ptr/MemberPtr/FixedPoint.

Context: Found while adding constexpr for X86 vec_ext/vec_set. PR: #161302
Current workaround: if (PT == PT_Float) { … } else { INT_TYPE_SWITCH_NO_BOOL(PT, …) }

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:bytecodeIssues for the clang bytecode constexpr interpretergood first issuehttps://github.com/llvm/llvm-project/contribute

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions