From adf3eab7735741926c67e6fc12b952500c45a9ba Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 19 Nov 2007 15:30:20 +0000 Subject: [PATCH] Add explicit keywords. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44234 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/StringMap.h | 12 ++++++------ include/llvm/Analysis/ScalarEvolutionExpressions.h | 6 +++--- include/llvm/Bitcode/Serialize.h | 2 +- lib/Bitcode/Reader/BitcodeReader.cpp | 2 +- lib/Bitcode/Writer/BitcodeWriterPass.cpp | 3 ++- lib/Transforms/Scalar/CorrelatedExprs.cpp | 8 ++++---- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h index 895d62b1e61..5c47604db45 100644 --- a/include/llvm/ADT/StringMap.h +++ b/include/llvm/ADT/StringMap.h @@ -28,7 +28,7 @@ namespace llvm { class StringMapEntryBase { unsigned StrLen; public: - StringMapEntryBase(unsigned Len) : StrLen(Len) {} + explicit StringMapEntryBase(unsigned Len) : StrLen(Len) {} unsigned getKeyLength() const { return StrLen; } }; @@ -55,7 +55,7 @@ protected: unsigned NumTombstones; unsigned ItemSize; protected: - StringMapImpl(unsigned itemSize) : ItemSize(itemSize) { + explicit StringMapImpl(unsigned itemSize) : ItemSize(itemSize) { // Initialize the map with zero buckets to allocation. TheTable = 0; NumBuckets = 0; @@ -115,7 +115,7 @@ template class StringMapEntry : public StringMapEntryBase { ValueTy Val; public: - StringMapEntry(unsigned StrLen) + explicit StringMapEntry(unsigned StrLen) : StringMapEntryBase(StrLen), Val() {} StringMapEntry(unsigned StrLen, const ValueTy &V) : StringMapEntryBase(StrLen), Val(V) {} @@ -204,7 +204,7 @@ class StringMap : public StringMapImpl { typedef StringMapEntry MapEntryTy; public: StringMap() : StringMapImpl(sizeof(MapEntryTy)) {} - StringMap(unsigned InitialSize) + explicit StringMap(unsigned InitialSize) : StringMapImpl(InitialSize, sizeof(MapEntryTy)) {} AllocatorTy &getAllocator() { return Allocator; } @@ -314,8 +314,8 @@ class StringMapConstIterator { protected: StringMapImpl::ItemBucket *Ptr; public: - StringMapConstIterator(StringMapImpl::ItemBucket *Bucket, - bool NoAdvance = false) + explicit StringMapConstIterator(StringMapImpl::ItemBucket *Bucket, + bool NoAdvance = false) : Ptr(Bucket) { if (!NoAdvance) AdvancePastEmptyBuckets(); } diff --git a/include/llvm/Analysis/ScalarEvolutionExpressions.h b/include/llvm/Analysis/ScalarEvolutionExpressions.h index 7fbeff7de0d..fb69a90fe74 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpressions.h +++ b/include/llvm/Analysis/ScalarEvolutionExpressions.h @@ -285,7 +285,7 @@ namespace llvm { class SCEVAddExpr : public SCEVCommutativeExpr { friend class ScalarEvolution; - SCEVAddExpr(const std::vector &ops) + explicit SCEVAddExpr(const std::vector &ops) : SCEVCommutativeExpr(scAddExpr, ops) { } @@ -305,7 +305,7 @@ namespace llvm { class SCEVMulExpr : public SCEVCommutativeExpr { friend class ScalarEvolution; - SCEVMulExpr(const std::vector &ops) + explicit SCEVMulExpr(const std::vector &ops) : SCEVCommutativeExpr(scMulExpr, ops) { } @@ -468,7 +468,7 @@ namespace llvm { friend class ScalarEvolution; Value *V; - SCEVUnknown(Value *v) : SCEV(scUnknown), V(v) {} + explicit SCEVUnknown(Value *v) : SCEV(scUnknown), V(v) {} protected: ~SCEVUnknown(); diff --git a/include/llvm/Bitcode/Serialize.h b/include/llvm/Bitcode/Serialize.h index 60d9cb2c992..7b6d8226a08 100644 --- a/include/llvm/Bitcode/Serialize.h +++ b/include/llvm/Bitcode/Serialize.h @@ -31,7 +31,7 @@ class Serializer { MapTy PtrMap; public: - Serializer(BitstreamWriter& stream); + explicit Serializer(BitstreamWriter& stream); ~Serializer(); template diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 0bacf0fe70e..aa78e7c4dc0 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -123,7 +123,7 @@ namespace { void operator=(const ConstantPlaceHolder &); // DO NOT IMPLEMENT public: Use Op; - ConstantPlaceHolder(const Type *Ty) + explicit ConstantPlaceHolder(const Type *Ty) : ConstantExpr(Ty, Instruction::UserOp1, &Op, 1), Op(UndefValue::get(Type::Int32Ty), this) { } diff --git a/lib/Bitcode/Writer/BitcodeWriterPass.cpp b/lib/Bitcode/Writer/BitcodeWriterPass.cpp index 8de7ffb2db2..57512045e03 100644 --- a/lib/Bitcode/Writer/BitcodeWriterPass.cpp +++ b/lib/Bitcode/Writer/BitcodeWriterPass.cpp @@ -20,7 +20,8 @@ namespace { std::ostream &Out; // ostream to print on public: static char ID; // Pass identifcation, replacement for typeid - WriteBitcodePass(std::ostream &o) : ModulePass((intptr_t) &ID), Out(o) {} + explicit WriteBitcodePass(std::ostream &o) + : ModulePass((intptr_t) &ID), Out(o) {} const char *getPassName() const { return "Bitcode Writer"; } diff --git a/lib/Transforms/Scalar/CorrelatedExprs.cpp b/lib/Transforms/Scalar/CorrelatedExprs.cpp index 6933fab3cf4..42c4055ae67 100644 --- a/lib/Transforms/Scalar/CorrelatedExprs.cpp +++ b/lib/Transforms/Scalar/CorrelatedExprs.cpp @@ -57,7 +57,7 @@ namespace { Value *Val; // Relation to what value? unsigned Rel; // SetCC or ICmp relation, or Add if no information public: - Relation(Value *V) : Val(V), Rel(Instruction::Add) {} + explicit Relation(Value *V) : Val(V), Rel(Instruction::Add) {} bool operator<(const Relation &R) const { return Val < R.Val; } Value *getValue() const { return Val; } unsigned getRelation() const { return Rel; } @@ -112,7 +112,7 @@ namespace { // Value *Replacement; public: - ValueInfo(const Type *Ty) + explicit ValueInfo(const Type *Ty) : Bounds(Ty->isInteger() ? cast(Ty)->getBitWidth() : 32), Replacement(0) {} @@ -146,7 +146,7 @@ namespace { return *I; // Insert and return the new relationship... - return *Relationships.insert(I, V); + return *Relationships.insert(I, Relation(V)); } const Relation *requestRelation(Value *V) const { @@ -176,7 +176,7 @@ namespace { typedef std::map ValueMapTy; ValueMapTy ValueMap; public: - RegionInfo(BasicBlock *bb) : BB(bb) {} + explicit RegionInfo(BasicBlock *bb) : BB(bb) {} // getEntryBlock - Return the block that dominates all of the members of // this region. -- 2.34.1