Bug 1302401 - This check is responsible for using the auto type specifier for variable declarations to improve code readability and maintainability. draft
authorSylvestre Ledru <sylvestre@debian.org>
Tue, 13 Sep 2016 14:23:04 +0200
changeset 417995 3e7cf96f87d5cc7a9a43d4e1790457c5382be8f1
parent 417991 2a31f8aa21d956ee75d9292b320b2ee2332b3357
child 417996 41494dbb6afb0a986d75bf63bda54101132202eb
push id30554
push userbmo:sledru@mozilla.com
push dateTue, 27 Sep 2016 13:26:04 +0000
bugs1302401
milestone52.0a1
Bug 1302401 - This check is responsible for using the auto type specifier for variable declarations to improve code readability and maintainability. MozReview-Commit-ID: 5elj65A6dzO
js/src/jit/LIR.h
js/src/jit/MIR.h
js/xpconnect/src/XPCMaps.h
--- a/js/src/jit/LIR.h
+++ b/js/src/jit/LIR.h
@@ -1809,17 +1809,18 @@ class LIRGraph
     }
     LBlock* getBlock(size_t i) {
         return &blocks_[i];
     }
     uint32_t numBlockIds() const {
         return mir_.numBlockIds();
     }
     MOZ_MUST_USE bool initBlock(MBasicBlock* mir) {
-        LBlock* lir = new (&blocks_[mir->id()]) LBlock(mir);
+        auto* block = &blocks_[mir->id()];
+        auto* lir = new (block) LBlock(mir);
         return lir->init(mir_.alloc());
     }
     uint32_t getVirtualRegister() {
         numVirtualRegisters_ += VREG_INCREMENT;
         return numVirtualRegisters_;
     }
     uint32_t numVirtualRegisters() const {
         // Virtual registers are 1-based, not 0-based, so add one as a
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -6177,17 +6177,17 @@ class MAbs
         specialization_ = type;
     }
 
   public:
     INSTRUCTION_HEADER(Abs)
     TRIVIAL_NEW_WRAPPERS
 
     static MAbs* NewAsmJS(TempAllocator& alloc, MDefinition* num, MIRType type) {
-        MAbs* ins = new(alloc) MAbs(num, type);
+        auto* ins = new(alloc) MAbs(num, type);
         if (type == MIRType::Int32)
             ins->implicitTruncate_ = true;
         return ins;
     }
     bool congruentTo(const MDefinition* ins) const override {
         return congruentIfOperandsEqual(ins);
     }
     bool fallible() const;
@@ -6715,17 +6715,17 @@ class MAdd : public MBinaryArithInstruct
 
   public:
     INSTRUCTION_HEADER(Add)
     TRIVIAL_NEW_WRAPPERS
 
     static MAdd* NewAsmJS(TempAllocator& alloc, MDefinition* left, MDefinition* right,
                           MIRType type)
     {
-        MAdd* add = new(alloc) MAdd(left, right);
+        auto* add = new(alloc) MAdd(left, right);
         add->specialization_ = type;
         add->setResultType(type);
         if (type == MIRType::Int32) {
             add->setTruncateKind(Truncate);
             add->setCommutative();
         }
         return add;
     }
@@ -6760,17 +6760,17 @@ class MSub : public MBinaryArithInstruct
 
   public:
     INSTRUCTION_HEADER(Sub)
     TRIVIAL_NEW_WRAPPERS
 
     static MSub* NewAsmJS(TempAllocator& alloc, MDefinition* left, MDefinition* right,
                           MIRType type, bool mustPreserveNaN = false)
     {
-        MSub* sub = new(alloc) MSub(left, right);
+        auto* sub = new(alloc) MSub(left, right);
         sub->specialization_ = type;
         sub->setResultType(type);
         sub->setMustPreserveNaN(mustPreserveNaN);
         if (type == MIRType::Int32)
             sub->setTruncateKind(Truncate);
         return sub;
     }
 
@@ -6938,17 +6938,17 @@ class MDiv : public MBinaryArithInstruct
     }
     static MDiv* New(TempAllocator& alloc, MDefinition* left, MDefinition* right, MIRType type) {
         return new(alloc) MDiv(left, right, type);
     }
     static MDiv* NewAsmJS(TempAllocator& alloc, MDefinition* left, MDefinition* right,
                           MIRType type, bool unsignd, bool trapOnError = false,
                           bool mustPreserveNaN = false)
     {
-        MDiv* div = new(alloc) MDiv(left, right, type);
+        auto* div = new(alloc) MDiv(left, right, type);
         div->unsigned_ = unsignd;
         div->trapOnError_ = trapOnError;
         if (trapOnError)
             div->setGuard(); // not removable because of possible side-effects.
         div->setMustPreserveNaN(mustPreserveNaN);
         if (type == MIRType::Int32)
             div->setTruncateKind(Truncate);
         return div;
@@ -7065,17 +7065,17 @@ class MMod : public MBinaryArithInstruct
   public:
     INSTRUCTION_HEADER(Mod)
     static MMod* New(TempAllocator& alloc, MDefinition* left, MDefinition* right) {
         return new(alloc) MMod(left, right, MIRType::Value);
     }
     static MMod* NewAsmJS(TempAllocator& alloc, MDefinition* left, MDefinition* right,
                           MIRType type, bool unsignd, bool trapOnError = false)
     {
-        MMod* mod = new(alloc) MMod(left, right, type);
+        auto* mod = new(alloc) MMod(left, right, type);
         mod->unsigned_ = unsignd;
         mod->trapOnError_ = trapOnError;
         if (trapOnError)
             mod->setGuard(); // not removable because of possible side-effects.
         if (type == MIRType::Int32)
             mod->setTruncateKind(Truncate);
         return mod;
     }
@@ -8890,17 +8890,17 @@ class MNot
             cacheOperandMightEmulateUndefined(constraints);
     }
 
     void cacheOperandMightEmulateUndefined(CompilerConstraintList* constraints);
 
   public:
     static MNot* NewAsmJS(TempAllocator& alloc, MDefinition* input) {
         MOZ_ASSERT(input->type() == MIRType::Int32 || input->type() == MIRType::Int64);
-        MNot* ins = new(alloc) MNot(input);
+        auto* ins = new(alloc) MNot(input);
         ins->setResultType(MIRType::Int32);
         return ins;
     }
 
     INSTRUCTION_HEADER(Not)
     TRIVIAL_NEW_WRAPPERS
 
     MDefinition* foldsTo(TempAllocator& alloc) override;
@@ -11715,17 +11715,17 @@ class MGetDOMProperty
 
   public:
     INSTRUCTION_HEADER(GetDOMProperty)
     NAMED_OPERANDS((0, object))
 
     static MGetDOMProperty* New(TempAllocator& alloc, const JSJitInfo* info, MDefinition* obj,
                                 MDefinition* guard, MDefinition* globalGuard)
     {
-        MGetDOMProperty* res = new(alloc) MGetDOMProperty(info);
+        auto* res = new(alloc) MGetDOMProperty(info);
         if (!res || !res->init(alloc, obj, guard, globalGuard))
             return nullptr;
         return res;
     }
 
     JSJitGetterOp fun() const {
         return info_->getter;
     }
@@ -11789,17 +11789,17 @@ class MGetDOMMember : public MGetDOMProp
     }
 
   public:
     INSTRUCTION_HEADER(GetDOMMember)
 
     static MGetDOMMember* New(TempAllocator& alloc, const JSJitInfo* info, MDefinition* obj,
                               MDefinition* guard, MDefinition* globalGuard)
     {
-        MGetDOMMember* res = new(alloc) MGetDOMMember(info);
+        auto* res = new(alloc) MGetDOMMember(info);
         if (!res || !res->init(alloc, obj, guard, globalGuard))
             return nullptr;
         return res;
     }
 
     bool possiblyCalls() const override {
         return false;
     }
--- a/js/xpconnect/src/XPCMaps.h
+++ b/js/xpconnect/src/XPCMaps.h
@@ -29,17 +29,17 @@ class JSObject2WrappedJSMap
 {
     using Map = js::HashMap<JS::Heap<JSObject*>,
                             nsXPCWrappedJS*,
                             js::MovableCellHasher<JS::Heap<JSObject*>>,
                             InfallibleAllocPolicy>;
 
 public:
     static JSObject2WrappedJSMap* newMap(int length) {
-        JSObject2WrappedJSMap* map = new JSObject2WrappedJSMap();
+        auto* map = new JSObject2WrappedJSMap();
         if (!map->mTable.init(length)) {
             // This is a decent estimate of the size of the hash table's
             // entry storage. The |2| is because on average the capacity is
             // twice the requested length.
             NS_ABORT_OOM(length * 2 * sizeof(Map::Entry));
         }
         return map;
     }
@@ -587,17 +587,17 @@ class JSObject2JSObjectMap
 {
     using Map = JS::GCHashMap<JS::Heap<JSObject*>,
                               JS::Heap<JSObject*>,
                               js::MovableCellHasher<JS::Heap<JSObject*>>,
                               js::SystemAllocPolicy>;
 
 public:
     static JSObject2JSObjectMap* newMap(int length) {
-        JSObject2JSObjectMap* map = new JSObject2JSObjectMap();
+        auto* map = new JSObject2JSObjectMap();
         if (!map->mTable.init(length)) {
             // This is a decent estimate of the size of the hash table's
             // entry storage. The |2| is because on average the capacity is
             // twice the requested length.
             NS_ABORT_OOM(length * 2 * sizeof(Map::Entry));
         }
         return map;
     }