From a70b1bf8f79e969fa40abc87153c5c5418a3bbc4 Mon Sep 17 00:00:00 2001 From: Jordan DeLong Date: Sat, 20 Apr 2013 14:04:42 -0700 Subject: [PATCH] Ad few more lint fixes under runtime/vm/translator --- hphp/runtime/vm/translator/asm-x64-test.h | 4 +++ hphp/runtime/vm/translator/hopt/codegen.h | 3 +- hphp/runtime/vm/translator/hopt/memelim.cpp | 6 ++-- hphp/runtime/vm/translator/hopt/nativecalls.h | 2 +- .../runtime/vm/translator/hopt/tracebuilder.h | 6 ++-- hphp/runtime/vm/translator/physreg.h | 6 ++-- hphp/runtime/vm/translator/regalloc.cpp | 5 ++- hphp/runtime/vm/translator/regalloc.h | 14 +++++--- hphp/runtime/vm/translator/runtime-type.cpp | 4 +-- hphp/runtime/vm/translator/runtime-type.h | 36 ++++++++++--------- hphp/runtime/vm/translator/srcdb.cpp | 2 +- .../runtime/vm/translator/translator-inline.h | 2 +- hphp/runtime/vm/translator/translator-x64.cpp | 10 +++--- hphp/runtime/vm/translator/translator.cpp | 35 +++++++++--------- hphp/runtime/vm/translator/translator.h | 7 ++-- hphp/runtime/vm/translator/writelease.h | 6 ++-- 16 files changed, 82 insertions(+), 66 deletions(-) diff --git a/hphp/runtime/vm/translator/asm-x64-test.h b/hphp/runtime/vm/translator/asm-x64-test.h index e99d2bff1..1ae0b9c12 100644 --- a/hphp/runtime/vm/translator/asm-x64-test.h +++ b/hphp/runtime/vm/translator/asm-x64-test.h @@ -13,6 +13,8 @@ | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ */ +#ifndef incl_HPHP_ASM_X64_TEST_H_ +#define incl_HPHP_ASM_X64_TEST_H_ namespace HPHP { namespace x64 { @@ -24,3 +26,5 @@ void testEmitMethods(); } } +#endif + diff --git a/hphp/runtime/vm/translator/hopt/codegen.h b/hphp/runtime/vm/translator/hopt/codegen.h index 4df0a007d..5bc0d0dbb 100644 --- a/hphp/runtime/vm/translator/hopt/codegen.h +++ b/hphp/runtime/vm/translator/hopt/codegen.h @@ -54,7 +54,7 @@ enum SyncOptions { // Information about where code was generated, for pretty-printing. struct AsmInfo { - AsmInfo(const IRFactory* factory) + explicit AsmInfo(const IRFactory* factory) : instRanges(factory, TcaRange(nullptr, nullptr)) , asmRanges(factory, TcaRange(nullptr, nullptr)) , astubRanges(factory, TcaRange(nullptr, nullptr)) @@ -464,7 +464,6 @@ private: std::vector m_args; }; -using namespace HPHP::VM::Transl::TargetCache; ActRec* irNewInstanceHelper(Class* cls, int numArgs, Cell* sp, diff --git a/hphp/runtime/vm/translator/hopt/memelim.cpp b/hphp/runtime/vm/translator/hopt/memelim.cpp index 96bef3c35..1a34cef06 100644 --- a/hphp/runtime/vm/translator/hopt/memelim.cpp +++ b/hphp/runtime/vm/translator/hopt/memelim.cpp @@ -32,7 +32,7 @@ namespace { class MemMap { public: - MemMap(IRFactory* factory) + explicit MemMap(IRFactory* factory) : m_factory(factory) , m_liveInsts(factory->numInsts()) { assert(factory != nullptr); @@ -71,7 +71,7 @@ private: // it can also track the reference count of the box for better availability // analysis. and when the object gets to a ref count of 0 it will be destroyed struct RefInfo : public Counted { - RefInfo(IRInstruction* inst, bool killValue = false) { + explicit RefInfo(IRInstruction* inst, bool killValue = false) { update(inst, killValue); } @@ -86,7 +86,7 @@ private: }; struct LocInfo : public Counted { - LocInfo(IRInstruction* inst, bool killValue = false) { + explicit LocInfo(IRInstruction* inst, bool killValue = false) { update(inst, killValue); } diff --git a/hphp/runtime/vm/translator/hopt/nativecalls.h b/hphp/runtime/vm/translator/hopt/nativecalls.h index d47becf72..dd0146c6e 100644 --- a/hphp/runtime/vm/translator/hopt/nativecalls.h +++ b/hphp/runtime/vm/translator/hopt/nativecalls.h @@ -36,7 +36,7 @@ enum FuncType : unsigned { struct FuncPtr { FuncPtr() {} - FuncPtr(TCA f) : type(FPtr), ptr(f) {} + /* implicit */ FuncPtr(TCA f) : type(FPtr), ptr(f) {} FuncPtr(FuncType t, uint64_t i) : type(t), srcIdx(i) { assert(t == FSSA); } FuncType type; diff --git a/hphp/runtime/vm/translator/hopt/tracebuilder.h b/hphp/runtime/vm/translator/hopt/tracebuilder.h index a6ec84e95..040b93656 100644 --- a/hphp/runtime/vm/translator/hopt/tracebuilder.h +++ b/hphp/runtime/vm/translator/hopt/tracebuilder.h @@ -311,9 +311,9 @@ public: } struct DisableCseGuard { - DisableCseGuard(TraceBuilder& tb) - : m_tb(tb) - , m_oldEnable(tb.m_enableCse) + explicit DisableCseGuard(TraceBuilder& tb) + : m_tb(tb) + , m_oldEnable(tb.m_enableCse) { m_tb.m_enableCse = false; } diff --git a/hphp/runtime/vm/translator/physreg.h b/hphp/runtime/vm/translator/physreg.h index dc6c746e7..bd9cb73f2 100644 --- a/hphp/runtime/vm/translator/physreg.h +++ b/hphp/runtime/vm/translator/physreg.h @@ -37,13 +37,13 @@ namespace HPHP { namespace VM { namespace Transl { */ struct PhysReg { explicit constexpr PhysReg(int n = -1) : n(n) {} - /* implicit */ constexpr PhysReg(Reg64 r) : n(int(r)) {} + constexpr /* implicit */ PhysReg(Reg64 r) : n(int(r)) {} explicit constexpr PhysReg(Reg32 r) : n(int(RegNumber(r))) {} explicit constexpr PhysReg(RegNumber r) : n(int(r)) {} - constexpr operator Reg64() const { return Reg64(n); } - constexpr operator RegNumber() const { return RegNumber(n); } + constexpr /* implicit */ operator Reg64() const { return Reg64(n); } + constexpr /* implicit */ operator RegNumber() const { return RegNumber(n); } explicit constexpr operator int() const { return n; } constexpr bool operator==(PhysReg r) const { return n == r.n; } diff --git a/hphp/runtime/vm/translator/regalloc.cpp b/hphp/runtime/vm/translator/regalloc.cpp index af4f043bb..d5c7e04c4 100644 --- a/hphp/runtime/vm/translator/regalloc.cpp +++ b/hphp/runtime/vm/translator/regalloc.cpp @@ -13,13 +13,16 @@ | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ */ +#define __STDC_FORMAT_MACROS + +#include "runtime/vm/translator/regalloc.h" #include +#include #include #include "runtime/base/types.h" #include "util/trace.h" -#include "regalloc.h" namespace HPHP { namespace VM { namespace Transl { diff --git a/hphp/runtime/vm/translator/regalloc.h b/hphp/runtime/vm/translator/regalloc.h index 11f1dbde2..bd9989715 100644 --- a/hphp/runtime/vm/translator/regalloc.h +++ b/hphp/runtime/vm/translator/regalloc.h @@ -51,10 +51,14 @@ struct RegContent { int64_t m_int; Location m_loc; - RegContent(const Location &loc, int64_t intval = 0) - : m_kind(Loc), m_int(intval), m_loc(loc) { } + explicit RegContent(const Location &loc, int64_t intval = 0) + : m_kind(Loc), m_int(intval), m_loc(loc) {} - RegContent(int64_t _m_int) : m_kind(Int), m_int(_m_int), m_loc(Location()) { } + explicit RegContent(int64_t _m_int) + : m_kind(Int) + , m_int(_m_int) + , m_loc(Location()) + {} RegContent() : m_kind(Invalid), m_int(0), m_loc(Location()) { } @@ -419,7 +423,7 @@ class LazyScratchReg : boost::noncopyable { RegAlloc& m_regMap; PhysReg m_reg; public: - LazyScratchReg(RegAlloc& regMap); + explicit LazyScratchReg(RegAlloc& regMap); ~LazyScratchReg(); bool isAllocated() const { return m_reg != reg::noreg; } @@ -436,7 +440,7 @@ class LazyScratchReg : boost::noncopyable { class ScratchReg : public LazyScratchReg { public: - ScratchReg(RegAlloc& regMap); + explicit ScratchReg(RegAlloc& regMap); // Use this constructor to reserve an already-selected register, which // must be free. ScratchReg(RegAlloc& regMap, PhysReg pr); diff --git a/hphp/runtime/vm/translator/runtime-type.cpp b/hphp/runtime/vm/translator/runtime-type.cpp index 13eab61a7..6a90a3122 100644 --- a/hphp/runtime/vm/translator/runtime-type.cpp +++ b/hphp/runtime/vm/translator/runtime-type.cpp @@ -13,14 +13,14 @@ | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ */ +#include "runtime/vm/translator/runtime-type.h" #include #include #include #include "runtime/vm/bytecode.h" #include "runtime/base/types.h" -#include "runtime-type.h" -#include "translator.h" +#include "runtime/vm/translator/translator.h" namespace HPHP { namespace VM { diff --git a/hphp/runtime/vm/translator/runtime-type.h b/hphp/runtime/vm/translator/runtime-type.h index 3a10df069..4852f7562 100644 --- a/hphp/runtime/vm/translator/runtime-type.h +++ b/hphp/runtime/vm/translator/runtime-type.h @@ -37,10 +37,12 @@ struct Location { This, // $this in the current frame }; - Location(Space spc) - : space(spc) - , offset(0) - { assert(spc == This); } + explicit Location(Space spc) + : space(spc) + , offset(0) + { + assert(spc == This); + } Location(Space spc, int64_t off) : space(spc) @@ -125,12 +127,12 @@ public: }; struct InputInfo { - InputInfo(const Location &l) - : loc(l), - dontBreak(false), - dontGuard(l.isLiteral()), - dontGuardInner(false) - {} + explicit InputInfo(const Location &l) + : loc(l) + , dontBreak(false) + , dontGuard(l.isLiteral()) + , dontGuardInner(false) + {} std::string pretty() const { std::string p = loc.pretty(); @@ -228,17 +230,17 @@ class RuntimeType { } public: - RuntimeType(DataType outer, DataType inner = KindOfInvalid, - const Class* = nullptr); - RuntimeType(const StringData*); - RuntimeType(const ArrayData*); - RuntimeType(const Class*); + explicit RuntimeType(DataType outer, DataType inner = KindOfInvalid, + const Class* = nullptr); + explicit RuntimeType(const StringData*); + explicit RuntimeType(const ArrayData*); + explicit RuntimeType(const Class*); explicit RuntimeType(bool value); explicit RuntimeType(int64_t value); RuntimeType(const RuntimeType& copy); RuntimeType(); - RuntimeType(const Iter* iter); - RuntimeType(ArrayIter::Type type); + explicit RuntimeType(const Iter* iter); + explicit RuntimeType(ArrayIter::Type type); static const int UnknownBool = -1; diff --git a/hphp/runtime/vm/translator/srcdb.cpp b/hphp/runtime/vm/translator/srcdb.cpp index 6826e7785..f7f3434d0 100644 --- a/hphp/runtime/vm/translator/srcdb.cpp +++ b/hphp/runtime/vm/translator/srcdb.cpp @@ -13,6 +13,7 @@ | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ */ +#include "runtime/vm/translator/srcdb.h" #include #include @@ -21,7 +22,6 @@ #include "util/base.h" #include "util/trace.h" #include "runtime/vm/translator/translator-x64.h" -#include "srcdb.h" namespace HPHP { namespace VM { diff --git a/hphp/runtime/vm/translator/translator-inline.h b/hphp/runtime/vm/translator/translator-inline.h index 91066b120..153f69a1d 100644 --- a/hphp/runtime/vm/translator/translator-inline.h +++ b/hphp/runtime/vm/translator/translator-inline.h @@ -90,7 +90,7 @@ struct VMRegAnchor : private boost::noncopyable { m_old = tl_regState; Translator::Get()->sync(); } - VMRegAnchor(ActRec* ar) { + explicit VMRegAnchor(ActRec* ar) { // Some C++ entry points have an ActRec prepared from after a call // instruction. This syncs us to right after the call instruction. assert(tl_regState == REGSTATE_DIRTY); diff --git a/hphp/runtime/vm/translator/translator-x64.cpp b/hphp/runtime/vm/translator/translator-x64.cpp index 1cca00bc7..cefa99ee4 100644 --- a/hphp/runtime/vm/translator/translator-x64.cpp +++ b/hphp/runtime/vm/translator/translator-x64.cpp @@ -14,6 +14,9 @@ +----------------------------------------------------------------------+ */ #define __STDC_FORMAT_MACROS + +#include "runtime/vm/translator/translator-x64.h" + #include #include #include @@ -76,7 +79,6 @@ typedef __sighandler_t *sighandler_t; #include "runtime/vm/translator/targetcache.h" #include "runtime/vm/translator/translator-deps.h" #include "runtime/vm/translator/translator-inline.h" -#include "runtime/vm/translator/translator-x64.h" #include "runtime/vm/translator/srcdb.h" #include "runtime/vm/translator/x64-util.h" #include "runtime/vm/translator/unwind-x64.h" @@ -3017,7 +3019,7 @@ TranslatorX64::emitRetFromInterpretedGeneratorFrame() { class FreeRequestStubTrigger : public Treadmill::WorkItem { TCA m_stub; public: - FreeRequestStubTrigger(TCA stub) : m_stub(stub) { + explicit FreeRequestStubTrigger(TCA stub) : m_stub(stub) { TRACE(3, "FreeStubTrigger @ %p, stub %p\n", this, m_stub); } virtual void operator()() { @@ -11863,7 +11865,7 @@ namespace { struct DeferredFileInvalidate : public DeferredWorkItem { Eval::PhpFile* m_f; - DeferredFileInvalidate(Eval::PhpFile* f) : m_f(f) { + explicit DeferredFileInvalidate(Eval::PhpFile* f) : m_f(f) { TRACE(2, "DeferredFileInvalidate @ %p, m_f %p\n", this, m_f); } void operator()() { TRACE(2, "DeferredFileInvalidate: Firing @ %p , m_f %p\n", this, m_f); @@ -11873,7 +11875,7 @@ struct DeferredFileInvalidate : public DeferredWorkItem { struct DeferredPathInvalidate : public DeferredWorkItem { const std::string m_path; - DeferredPathInvalidate(const std::string& path) : m_path(path) { + explicit DeferredPathInvalidate(const std::string& path) : m_path(path) { assert(m_path.size() >= 1 && m_path[0] == '/'); } void operator()() { diff --git a/hphp/runtime/vm/translator/translator.cpp b/hphp/runtime/vm/translator/translator.cpp index 1109858b5..840f488c9 100644 --- a/hphp/runtime/vm/translator/translator.cpp +++ b/hphp/runtime/vm/translator/translator.cpp @@ -13,11 +13,13 @@ | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ */ +#define __STDC_FORMAT_MACROS + +#include "runtime/vm/translator/translator.h" // Translator front-end: parse instruction stream into basic blocks, decode // and normalize instructions. Propagate run-time type info to instructions // to annotate their inputs and outputs with types. -#define __STDC_FORMAT_MACROS #include #include #include @@ -35,7 +37,6 @@ #include "runtime/vm/hhbc.h" #include "runtime/vm/bytecode.h" #include "runtime/vm/translator/targetcache.h" -#include "runtime/vm/translator/translator.h" #include "runtime/vm/translator/translator-deps.h" #include "runtime/vm/translator/translator-inline.h" #include "runtime/vm/translator/translator-x64.h" @@ -499,7 +500,7 @@ static RuntimeType bitOpType(DynLocation* a, DynLocation* b) { vector ins; ins.push_back(a); if (b) ins.push_back(b); - return inferType(BitOpRules, ins); + return RuntimeType(inferType(BitOpRules, ins)); } static uint32_t m_w = 1; /* must not be zero */ @@ -1798,11 +1799,11 @@ static void addMVectorInputs(NormalizedInstruction& ni, auto push_stack = [&] { ++stackCount; - inputs.push_back(Location(Location::Stack, localStackOffset++)); + inputs.emplace_back(Location(Location::Stack, localStackOffset++)); }; auto push_local = [&] (int imm) { ++localCount; - inputs.push_back(Location(Location::Local, imm)); + inputs.emplace_back(Location(Location::Local, imm)); }; /* @@ -1827,7 +1828,7 @@ static void addMVectorInputs(NormalizedInstruction& ni, switch (numLocationCodeStackVals(lcode)) { case 0: { if (lcode == LH) { - inputs.push_back(Location(Location::This)); + inputs.emplace_back(Location(Location::This)); } else { assert(lcode == LL || lcode == LGL || lcode == LNL); int numImms = numLocationCodeImms(lcode); @@ -1867,10 +1868,10 @@ static void addMVectorInputs(NormalizedInstruction& ni, if (memberCodeImmIsLoc(mcode)) { push_local(imm); } else if (memberCodeImmIsString(mcode)) { - inputs.push_back(Location(Location::Litstr, imm)); + inputs.emplace_back(Location(Location::Litstr, imm)); } else { assert(memberCodeImmIsInt(mcode)); - inputs.push_back(Location(Location::Litint, imm)); + inputs.emplace_back(Location(Location::Litint, imm)); } } else { push_stack(); @@ -1925,7 +1926,7 @@ void Translator::getInputs(Tracelet& t, inputs.needsRefCheck = true; } if (input & Iter) { - inputs.push_back(Location(Location::Iter, ni->imm[0].u_IVA)); + inputs.emplace_back(Location(Location::Iter, ni->imm[0].u_IVA)); } if (input & FStack) { currentStackOffset -= ni->imm[0].u_IVA; // arguments consumed @@ -1934,15 +1935,15 @@ void Translator::getInputs(Tracelet& t, if (input & IgnoreInnerType) ni->ignoreInnerType = true; if (input & Stack1) { SKTRACE(1, sk, "getInputs: stack1 %d\n", currentStackOffset - 1); - inputs.push_back(Location(Location::Stack, --currentStackOffset)); + inputs.emplace_back(Location(Location::Stack, --currentStackOffset)); if (input & DontGuardStack1) inputs.back().dontGuard = true; if (input & DontBreakStack1) inputs.back().dontBreak = true; if (input & Stack2) { SKTRACE(1, sk, "getInputs: stack2 %d\n", currentStackOffset - 1); - inputs.push_back(Location(Location::Stack, --currentStackOffset)); + inputs.emplace_back(Location(Location::Stack, --currentStackOffset)); if (input & Stack3) { SKTRACE(1, sk, "getInputs: stack3 %d\n", currentStackOffset - 1); - inputs.push_back(Location(Location::Stack, --currentStackOffset)); + inputs.emplace_back(Location(Location::Stack, --currentStackOffset)); } } } @@ -1951,7 +1952,7 @@ void Translator::getInputs(Tracelet& t, SKTRACE(1, sk, "getInputs: stackN %d %d\n", currentStackOffset - 1, numArgs); for (int i = 0; i < numArgs; i++) { - inputs.push_back(Location(Location::Stack, --currentStackOffset)); + inputs.emplace_back(Location(Location::Stack, --currentStackOffset)); inputs.back().dontGuard = true; inputs.back().dontBreak = true; } @@ -1961,7 +1962,7 @@ void Translator::getInputs(Tracelet& t, SKTRACE(1, sk, "getInputs: BStackN %d %d\n", currentStackOffset - 1, numArgs); for (int i = 0; i < numArgs; i++) { - inputs.push_back(Location(Location::Stack, --currentStackOffset)); + inputs.emplace_back(Location(Location::Stack, --currentStackOffset)); } } if (input & MVector) { @@ -1991,7 +1992,7 @@ void Translator::getInputs(Tracelet& t, break; } SKTRACE(1, sk, "getInputs: local %d\n", loc); - inputs.push_back(Location(Location::Local, loc)); + inputs.emplace_back(Location(Location::Local, loc)); if (input & DontGuardLocal) inputs.back().dontGuard = true; if (input & DontBreakLocal) inputs.back().dontBreak = true; } @@ -2024,7 +2025,7 @@ void Translator::getInputs(Tracelet& t, int n = curFunc()->numLocals(); for (int i = 0; i < n; ++i) { if (!ni->nonRefCountedLocals[i]) { - inputs.push_back(Location(Location::Local, i)); + inputs.emplace_back(Location(Location::Local, i)); } } } @@ -2039,7 +2040,7 @@ void Translator::getInputs(Tracelet& t, } } if (input & This) { - inputs.push_back(Location(Location::This)); + inputs.emplace_back(Location(Location::This)); } } diff --git a/hphp/runtime/vm/translator/translator.h b/hphp/runtime/vm/translator/translator.h index e044c8892..4f4f95c97 100644 --- a/hphp/runtime/vm/translator/translator.h +++ b/hphp/runtime/vm/translator/translator.h @@ -491,9 +491,10 @@ class UnknownInputExc : public std::exception { class GuardType { public: - GuardType(DataType outer = KindOfInvalid, DataType inner = KindOfInvalid); - GuardType(const RuntimeType& rtt); - GuardType(const GuardType& other); + explicit GuardType(DataType outer = KindOfInvalid, + DataType inner = KindOfInvalid); + explicit GuardType(const RuntimeType& rtt); + GuardType(const GuardType& other); const DataType getOuterType() const; const DataType getInnerType() const; bool isSpecific() const; diff --git a/hphp/runtime/vm/translator/writelease.h b/hphp/runtime/vm/translator/writelease.h index 0eb54cd16..d854919a6 100644 --- a/hphp/runtime/vm/translator/writelease.h +++ b/hphp/runtime/vm/translator/writelease.h @@ -80,7 +80,7 @@ struct LeaseHolderBase { public: ~LeaseHolderBase(); - operator bool() const { return m_haveLock; } + explicit operator bool() const { return m_haveLock; } bool acquire(); private: @@ -89,11 +89,11 @@ struct LeaseHolderBase { bool m_acquired; }; struct LeaseHolder : public LeaseHolderBase { - LeaseHolder(Lease& l, LeaseAcquire acquire = ACQUIRE) + explicit LeaseHolder(Lease& l, LeaseAcquire acquire = ACQUIRE) : LeaseHolderBase(l, acquire, false) {} }; struct BlockingLeaseHolder : public LeaseHolderBase { - BlockingLeaseHolder(Lease& l) + explicit BlockingLeaseHolder(Lease& l) : LeaseHolderBase(l, ACQUIRE, true) {} };