From 0deb9a9a1f9a02bc0c63d1bc4d881bfb1f46bca4 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Thu, 31 May 2018 13:29:58 +0000 Subject: Extend the GlobalObject metadata interface - Make eraseMetadata return whether it changed something - Wire getMetadata for a single MDNode efficiently into the attachment map - Add hasMetadata, which is less weird than checking getMetadata == nullptr on a multimap. Use it to simplify code. llvm-svn: 333649 --- llvm/lib/IR/LLVMContextImpl.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'llvm/lib/IR/LLVMContextImpl.h') diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h index 7ceeca6e347..d5046d64418 100644 --- a/llvm/lib/IR/LLVMContextImpl.h +++ b/llvm/lib/IR/LLVMContextImpl.h @@ -1164,7 +1164,7 @@ public: /// Remove an attachment. /// /// Remove the attachment at \c ID, if any. - void erase(unsigned ID); + bool erase(unsigned ID); /// Copy out all the attachments. /// @@ -1197,10 +1197,14 @@ public: /// Appends all attachments with the given ID to \c Result in insertion order. /// If the global has no attachments with the given ID, or if ID is invalid, /// leaves Result unchanged. - void get(unsigned ID, SmallVectorImpl &Result); + void get(unsigned ID, SmallVectorImpl &Result) const; + + /// Returns the first attachment with the given ID or nullptr if no such + /// attachment exists. + MDNode *lookup(unsigned ID) const; void insert(unsigned ID, MDNode &MD); - void erase(unsigned ID); + bool erase(unsigned ID); /// Appends all attachments for the global to \c Result, sorting by attachment /// ID. Attachments with the same ID appear in insertion order. This function -- cgit v1.2.3