From 24cb23f21b453d098c7e09b3d5e5cea4be746ba1 Mon Sep 17 00:00:00 2001 From: Jordan DeLong Date: Sat, 20 Apr 2013 10:23:50 -0700 Subject: [PATCH] More fixing lint: various conversion constructors in compiler/ Left one implicit, but it's arguable. Inspected manually. --- hphp/compiler/analysis/alias_manager.cpp | 4 ++-- hphp/compiler/analysis/alias_manager.h | 6 +++--- hphp/compiler/analysis/analysis_result.cpp | 8 +++++--- hphp/compiler/analysis/analysis_result.h | 18 +++++++++--------- hphp/compiler/analysis/ast_walker.h | 4 ++-- hphp/compiler/analysis/constant_table.h | 2 +- hphp/compiler/analysis/control_flow.cpp | 8 ++++---- hphp/compiler/analysis/control_flow.h | 5 ++++- hphp/compiler/analysis/data_flow.h | 2 +- hphp/compiler/analysis/dictionary.h | 2 +- hphp/compiler/analysis/expr_dict.h | 4 ++-- hphp/compiler/analysis/function_scope.h | 7 +++++-- hphp/compiler/analysis/live_dict.cpp | 6 +++--- hphp/compiler/analysis/live_dict.h | 2 +- hphp/compiler/analysis/ref_dict.h | 4 ++-- hphp/compiler/analysis/symbol_table.h | 4 ++-- hphp/compiler/analysis/type.h | 2 +- hphp/compiler/analysis/variable_table.h | 2 +- hphp/compiler/construct.cpp | 3 ++- hphp/compiler/construct.h | 2 +- hphp/compiler/expression/expression_list.h | 4 ++-- hphp/compiler/expression/function_call.cpp | 5 ++++- hphp/compiler/expression/modifier_expression.h | 2 +- hphp/compiler/expression/static_class_name.h | 2 +- hphp/compiler/package.h | 4 +++- hphp/compiler/statement/loop_statement.h | 2 +- hphp/compiler/statement/statement_list.h | 2 +- 27 files changed, 65 insertions(+), 51 deletions(-) diff --git a/hphp/compiler/analysis/alias_manager.cpp b/hphp/compiler/analysis/alias_manager.cpp index 7cbaad532..1d1de4212 100644 --- a/hphp/compiler/analysis/alias_manager.cpp +++ b/hphp/compiler/analysis/alias_manager.cpp @@ -263,7 +263,7 @@ void AliasManager::beginScope() { ExpressionPtr e(new ScalarExpression(BlockScopePtr(), LocationPtr(), T_STRING, string("begin"))); m_accessList.add(e); - m_stack.push_back(m_accessList.size()); + m_stack.push_back(CondStackElem(m_accessList.size())); m_accessList.beginScope(); if (BucketMapEntry *tail = m_bucketList) { BucketMapEntry *bm = tail; @@ -2504,7 +2504,7 @@ static void markAvailable(ExpressionRawPtr e) { class TypeAssertionInserter { public: - TypeAssertionInserter(AnalysisResultConstPtr ar) : + explicit TypeAssertionInserter(AnalysisResultConstPtr ar) : m_ar(ar), m_changed(false) { BuildAssertionMap(); } diff --git a/hphp/compiler/analysis/alias_manager.h b/hphp/compiler/analysis/alias_manager.h index cd44352b1..0f9a4b72f 100644 --- a/hphp/compiler/analysis/alias_manager.h +++ b/hphp/compiler/analysis/alias_manager.h @@ -88,7 +88,7 @@ class AliasManager { enum { SameAccess, SameLValueAccess, InterfAccess, DisjointAccess, NotAccess }; - AliasManager(int opt); + explicit AliasManager(int opt); ~AliasManager(); void clear(); @@ -141,7 +141,7 @@ class AliasManager { enum { FallThrough, CondBranch, Branch, Converge }; enum { NoCopyProp = 1, NoDeadStore = 2 }; struct CondStackElem { - CondStackElem(size_t s = 0) : m_size(s), m_exprs() {} + explicit CondStackElem(size_t s = 0) : m_size(s), m_exprs() {} size_t m_size; ExpressionPtrList m_exprs; }; @@ -154,7 +154,7 @@ class AliasManager { class LoopInfo { public: - LoopInfo(StatementPtr s); + explicit LoopInfo(StatementPtr s); StatementPtr m_stmt; StatementPtrVec m_inner; diff --git a/hphp/compiler/analysis/analysis_result.cpp b/hphp/compiler/analysis/analysis_result.cpp index fca42f8da..aa9654317 100644 --- a/hphp/compiler/analysis/analysis_result.cpp +++ b/hphp/compiler/analysis/analysis_result.cpp @@ -853,9 +853,11 @@ struct OptVisitor { OptVisitor(AnalysisResultPtr ar, unsigned nscope) : m_ar(ar), m_nscope(nscope), m_dispatcher(0) { } - OptVisitor(const Visitor &po) : m_ar(po.m_ar), - m_nscope(po.m_nscope), - m_dispatcher(po.m_dispatcher) { + /* implicit */ OptVisitor(const Visitor &po) + : m_ar(po.m_ar) + , m_nscope(po.m_nscope) + , m_dispatcher(po.m_dispatcher) + { const_cast(po).m_dispatcher = 0; } ~OptVisitor() { diff --git a/hphp/compiler/analysis/analysis_result.h b/hphp/compiler/analysis/analysis_result.h index 95f1543f6..4927b765d 100644 --- a/hphp/compiler/analysis/analysis_result.h +++ b/hphp/compiler/analysis/analysis_result.h @@ -91,12 +91,12 @@ public: class Locker { public: - Locker(const AnalysisResult *ar) : + explicit Locker(const AnalysisResult *ar) : m_ar(const_cast(ar)), m_mutex(m_ar->getMutex()) { m_mutex.lock(); } - Locker(AnalysisResultConstPtr ar) : + explicit Locker(AnalysisResultConstPtr ar) : m_ar(const_cast(ar.get())), m_mutex(m_ar->getMutex()) { m_mutex.lock(); @@ -399,7 +399,7 @@ private: class RescheduleException : public Exception { public: - RescheduleException(BlockScopeRawPtr scope) : + explicit RescheduleException(BlockScopeRawPtr scope) : Exception(), m_scope(scope) {} BlockScopeRawPtr &getScope() { return m_scope; } #ifdef HPHP_INSTRUMENT_TYPE_INF @@ -413,7 +413,7 @@ private: class SetCurrentScope { public: - SetCurrentScope(BlockScopeRawPtr scope) { + explicit SetCurrentScope(BlockScopeRawPtr scope) { assert(!((*AnalysisResult::s_currentScopeThreadLocal).get())); *AnalysisResult::s_currentScopeThreadLocal = scope; scope->setInVisitScopes(true); @@ -499,9 +499,9 @@ private: } } #else - BaseTryLock(BlockScopeRawPtr scopeToLock, - bool lockCondition = true, - bool profile = true) + explicit BaseTryLock(BlockScopeRawPtr scopeToLock, + bool lockCondition = true, + bool profile = true) : m_profiler(profile), m_mutex(scopeToLock->getInferTypesMutex()), m_acquired(false) { @@ -536,8 +536,8 @@ public: bool profile = true) : BaseTryLock(scopeToLock, fromFunction, fromLine, true, profile) {} #else - TryLock(BlockScopeRawPtr scopeToLock, - bool profile = true) : + explicit TryLock(BlockScopeRawPtr scopeToLock, + bool profile = true) : BaseTryLock(scopeToLock, true, profile) {} #endif /* HPHP_INSTRUMENT_TYPE_INF */ }; diff --git a/hphp/compiler/analysis/ast_walker.h b/hphp/compiler/analysis/ast_walker.h index 281fd5df8..864ad8bb0 100644 --- a/hphp/compiler/analysis/ast_walker.h +++ b/hphp/compiler/analysis/ast_walker.h @@ -26,7 +26,7 @@ namespace HPHP { class AstWalkerState { public: AstWalkerState() : index(0) {} - AstWalkerState(ConstructRawPtr c) : cp(c), index(0) {} + explicit AstWalkerState(ConstructRawPtr c) : cp(c), index(0) {} friend bool operator==(const AstWalkerState &s1, const AstWalkerState &s2) { @@ -40,7 +40,7 @@ public: class AstWalkerStateVec : public std::vector { public: AstWalkerStateVec() {} - AstWalkerStateVec(ConstructRawPtr cp) { + explicit AstWalkerStateVec(ConstructRawPtr cp) { push_back(AstWalkerState(cp)); } }; diff --git a/hphp/compiler/analysis/constant_table.h b/hphp/compiler/analysis/constant_table.h index cddc9d3e9..8020a739e 100644 --- a/hphp/compiler/analysis/constant_table.h +++ b/hphp/compiler/analysis/constant_table.h @@ -37,7 +37,7 @@ DECLARE_BOOST_TYPES(ClassScope); */ class ConstantTable : public SymbolTable { public: - ConstantTable(BlockScope &blockScope); + explicit ConstantTable(BlockScope &blockScope); /** * Whether defining something to be non-scalar value or redeclared, or diff --git a/hphp/compiler/analysis/control_flow.cpp b/hphp/compiler/analysis/control_flow.cpp index 5ff53ca68..3acd9487a 100644 --- a/hphp/compiler/analysis/control_flow.cpp +++ b/hphp/compiler/analysis/control_flow.cpp @@ -13,9 +13,11 @@ | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ */ +#include "compiler/analysis/control_flow.h" + +#include #include "compiler/analysis/ast_walker.h" -#include "compiler/analysis/control_flow.h" #include "compiler/analysis/data_flow.h" #include "compiler/expression/expression.h" #include "compiler/expression/binary_op_expression.h" @@ -37,8 +39,6 @@ #include "compiler/statement/goto_statement.h" #include "compiler/statement/case_statement.h" -#include - namespace HPHP { /////////////////////////////////////////////////////////////////////////////// @@ -182,7 +182,7 @@ public: class dfs_dump : public boost::default_dfs_visitor { public: - dfs_dump(AnalysisResultConstPtr ar) : m_ar(ar) {} + explicit dfs_dump(AnalysisResultConstPtr ar) : m_ar(ar) {} void discover_vertex(ControlFlowGraph::vertex_descriptor u, const ControlFlowGraph &g) { diff --git a/hphp/compiler/analysis/control_flow.h b/hphp/compiler/analysis/control_flow.h index 3a3ad181e..e1909bba7 100644 --- a/hphp/compiler/analysis/control_flow.h +++ b/hphp/compiler/analysis/control_flow.h @@ -309,7 +309,10 @@ inline void put(boost::vertex_color_t c, class ControlFlowGraphWalker : public FunctionWalker { public: - ControlFlowGraphWalker(ControlFlowGraph *g) : m_block(0), m_graph(*g) {} + explicit ControlFlowGraphWalker(ControlFlowGraph *g) + : m_block(0) + , m_graph(*g) + {} template void walk(T &t) { std::pair void walk(T &t) { ControlFlowGraphWalker::walk(t); } diff --git a/hphp/compiler/analysis/dictionary.h b/hphp/compiler/analysis/dictionary.h index 38e7de8d7..a81a04df9 100644 --- a/hphp/compiler/analysis/dictionary.h +++ b/hphp/compiler/analysis/dictionary.h @@ -32,7 +32,7 @@ class Dictionary { public: typedef std::vector IdMap; - Dictionary(AliasManager &am); + explicit Dictionary(AliasManager &am); void build(MethodStatementPtr s); void build(StatementPtr s); void build(ExpressionPtr s); diff --git a/hphp/compiler/analysis/expr_dict.h b/hphp/compiler/analysis/expr_dict.h index fb454a91b..225e1cf27 100644 --- a/hphp/compiler/analysis/expr_dict.h +++ b/hphp/compiler/analysis/expr_dict.h @@ -27,7 +27,7 @@ typedef std::vector TypePtrIdxPairVec; class ExprDict : public Dictionary { public: - ExprDict(AliasManager &am); + explicit ExprDict(AliasManager &am); /* Building the dictionary */ void build(MethodStatementPtr m); void visit(ExpressionPtr e); @@ -43,8 +43,8 @@ public: TypePtr propagateType(ExpressionPtr e); void getTypes(ExpressionPtr e, TypePtrIdxPairVec &types); -private: +private: /** * types is filled with (type assertion, canon id for that type assertion) * tuples diff --git a/hphp/compiler/analysis/function_scope.h b/hphp/compiler/analysis/function_scope.h index a741c13da..375069f4b 100644 --- a/hphp/compiler/analysis/function_scope.h +++ b/hphp/compiler/analysis/function_scope.h @@ -398,8 +398,11 @@ public: class FunctionInfo { public: - FunctionInfo(int rva = -1) : m_maybeStatic(false), m_maybeRefReturn(false), - m_refVarArg(rva) { } + explicit FunctionInfo(int rva = -1) + : m_maybeStatic(false) + , m_maybeRefReturn(false) + , m_refVarArg(rva) + {} bool isRefParam(int p) const { if (m_refVarArg >= 0 && p >= m_refVarArg) return true; diff --git a/hphp/compiler/analysis/live_dict.cpp b/hphp/compiler/analysis/live_dict.cpp index a3a2e92a8..0e65384b6 100644 --- a/hphp/compiler/analysis/live_dict.cpp +++ b/hphp/compiler/analysis/live_dict.cpp @@ -326,10 +326,10 @@ void LiveDict::updateAccess(ExpressionPtr e) { } struct Colorizer { - Colorizer(int w) : toNode(w) {} + explicit Colorizer(int w) : toNode(w) {} struct NodeInfo { - NodeInfo(int index) : originalIndex(index), size(0), color(-1) {} + explicit NodeInfo(int index) : originalIndex(index), size(0), color(-1) {} int originalIndex; int size; int color; @@ -359,7 +359,7 @@ struct Colorizer { class NodeCmp { public: - NodeCmp(const Colorizer *c) : m_c(c) {} + explicit NodeCmp(const Colorizer *c) : m_c(c) {} bool operator()(int a, int b) { const NodeInfo &n1 = m_c->nodes[a]; const NodeInfo &n2 = m_c->nodes[b]; diff --git a/hphp/compiler/analysis/live_dict.h b/hphp/compiler/analysis/live_dict.h index 8be8400a3..c9ab092d0 100644 --- a/hphp/compiler/analysis/live_dict.h +++ b/hphp/compiler/analysis/live_dict.h @@ -26,7 +26,7 @@ namespace HPHP { class LiveDict : public Dictionary { public: - LiveDict(AliasManager &am) : Dictionary(am) {} + explicit LiveDict(AliasManager &am) : Dictionary(am) {} /* Building the dictionary */ void build(MethodStatementPtr m); void visit(ExpressionPtr e); diff --git a/hphp/compiler/analysis/ref_dict.h b/hphp/compiler/analysis/ref_dict.h index bcecf7b77..562f56b08 100644 --- a/hphp/compiler/analysis/ref_dict.h +++ b/hphp/compiler/analysis/ref_dict.h @@ -24,7 +24,7 @@ namespace HPHP { class RefDict : public Dictionary { public: - RefDict(AliasManager &am) : Dictionary(am), first_pass(true) {} + explicit RefDict(AliasManager &am) : Dictionary(am), first_pass(true) {} /* Building the dictionary */ void build(MethodStatementPtr m); @@ -52,7 +52,7 @@ private: class RefDictWalker : public ControlFlowGraphWalker { public: - RefDictWalker(ControlFlowGraph *g) : + explicit RefDictWalker(ControlFlowGraph *g) : ControlFlowGraphWalker(g), first_pass(true) {} void walk() { ControlFlowGraphWalker::walk(*this); } int after(ConstructRawPtr cp); diff --git a/hphp/compiler/analysis/symbol_table.h b/hphp/compiler/analysis/symbol_table.h index a282a36e6..02c656e76 100644 --- a/hphp/compiler/analysis/symbol_table.h +++ b/hphp/compiler/analysis/symbol_table.h @@ -254,7 +254,7 @@ private: class SymParamWrapper : public JSON::DocTarget::ISerializable { public: - SymParamWrapper(const Symbol* sym) : m_sym(sym) { + explicit SymParamWrapper(const Symbol* sym) : m_sym(sym) { assert(sym); } virtual void serialize(JSON::DocTarget::OutputStream &out) const { @@ -266,7 +266,7 @@ private: class SymClassVarWrapper : public JSON::DocTarget::ISerializable { public: - SymClassVarWrapper(const Symbol* sym) : m_sym(sym) { + explicit SymClassVarWrapper(const Symbol* sym) : m_sym(sym) { assert(sym); } virtual void serialize(JSON::DocTarget::OutputStream &out) const { diff --git a/hphp/compiler/analysis/type.h b/hphp/compiler/analysis/type.h index 417bbac18..5f6dcbfbf 100644 --- a/hphp/compiler/analysis/type.h +++ b/hphp/compiler/analysis/type.h @@ -201,7 +201,7 @@ public: /** * KindOf testing. */ - Type(KindOf kindOf); + explicit Type(KindOf kindOf); bool is(KindOf kindOf) const { return m_kindOf == kindOf;} bool isExactType() const { return IsExactType(m_kindOf); } bool mustBe(KindOf kindOf) const { return !(m_kindOf & ~kindOf); } diff --git a/hphp/compiler/analysis/variable_table.h b/hphp/compiler/analysis/variable_table.h index 3e9ceec5b..ef4116171 100644 --- a/hphp/compiler/analysis/variable_table.h +++ b/hphp/compiler/analysis/variable_table.h @@ -100,7 +100,7 @@ public: } public: - VariableTable(BlockScope &blockScope); + explicit VariableTable(BlockScope &blockScope); /** * Get/set attributes. diff --git a/hphp/compiler/construct.cpp b/hphp/compiler/construct.cpp index 6c03dd82f..935a8c481 100644 --- a/hphp/compiler/construct.cpp +++ b/hphp/compiler/construct.cpp @@ -454,7 +454,8 @@ private: void Construct::dump(int spc, AnalysisResultConstPtr ar) { ConstructDumper cd(spc, ar); - cd.walk(ConstructRawPtr(this), ConstructRawPtr(), ConstructRawPtr()); + cd.walk(AstWalkerStateVec(ConstructRawPtr(this)), + ConstructRawPtr(), ConstructRawPtr()); } void Construct::dump(int spc, AnalysisResultConstPtr ar, bool functionOnly, diff --git a/hphp/compiler/construct.h b/hphp/compiler/construct.h index 0a76ffaff..ded092bd7 100644 --- a/hphp/compiler/construct.h +++ b/hphp/compiler/construct.h @@ -314,7 +314,7 @@ public: int getLocalEffects() const { return m_localEffects; } virtual void effectsCallback() = 0; protected: - LocalEffectsContainer(Construct::Effect localEffect) : + explicit LocalEffectsContainer(Construct::Effect localEffect) : m_localEffects(localEffect) {} LocalEffectsContainer() : m_localEffects(0) {} diff --git a/hphp/compiler/expression/expression_list.h b/hphp/compiler/expression/expression_list.h index 47aa0d6fa..10bd0be31 100644 --- a/hphp/compiler/expression/expression_list.h +++ b/hphp/compiler/expression/expression_list.h @@ -33,8 +33,8 @@ public: ListKindLeft }; - ExpressionList(EXPRESSION_CONSTRUCTOR_PARAMETERS, - ListKind kind = ListKindParam); + explicit ExpressionList(EXPRESSION_CONSTRUCTOR_PARAMETERS, + ListKind kind = ListKindParam); // change case to lower so to make it case insensitive void toLower(); diff --git a/hphp/compiler/expression/function_call.cpp b/hphp/compiler/expression/function_call.cpp index fac1b8e64..67ff206bf 100644 --- a/hphp/compiler/expression/function_call.cpp +++ b/hphp/compiler/expression/function_call.cpp @@ -208,7 +208,10 @@ void FunctionCall::analyzeProgram(AnalysisResultPtr ar) { } struct InlineCloneInfo { - InlineCloneInfo(FunctionScopePtr fs) : func(fs), callWithThis(false) {} + explicit InlineCloneInfo(FunctionScopePtr fs) + : func(fs) + , callWithThis(false) + {} FunctionScopePtr func; StringToExpressionPtrMap sepm; diff --git a/hphp/compiler/expression/modifier_expression.h b/hphp/compiler/expression/modifier_expression.h index 29a960272..12999fe9d 100644 --- a/hphp/compiler/expression/modifier_expression.h +++ b/hphp/compiler/expression/modifier_expression.h @@ -26,7 +26,7 @@ DECLARE_BOOST_TYPES(ModifierExpression); class ModifierExpression : public Expression { public: - ModifierExpression(EXPRESSION_CONSTRUCTOR_PARAMETERS); + explicit ModifierExpression(EXPRESSION_CONSTRUCTOR_PARAMETERS); DECLARE_BASE_EXPRESSION_VIRTUAL_FUNCTIONS; diff --git a/hphp/compiler/expression/static_class_name.h b/hphp/compiler/expression/static_class_name.h index df86b4d00..3aa170688 100644 --- a/hphp/compiler/expression/static_class_name.h +++ b/hphp/compiler/expression/static_class_name.h @@ -24,7 +24,7 @@ namespace HPHP { class StaticClassName : public IParseHandler { public: - StaticClassName(ExpressionPtr classExp); + explicit StaticClassName(ExpressionPtr classExp); void onParse(AnalysisResultConstPtr ar, FileScopePtr scope); diff --git a/hphp/compiler/package.h b/hphp/compiler/package.h index ab4e6b8ba..78339ab31 100644 --- a/hphp/compiler/package.h +++ b/hphp/compiler/package.h @@ -37,7 +37,9 @@ DECLARE_BOOST_TYPES(AnalysisResult); */ class Package { public: - Package(const char *root, bool bShortTags = true, bool bAspTags = false); + explicit Package(const char *root, + bool bShortTags = true, + bool bAspTags = false); void addAllFiles(bool force); // add from Option::PackageDirectories/Files diff --git a/hphp/compiler/statement/loop_statement.h b/hphp/compiler/statement/loop_statement.h index 70264bd79..09174415b 100644 --- a/hphp/compiler/statement/loop_statement.h +++ b/hphp/compiler/statement/loop_statement.h @@ -26,7 +26,7 @@ DECLARE_BOOST_TYPES(LoopStatement); class LoopStatement : public Statement { protected: - LoopStatement(STATEMENT_CONSTRUCTOR_BASE_PARAMETERS); + explicit LoopStatement(STATEMENT_CONSTRUCTOR_BASE_PARAMETERS); public: void clearStringBufs(); void addStringBuf(const std::string &name); diff --git a/hphp/compiler/statement/statement_list.h b/hphp/compiler/statement/statement_list.h index dbf17c879..7123b7389 100644 --- a/hphp/compiler/statement/statement_list.h +++ b/hphp/compiler/statement/statement_list.h @@ -26,7 +26,7 @@ DECLARE_BOOST_TYPES(StatementList); class StatementList : public Statement { public: - StatementList(STATEMENT_CONSTRUCTOR_PARAMETERS); + explicit StatementList(STATEMENT_CONSTRUCTOR_PARAMETERS); DECLARE_STATEMENT_VIRTUAL_FUNCTIONS; StatementPtr preOptimize(AnalysisResultConstPtr ar);