[llvm] [MC][DecoderEmitter] Fix build warning: explicit specialization cannot have a storage class (PR #156375)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 1 15:15:02 PDT 2025


jurahul wrote:

> > :( That does not work.
> 
> What are the symptoms? Not sure what difference does anonymous namespace make.

Attempt #1:

Linker error with just dropping the static in front of these. Because we now have duplicate template instantiations between RISCV and AMDGPU and they conflict. 

Attempt #2:
If I also put namespace {} surrounding the specializations, I get error "class template specialization not in a namespace enclosing" because since `InsnBitWidth` is in namesapce llvm::MCD, its specializations are also expected to be in that same namespace. That means the conflict between AMDGPU and RISCV is impossible to prevent.

Current PR:
Move `InsnBitWidth` to anonymous namespace, and then its specializations can also be in anonymous namespace and thus private to each target, avoiding any linker errors.

https://github.com/llvm/llvm-project/pull/156375


More information about the llvm-commits mailing list