[llvm] [AsmWriter] Ensure getMnemonic doesn't return invalid pointers (PR #75783)
Tomas Matheson via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 18 03:28:09 PST 2023
================
@@ -154,7 +154,10 @@ class MCAsmStreamer final : public MCStreamer {
void emitGNUAttribute(unsigned Tag, unsigned Value) override;
StringRef getMnemonic(MCInst &MI) override {
- return InstPrinter->getMnemonic(&MI).first;
+ std::pair<const char *, uint64_t> M = InstPrinter->getMnemonic(&MI);
+ assert((M.second != 0 || M.first == nullptr) &&
----------------
tmatheson-arm wrote:
C++17 structured bindings might make this a bit more readable:
```cpp
auto [ Ptr, Bits ] = InstPrinter->getMnemonic(&MI);
```
https://github.com/llvm/llvm-project/pull/75783
More information about the llvm-commits
mailing list