Support: Write ScaledNumbers::getRounded()
[oota-llvm.git] / include / llvm / Support / StringPool.h
index 82e46d42c69dcb5b98300ffb38f9899695534733..3e0465340c3b472a32cf38124ea695d1681f6ba5 100644 (file)
 #ifndef LLVM_SUPPORT_STRINGPOOL_H
 #define LLVM_SUPPORT_STRINGPOOL_H
 
+#include "llvm/Support/Compiler.h"
 #include "llvm/ADT/StringMap.h"
-#include <new>
 #include <cassert>
+#include <new>
 
 namespace llvm {
 
@@ -48,7 +49,7 @@ namespace llvm {
       unsigned Refcount; ///< Number of referencing PooledStringPtrs.
 
     public:
-      PooledString() : Pool(0), Refcount(0) { }
+      PooledString() : Pool(nullptr), Refcount(0) { }
     };
 
     friend class PooledStringPtr;
@@ -64,7 +65,7 @@ namespace llvm {
     /// intern - Adds a string to the pool and returns a reference-counted
     /// pointer to it. No additional memory is allocated if the string already
     /// exists in the pool.
-    PooledStringPtr intern(const StringRef &Str);
+    PooledStringPtr intern(StringRef Str);
 
     /// empty - Checks whether the pool is empty. Returns true if so.
     ///
@@ -81,7 +82,7 @@ namespace llvm {
     entry_t *S;
 
   public:
-    PooledStringPtr() : S(0) {}
+    PooledStringPtr() : S(nullptr) {}
 
     explicit PooledStringPtr(entry_t *E) : S(E) {
       if (S) ++S->getValue().Refcount;
@@ -107,7 +108,7 @@ namespace llvm {
         S->getValue().Pool->InternTable.remove(S);
         S->Destroy();
       }
-      S = 0;
+      S = nullptr;
     }
 
     ~PooledStringPtr() { clear(); }
@@ -128,10 +129,10 @@ namespace llvm {
     }
 
     inline const char *operator*() const { return begin(); }
-    inline operator bool() const { return S != 0; }
+    inline LLVM_EXPLICIT operator bool() const { return S != nullptr; }
 
-    inline bool operator==(const PooledStringPtr &That) { return S == That.S; }
-    inline bool operator!=(const PooledStringPtr &That) { return S != That.S; }
+    inline bool operator==(const PooledStringPtr &That) const { return S == That.S; }
+    inline bool operator!=(const PooledStringPtr &That) const { return S != That.S; }
   };
 
 } // End llvm namespace