Use a non-c'tor for converting a boolean into a StringRef.
authorBill Wendling <isanbard@gmail.com>
Fri, 26 Jul 2013 21:50:30 +0000 (21:50 +0000)
committerBill Wendling <isanbard@gmail.com>
Fri, 26 Jul 2013 21:50:30 +0000 (21:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187250 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/StringRef.h

index 56848fb61672dc16027827b30983231881ea2d79..6215d3f6eae34ef11290fe5ab8d6269c47f61d11 100644 (file)
@@ -90,10 +90,6 @@ namespace llvm {
     /*implicit*/ StringRef(const std::string &Str)
       : Data(Str.data()), Length(Str.length()) {}
 
-    /// Construct a string ref from a boolean.
-    explicit StringRef(bool B)
-      : Data(B ? "true" : "false"), Length(::strlen(Data)) {}
-
     /// @}
     /// @name Iterators
     /// @{
@@ -552,6 +548,10 @@ namespace llvm {
   template <typename T> struct isPodLike;
   template <> struct isPodLike<StringRef> { static const bool value = true; };
 
+  /// Construct a string ref from a boolean.
+  inline StringRef toStringRef(bool B) {
+    return StringRef(B ? "true" : "false");
+  }
 }
 
 #endif