[llvm] r291694 - Make some operator bools explicit for sanity/safety.

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 11 11:47:16 PST 2017


Author: dblaikie
Date: Wed Jan 11 13:47:16 2017
New Revision: 291694

URL: http://llvm.org/viewvc/llvm-project?rev=291694&view=rev
Log:
Make some operator bools explicit for sanity/safety.

There are a couple left in bool-like containers (BitVector, etc) where
the implicit conversions seem more suitable - though it might be worth
considering explicitifying those too.

Modified:
    llvm/trunk/include/llvm/ADT/PointerSumType.h
    llvm/trunk/include/llvm/Analysis/LazyCallGraph.h
    llvm/trunk/include/llvm/Support/CommandLine.h

Modified: llvm/trunk/include/llvm/ADT/PointerSumType.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/PointerSumType.h?rev=291694&r1=291693&r2=291694&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/PointerSumType.h (original)
+++ llvm/trunk/include/llvm/ADT/PointerSumType.h Wed Jan 11 13:47:16 2017
@@ -94,7 +94,7 @@ public:
     return HelperT::template Lookup<N>::TraitsT::getFromVoidPointer(getImpl());
   }
 
-  operator bool() const { return Value & HelperT::PointerMask; }
+  explicit operator bool() const { return Value & HelperT::PointerMask; }
   bool operator==(const PointerSumType &R) const { return Value == R.Value; }
   bool operator!=(const PointerSumType &R) const { return Value != R.Value; }
   bool operator<(const PointerSumType &R) const { return Value < R.Value; }

Modified: llvm/trunk/include/llvm/Analysis/LazyCallGraph.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LazyCallGraph.h?rev=291694&r1=291693&r2=291694&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/LazyCallGraph.h (original)
+++ llvm/trunk/include/llvm/Analysis/LazyCallGraph.h Wed Jan 11 13:47:16 2017
@@ -148,7 +148,7 @@ public:
     ///
     /// This happens when an edge has been deleted. We leave the edge objects
     /// around but clear them.
-    operator bool() const;
+    explicit operator bool() const;
 
     /// Returnss the \c Kind of the edge.
     Kind getKind() const;

Modified: llvm/trunk/include/llvm/Support/CommandLine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CommandLine.h?rev=291694&r1=291693&r2=291694&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/CommandLine.h (original)
+++ llvm/trunk/include/llvm/Support/CommandLine.h Wed Jan 11 13:47:16 2017
@@ -201,7 +201,7 @@ public:
 
   void reset();
 
-  operator bool() const;
+  explicit operator bool() const;
 
   StringRef getName() const { return Name; }
   StringRef getDescription() const { return Description; }




More information about the llvm-commits mailing list