[llvm] 552ee3c - [ADT] Add const to AllocatorList::{empty, size} (#161320)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 30 08:56:24 PDT 2025


Author: Kazu Hirata
Date: 2025-09-30T08:56:20-07:00
New Revision: 552ee3c160fe619e86e796b2fde2cc51592c3b5a

URL: https://github.com/llvm/llvm-project/commit/552ee3c160fe619e86e796b2fde2cc51592c3b5a
DIFF: https://github.com/llvm/llvm-project/commit/552ee3c160fe619e86e796b2fde2cc51592c3b5a.diff

LOG: [ADT] Add const to AllocatorList::{empty,size} (#161320)

While I am at it, this patch adds [[nodiscard]].

Added: 
    

Modified: 
    llvm/include/llvm/ADT/AllocatorList.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ADT/AllocatorList.h b/llvm/include/llvm/ADT/AllocatorList.h
index 04d0afc9d076e..2716b83ca224a 100644
--- a/llvm/include/llvm/ADT/AllocatorList.h
+++ b/llvm/include/llvm/ADT/AllocatorList.h
@@ -155,8 +155,8 @@ template <class T, class AllocatorT> class AllocatorList : AllocatorT {
     std::swap(getAlloc(), RHS.getAlloc());
   }
 
-  bool empty() { return List.empty(); }
-  size_t size() { return List.size(); }
+  [[nodiscard]] bool empty() const { return List.empty(); }
+  [[nodiscard]] size_t size() const { return List.size(); }
 
   iterator begin() { return iterator(List.begin()); }
   iterator end() { return iterator(List.end()); }


        


More information about the llvm-commits mailing list