Add the 'explicit' keyword to several constructors that accept one
authorDan Gohman <gohman@apple.com>
Fri, 23 Mar 2007 18:44:11 +0000 (18:44 +0000)
committerDan Gohman <gohman@apple.com>
Fri, 23 Mar 2007 18:44:11 +0000 (18:44 +0000)
argument that don't appear intended as implicit-conversion operators.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35280 91177308-0d34-0410-b5e6-96231b3b80d8

17 files changed:
include/llvm/Argument.h
include/llvm/BasicBlock.h
include/llvm/CodeGen/MachineBasicBlock.h
include/llvm/CodeGen/MachineConstantPool.h
include/llvm/CodeGen/MachineInstrBuilder.h
include/llvm/CodeGen/MachineJumpTableInfo.h
include/llvm/CodeGen/MachineLocation.h
include/llvm/CodeGen/SelectionDAGISel.h
include/llvm/CodeGen/SelectionDAGNodes.h
include/llvm/Constants.h
include/llvm/DerivedTypes.h
include/llvm/Module.h
include/llvm/PassAnalysisSupport.h
include/llvm/PassManager.h
include/llvm/PassManagers.h
include/llvm/PassSupport.h
include/llvm/Type.h

index 1d92066ce582f0f3e5ed6a6c6aba8203abe9235e..8776a488aadc36526965b25d348d7eedffa4f410 100644 (file)
@@ -41,7 +41,9 @@ public:
   /// Argument ctor - If Function argument is specified, this argument is
   /// inserted at the end of the argument list for the function.
   ///
-  Argument(const Type *Ty, const std::string &Name = "", Function *F = 0);
+  explicit Argument(const Type *Ty,
+                    const std::string &Name = "",
+                    Function *F = 0);
 
   inline const Function *getParent() const { return Parent; }
   inline       Function *getParent()       { return Parent; }
index 0ca8eae1a3ef01e1865083e111d85b594c55d162..e15a894591408305f3e410597b5f328c579e97d1 100644 (file)
@@ -70,8 +70,8 @@ public:
   /// is automatically inserted at either the end of the function (if
   /// InsertBefore is null), or before the specified basic block.
   ///
-  BasicBlock(const std::string &Name = "", Function *Parent = 0,
-             BasicBlock *InsertBefore = 0);
+  explicit BasicBlock(const std::string &Name = "", Function *Parent = 0,
+                      BasicBlock *InsertBefore = 0);
   ~BasicBlock();
 
   /// getParent - Return the enclosing method, or null if none
index d076046407f28613c0d562b38218fc1546b8fb0d..1be1b742bf88fdb8c2418017969f7d5f02b1b910 100644 (file)
@@ -79,9 +79,10 @@ class MachineBasicBlock {
   bool IsLandingPad;
 
 public:
-  MachineBasicBlock(const BasicBlock *bb = 0) : Prev(0), Next(0), BB(bb),
-                                                Number(-1), Parent(0),
-                                                IsLandingPad(false) {
+  explicit MachineBasicBlock(const BasicBlock *bb = 0) : Prev(0), Next(0),
+                                                         BB(bb), Number(-1),
+                                                         Parent(0),
+                                                         IsLandingPad(false) {
     Insts.parent = this;
   }
 
index ffd0e55663465dab800917c6e39fbb54b73a23bf..1500053a125d3d9992aa28c6faaaaa6a31a0a642 100644 (file)
@@ -35,7 +35,7 @@ class MachineConstantPoolValue {
   const Type *Ty;
 
 public:
-  MachineConstantPoolValue(const Type *ty) : Ty(ty) {}
+  explicit MachineConstantPoolValue(const Type *ty) : Ty(ty) {}
   virtual ~MachineConstantPoolValue() {};
 
   /// getType - get type of this MachineConstantPoolValue.
index 1d65a4692ff390af84f6c64d93a78774528cfb62..eb45b6ec1fa62324191b2ddc9c69f9b405d4d8a5 100644 (file)
@@ -27,7 +27,7 @@ class TargetInstrDescriptor;
 class MachineInstrBuilder {
   MachineInstr *MI;
 public:
-  MachineInstrBuilder(MachineInstr *mi) : MI(mi) {}
+  explicit MachineInstrBuilder(MachineInstr *mi) : MI(mi) {}
 
   /// Allow automatic conversion to the machine instruction we are working on.
   ///
index 404ed15fd985ef22266aa06034f2e167b1d7267c..d440268e565de13285571687c0cb2b4fcf7e9150 100644 (file)
@@ -34,7 +34,8 @@ struct MachineJumpTableEntry {
   /// MBBs - The vector of basic blocks from which to create the jump table.
   std::vector<MachineBasicBlock*> MBBs;
   
-  MachineJumpTableEntry(const std::vector<MachineBasicBlock*> &M) : MBBs(M) {}
+  explicit MachineJumpTableEntry(const std::vector<MachineBasicBlock*> &M)
+  : MBBs(M) {}
 };
   
 class MachineJumpTableInfo {
index 023962dd6af1801be914fe36e005fce909d81497..c0a78ae812fa3ee69b58998cb8cdf5e50fd79234 100644 (file)
@@ -40,7 +40,7 @@ public:
   , Register(0)
   , Offset(0)
   {}
-  MachineLocation(unsigned R)
+  explicit MachineLocation(unsigned R)
   : IsRegister(true)
   , Register(R)
   , Offset(0)
index 8557702018f764ce689caa03952d7177c9abc597..6ffe86a41e81fd896075eec37da5583df6eec012 100644 (file)
@@ -42,7 +42,8 @@ public:
   std::vector<SDNode*> TopOrder;
   unsigned DAGSize;
 
-  SelectionDAGISel(TargetLowering &tli) : TLI(tli), DAGSize(0), JT(0,0,0,0) {}
+  explicit SelectionDAGISel(TargetLowering &tli)
+  : TLI(tli), DAGSize(0), JT(0,0,0,0) {}
   
   TargetLowering &getTargetLowering() { return TLI; }
 
index d76e4b0813989171a2469a669a7efc7c53c4f556..5d1a0e3efb4f0f094095b11623a66f4936747c0e 100644 (file)
@@ -1075,7 +1075,7 @@ class HandleSDNode : public SDNode {
   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
   SDOperand Op;
 public:
-  HandleSDNode(SDOperand X)
+  explicit HandleSDNode(SDOperand X)
     : SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other)), Op(X) {
     InitOperands(&Op, 1);
   }
@@ -1088,7 +1088,7 @@ class StringSDNode : public SDNode {
   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
 protected:
   friend class SelectionDAG;
-  StringSDNode(const std::string &val)
+  explicit StringSDNode(const std::string &val)
     : SDNode(ISD::STRING, getSDVTList(MVT::Other)), Value(val) {
   }
 public:
@@ -1298,7 +1298,7 @@ class BasicBlockSDNode : public SDNode {
   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
 protected:
   friend class SelectionDAG;
-  BasicBlockSDNode(MachineBasicBlock *mbb)
+  explicit BasicBlockSDNode(MachineBasicBlock *mbb)
     : SDNode(ISD::BasicBlock, getSDVTList(MVT::Other)), MBB(mbb) {
   }
 public:
@@ -1375,7 +1375,7 @@ class CondCodeSDNode : public SDNode {
   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
 protected:
   friend class SelectionDAG;
-  CondCodeSDNode(ISD::CondCode Cond)
+  explicit CondCodeSDNode(ISD::CondCode Cond)
     : SDNode(ISD::CONDCODE, getSDVTList(MVT::Other)), Condition(Cond) {
   }
 public:
@@ -1395,7 +1395,7 @@ class VTSDNode : public SDNode {
   virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
 protected:
   friend class SelectionDAG;
-  VTSDNode(MVT::ValueType VT)
+  explicit VTSDNode(MVT::ValueType VT)
     : SDNode(ISD::VALUETYPE, getSDVTList(MVT::Other)), ValueType(VT) {
   }
 public:
index c307356247ce6840f16d5b02f10d48c9db698405..86fc2e70181460f7bb9e96d4ec274e715200fa78 100644 (file)
@@ -231,7 +231,7 @@ class ConstantAggregateZero : public Constant {
   friend struct ConstantCreator<ConstantAggregateZero, Type, char>;
   ConstantAggregateZero(const ConstantAggregateZero &);      // DO NOT IMPLEMENT
 protected:
-  ConstantAggregateZero(const Type *Ty)
+  explicit ConstantAggregateZero(const Type *Ty)
     : Constant(Ty, ConstantAggregateZeroVal, 0, 0) {}
 public:
   /// get() - static factory method for creating a null aggregate.  It is
@@ -420,7 +420,7 @@ class ConstantPointerNull : public Constant {
   friend struct ConstantCreator<ConstantPointerNull, PointerType, char>;
   ConstantPointerNull(const ConstantPointerNull &);      // DO NOT IMPLEMENT
 protected:
-  ConstantPointerNull(const PointerType *T)
+  explicit ConstantPointerNull(const PointerType *T)
     : Constant(reinterpret_cast<const Type*>(T),
                Value::ConstantPointerNullVal, 0, 0) {}
 
@@ -669,7 +669,7 @@ class UndefValue : public Constant {
   friend struct ConstantCreator<UndefValue, Type, char>;
   UndefValue(const UndefValue &);      // DO NOT IMPLEMENT
 protected:
-  UndefValue(const Type *T) : Constant(T, UndefValueVal, 0, 0) {}
+  explicit UndefValue(const Type *T) : Constant(T, UndefValueVal, 0, 0) {}
 public:
   /// get() - Static factory methods - Return an 'undef' object of the specified
   /// type.
index 4b24d876beef7a39deb20b1a761d69ec209f2040..21ff3d690f8c0c718e4e1f193ed1deb2afed8cd1 100644 (file)
@@ -36,7 +36,7 @@ class DerivedType : public Type {
   friend class Type;
 
 protected:
-  DerivedType(TypeID id) : Type(id) {}
+  explicit DerivedType(TypeID id) : Type(id) {}
 
   /// notifyUsesThatTypeBecameConcrete - Notify AbstractTypeUsers of this type
   /// that the current type has transitioned from being abstract to being
@@ -79,7 +79,7 @@ public:
 /// @brief Integer representation type
 class IntegerType : public DerivedType {
 protected:
-  IntegerType(unsigned NumBits) : DerivedType(IntegerTyID) {
+  explicit IntegerType(unsigned NumBits) : DerivedType(IntegerTyID) {
     setSubclassData(NumBits);
   }
   friend class TypeMap<IntegerValType, IntegerType>;
@@ -230,7 +230,7 @@ public:
 /// and VectorType
 class CompositeType : public DerivedType {
 protected:
-  inline CompositeType(TypeID id) : DerivedType(id) { }
+  inline explicit CompositeType(TypeID id) : DerivedType(id) { }
 public:
 
   /// getTypeAtIndex - Given an index value into the type, return the type of
@@ -404,7 +404,7 @@ class PointerType : public SequentialType {
   friend class TypeMap<PointerValType, PointerType>;
   PointerType(const PointerType &);                   // Do not implement
   const PointerType &operator=(const PointerType &);  // Do not implement
-  PointerType(const Type *ElType);
+  explicit PointerType(const Type *ElType);
 public:
   /// PointerType::get - This is the only way to construct a new pointer type.
   static PointerType *get(const Type *ElementType);
index 560554e3d0dba5d03fad76d583e7219460debb01..3d68e736bfc4da4c7e94c48f20706334d01f1350 100644 (file)
@@ -104,7 +104,7 @@ private:
 public:
   /// The Module constructor. Note that there is no default constructor. You
   /// must provide a name for the module upon construction.
-  Module(const std::string &ModuleID);
+  explicit Module(const std::string &ModuleID);
   /// The module destructor. This will dropAllReferences.
   ~Module();
 
index d832485b833c925e763ade00cb997720c9c64b15..3234e91ebaccaaaef465fa8ed91fd175899d5390 100644 (file)
@@ -111,7 +111,7 @@ private:
   AnalysisResolver();  // DO NOT IMPLEMENT
 
 public:
-  AnalysisResolver(PMDataManager &P) : PM(P) { }
+  explicit AnalysisResolver(PMDataManager &P) : PM(P) { }
   
   inline PMDataManager &getPMDataManager() { return PM; }
 
index f1178e07d3b0953f6367ea8ab3dafdfec6669516..254cac94d10ea12e7bdbbf9bfcc59400f8df6693 100644 (file)
@@ -59,7 +59,7 @@ private:
 /// FunctionPassManager manages FunctionPasses and BasicBlockPassManagers.
 class FunctionPassManager {
 public:
-  FunctionPassManager(ModuleProvider *P);
+  explicit FunctionPassManager(ModuleProvider *P);
   FunctionPassManager();
   ~FunctionPassManager();
  
index fd78833a85aa99a4b8baeeefd7735f2db4610dad..c94a098a842f4032b1dbe909d2859310a2033f13 100644 (file)
@@ -137,7 +137,7 @@ public:
   /// then return NULL.
   Pass *findAnalysisPass(AnalysisID AID);
 
-  PMTopLevelManager(enum TopLevelManagerType t);
+  explicit PMTopLevelManager(enum TopLevelManagerType t);
   virtual ~PMTopLevelManager(); 
 
   /// Add immutable pass and initialize it.
@@ -198,7 +198,7 @@ private:
 class PMDataManager {
 public:
 
-  PMDataManager(int Depth) : TPM(NULL), Depth(Depth) {
+  explicit PMDataManager(int Depth) : TPM(NULL), Depth(Depth) {
     initializeAnalysisInfo();
   }
 
@@ -321,7 +321,7 @@ private:
 class FPPassManager : public ModulePass, public PMDataManager {
  
 public:
-  FPPassManager(int Depth) : PMDataManager(Depth) { }
+  explicit FPPassManager(int Depth) : PMDataManager(Depth) { }
   
   /// run - Execute all of the passes scheduled for execution.  Keep track of
   /// whether any of the passes modifies the module, and if so, return true.
index e4144f7e4224fd493e88039ff50da40cc0231e81..c4d75d52ee15692ed54b6a15b3ff25a4589cff70 100644 (file)
@@ -193,20 +193,20 @@ class RegisterAGBase : public RegisterPassBase {
   const PassInfo *ImplementationInfo;
   bool isDefaultImplementation;
 protected:
-  RegisterAGBase(const std::type_info &Interface,
-                 const std::type_info *Pass = 0,
-                 bool isDefault = false);
+  explicit RegisterAGBase(const std::type_info &Interface,
+                          const std::type_info *Pass = 0,
+                          bool isDefault = false);
   void setGroupName(const char *Name);
 };
 
 template<typename Interface, bool Default = false>
 struct RegisterAnalysisGroup : public RegisterAGBase {
-  RegisterAnalysisGroup(RegisterPassBase &RPB)
+  explicit RegisterAnalysisGroup(RegisterPassBase &RPB)
     : RegisterAGBase(typeid(Interface), &RPB.getPassInfo()->getTypeInfo(), 
                      Default) {
   }
 
-  RegisterAnalysisGroup(const char *Name)
+  explicit RegisterAnalysisGroup(const char *Name)
   : RegisterAGBase(typeid(Interface)) {
     setGroupName(Name);
   }
index 880daadfb172ffd9650530f9ba77870541cf6514..439ac18bf4cecafb0cbb576e8f2428d8f4f1e6a9 100644 (file)
@@ -103,8 +103,8 @@ private:
   const Type *getForwardedTypeInternal() const;
 protected:
   Type(const char *Name, TypeID id);
-  Type(TypeID id) : ID(id), Abstract(false), SubclassData(0), RefCount(0), 
-                    ForwardType(0) {}
+  explicit Type(TypeID id) : ID(id), Abstract(false), SubclassData(0),
+                             RefCount(0), ForwardType(0) {}
   virtual ~Type() {
     assert(AbstractTypeUsers.empty());
   }