Add the 'explicit' keyword to several constructors that accept one

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
This commit is contained in:
Dan Gohman 2007-03-23 18:44:11 +00:00
parent b819a2b5fe
commit 423c2260f9
17 changed files with 41 additions and 36 deletions

View 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; }

View 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

View 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;
}

View 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.

View 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.
///

View 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 {

View File

@ -40,7 +40,7 @@ public:
, Register(0)
, Offset(0)
{}
MachineLocation(unsigned R)
explicit MachineLocation(unsigned R)
: IsRegister(true)
, Register(R)
, Offset(0)

View 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; }

View 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:

View 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.

View 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);

View 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();

View 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; }

View File

@ -59,7 +59,7 @@ private:
/// FunctionPassManager manages FunctionPasses and BasicBlockPassManagers.
class FunctionPassManager {
public:
FunctionPassManager(ModuleProvider *P);
explicit FunctionPassManager(ModuleProvider *P);
FunctionPassManager();
~FunctionPassManager();

View 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.

View 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);
}

View 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());
}