llvm-project
1a4bc95e - [DebugInfo][NFC] Add typed DIExpression operand views (#215682)

Commit
5 days ago
[DebugInfo][NFC] Add typed DIExpression operand views (#215682) DIExpression users check an opcode and then read its arguments with numbered getArg() calls. Add typed views for the operations with repeated raw accesses and use their named accessors in those consumers. The views reuse ExprOperand's pointer storage and LLVM's cast helpers. A failed dyn_cast returns an empty view, so conditional matches don't need an optional wrapper. Reading one is a bug, so getOp() and getArg() now assert the operand is there rather than dereferencing null. The only interesting change is that getActiveBits loses the fallthrough from its extract case into its fragment case. The two shared one read because both opcodes keep their size in the same argument; now each names its own through its view and they share a lambda for the narrowing. A unit test covers both paths. Overall a bit more code, but quite a bit more readable IMO. Tested with check-llvm and the IR unit tests. Assisted by AI.
Author
Parents
Loading