From b5660dc8223bd5eb3d21d9855692617fcdec5663 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 20 Feb 2008 16:44:09 +0000 Subject: [PATCH] Add explicit keywords. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47382 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Annotation.h | 6 ++++-- include/llvm/Support/CommandLine.h | 2 +- include/llvm/Support/ConstantRange.h | 2 +- lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 2 +- lib/Support/Annotation.cpp | 4 ++-- lib/Transforms/Scalar/PredicateSimplifier.cpp | 2 +- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/llvm/Support/Annotation.h b/include/llvm/Support/Annotation.h index 4a53ff59a99..2be1c106169 100644 --- a/include/llvm/Support/Annotation.h +++ b/include/llvm/Support/Annotation.h @@ -43,7 +43,9 @@ class AnnotationID { unsigned ID; AnnotationID(); // Default ctor is disabled - inline AnnotationID(unsigned i) : ID(i) {} // Only creatable from AnnMgr + + // AnnotationID is only creatable from AnnMgr. + explicit inline AnnotationID(unsigned i) : ID(i) {} public: inline AnnotationID(const AnnotationID &A) : ID(A.ID) {} @@ -67,7 +69,7 @@ class Annotation { AnnotationID ID; // ID number, as obtained from AnnotationManager Annotation *Next; // The next annotation in the linked list public: - inline Annotation(AnnotationID id) : ID(id), Next(0) {} + explicit inline Annotation(AnnotationID id) : ID(id), Next(0) {} virtual ~Annotation(); // Designed to be subclassed // getID - Return the unique ID# of this annotation diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 1392e334ac5..0f804395c39 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -1316,7 +1316,7 @@ struct aliasopt { // exit is called. struct extrahelp { const char * morehelp; - extrahelp(const char* help); + explicit extrahelp(const char* help); }; void PrintVersionMessage(); diff --git a/include/llvm/Support/ConstantRange.h b/include/llvm/Support/ConstantRange.h index 6fb56b3b257..2e477cf8998 100644 --- a/include/llvm/Support/ConstantRange.h +++ b/include/llvm/Support/ConstantRange.h @@ -44,7 +44,7 @@ class ConstantRange { public: /// Initialize a full (the default) or empty set for the specified bit width. /// - ConstantRange(uint32_t BitWidth, bool isFullSet = true); + explicit ConstantRange(uint32_t BitWidth, bool isFullSet = true); /// Initialize a range to hold the single specified value. /// diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index d1de88b7e24..244dee393f6 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -262,7 +262,7 @@ class VISIBILITY_HIDDEN WorkListRemover : public SelectionDAG::DAGUpdateListener { DAGCombiner &DC; public: - WorkListRemover(DAGCombiner &dc) : DC(dc) {} + explicit WorkListRemover(DAGCombiner &dc) : DC(dc) {} virtual void NodeDeleted(SDNode *N) { DC.removeFromWorkList(N); diff --git a/lib/Support/Annotation.cpp b/lib/Support/Annotation.cpp index 9d5e5457d9a..3ecc42f782e 100644 --- a/lib/Support/Annotation.cpp +++ b/lib/Support/Annotation.cpp @@ -57,9 +57,9 @@ AnnotationID AnnotationManager::getID(const std::string &Name) { // Name -> ID IDMapType::iterator I = IDMap->find(Name); if (I == IDMap->end()) { (*IDMap)[Name] = IDCounter++; // Add a new element - return IDCounter-1; + return AnnotationID(IDCounter-1); } - return I->second; + return AnnotationID(I->second); } // getID - Name -> ID + registration of a factory function for demand driven diff --git a/lib/Transforms/Scalar/PredicateSimplifier.cpp b/lib/Transforms/Scalar/PredicateSimplifier.cpp index 388071d1e9a..d0067b3302c 100644 --- a/lib/Transforms/Scalar/PredicateSimplifier.cpp +++ b/lib/Transforms/Scalar/PredicateSimplifier.cpp @@ -1112,7 +1112,7 @@ namespace { else if (isa(V)) return ConstantRange(APInt::getNullValue(typeToWidth(V->getType()))); else - return typeToWidth(V->getType()); + return ConstantRange(typeToWidth(V->getType())); } // typeToWidth - returns the number of bits necessary to store a value of -- 2.34.1