@@ -111,25 +111,25 @@ class ImmutableMap {
111111 }
112112 };
113113
114- bool contains (key_type_ref K) const {
114+ [[nodiscard]] bool contains (key_type_ref K) const {
115115 return Root ? Root->contains (K) : false ;
116116 }
117117
118- bool operator ==(const ImmutableMap &RHS) const {
118+ [[nodiscard]] bool operator ==(const ImmutableMap &RHS) const {
119119 return Root && RHS.Root ? Root->isEqual (*RHS.Root .get ()) : Root == RHS.Root ;
120120 }
121121
122- bool operator !=(const ImmutableMap &RHS) const {
122+ [[nodiscard]] bool operator !=(const ImmutableMap &RHS) const {
123123 return Root && RHS.Root ? Root->isNotEqual (*RHS.Root .get ())
124124 : Root != RHS.Root ;
125125 }
126126
127- TreeTy *getRoot () const {
127+ [[nodiscard]] TreeTy *getRoot () const {
128128 if (Root) { Root->retain (); }
129129 return Root.get ();
130130 }
131131
132- TreeTy *getRootWithoutRetain () const { return Root.get (); }
132+ [[nodiscard]] TreeTy *getRootWithoutRetain () const { return Root.get (); }
133133
134134 void manualRetain () {
135135 if (Root) Root->retain ();
@@ -139,7 +139,7 @@ class ImmutableMap {
139139 if (Root) Root->release ();
140140 }
141141
142- bool isEmpty () const { return !Root; }
142+ [[nodiscard]] bool isEmpty () const { return !Root; }
143143
144144public:
145145 // ===--------------------------------------------------===//
@@ -163,10 +163,10 @@ class ImmutableMap {
163163 data_type_ref getData () const { return (*this )->second ; }
164164 };
165165
166- iterator begin () const { return iterator (Root.get ()); }
167- iterator end () const { return iterator (); }
166+ [[nodiscard]] iterator begin () const { return iterator (Root.get ()); }
167+ [[nodiscard]] iterator end () const { return iterator (); }
168168
169- data_type* lookup (key_type_ref K) const {
169+ [[nodiscard]] data_type * lookup (key_type_ref K) const {
170170 if (Root) {
171171 TreeTy* T = Root->find (K);
172172 if (T) return &T->getValue ().second ;
@@ -178,15 +178,17 @@ class ImmutableMap {
178178 // / getMaxElement - Returns the <key,value> pair in the ImmutableMap for
179179 // / which key is the highest in the ordering of keys in the map. This
180180 // / method returns NULL if the map is empty.
181- value_type* getMaxElement () const {
181+ [[nodiscard]] value_type * getMaxElement () const {
182182 return Root ? &(Root->getMaxElement ()->getValue ()) : nullptr ;
183183 }
184184
185185 // ===--------------------------------------------------===//
186186 // Utility methods.
187187 // ===--------------------------------------------------===//
188188
189- unsigned getHeight () const { return Root ? Root->getHeight () : 0 ; }
189+ [[nodiscard]] unsigned getHeight () const {
190+ return Root ? Root->getHeight () : 0 ;
191+ }
190192
191193 static inline void Profile (FoldingSetNodeID& ID, const ImmutableMap& M) {
192194 ID.AddPointer (M.Root .get ());
@@ -250,24 +252,24 @@ class ImmutableMapRef {
250252 return ImmutableMapRef (NewT, Factory);
251253 }
252254
253- bool contains (key_type_ref K) const {
255+ [[nodiscard]] bool contains (key_type_ref K) const {
254256 return Root ? Root->contains (K) : false ;
255257 }
256258
257259 ImmutableMap<KeyT, ValT> asImmutableMap () const {
258260 return ImmutableMap<KeyT, ValT>(Factory->getCanonicalTree (Root.get ()));
259261 }
260262
261- bool operator ==(const ImmutableMapRef &RHS) const {
263+ [[nodiscard]] bool operator ==(const ImmutableMapRef &RHS) const {
262264 return Root && RHS.Root ? Root->isEqual (*RHS.Root .get ()) : Root == RHS.Root ;
263265 }
264266
265- bool operator !=(const ImmutableMapRef &RHS) const {
267+ [[nodiscard]] bool operator !=(const ImmutableMapRef &RHS) const {
266268 return Root && RHS.Root ? Root->isNotEqual (*RHS.Root .get ())
267269 : Root != RHS.Root ;
268270 }
269271
270- bool isEmpty () const { return !Root; }
272+ [[nodiscard]] bool isEmpty () const { return !Root; }
271273
272274 // ===--------------------------------------------------===//
273275 // For testing.
@@ -293,10 +295,10 @@ class ImmutableMapRef {
293295 data_type_ref getData () const { return (*this )->second ; }
294296 };
295297
296- iterator begin () const { return iterator (Root.get ()); }
297- iterator end () const { return iterator (); }
298+ [[nodiscard]] iterator begin () const { return iterator (Root.get ()); }
299+ [[nodiscard]] iterator end () const { return iterator (); }
298300
299- data_type *lookup (key_type_ref K) const {
301+ [[nodiscard]] data_type *lookup (key_type_ref K) const {
300302 if (Root) {
301303 TreeTy* T = Root->find (K);
302304 if (T) return &T->getValue ().second ;
@@ -308,15 +310,17 @@ class ImmutableMapRef {
308310 // / getMaxElement - Returns the <key,value> pair in the ImmutableMap for
309311 // / which key is the highest in the ordering of keys in the map. This
310312 // / method returns NULL if the map is empty.
311- value_type* getMaxElement () const {
313+ [[nodiscard]] value_type * getMaxElement () const {
312314 return Root ? &(Root->getMaxElement ()->getValue ()) : nullptr ;
313315 }
314316
315317 // ===--------------------------------------------------===//
316318 // Utility methods.
317319 // ===--------------------------------------------------===//
318320
319- unsigned getHeight () const { return Root ? Root->getHeight () : 0 ; }
321+ [[nodiscard]] unsigned getHeight () const {
322+ return Root ? Root->getHeight () : 0 ;
323+ }
320324
321325 static inline void Profile (FoldingSetNodeID &ID, const ImmutableMapRef &M) {
322326 ID.AddPointer (M.Root .get ());
0 commit comments