Fix clang warnings on extraneous semicolons after member function definitions, implicit NULL-to-bool conversions, and the utter deadwood-ness of PCStack::cx. No bug, r=themaid, r=sfink
authorJeff Walden <jwalden@mit.edu>
Thu, 06 Sep 2012 16:50:46 -0700
changeset 106631 8464ed98f78b18825c727c311a2001f2a243320b
parent 106630 211a7f7cae85ab704761c9c4325caec792fc8c1c
child 106632 76c080138e14638487465e9257fbb91269ddaa9d
push id74
push usershu@rfrn.org
push dateTue, 18 Sep 2012 19:23:47 +0000
reviewersthemaid, sfink
milestone18.0a1
Fix clang warnings on extraneous semicolons after member function definitions, implicit NULL-to-bool conversions, and the utter deadwood-ness of PCStack::cx. No bug, r=themaid, r=sfink
js/src/gc/Marking.cpp
js/src/gc/Root.h
js/src/jsapi.h
js/src/jsopcode.cpp
js/src/jsproxy.h
js/src/jspubtd.h
js/src/jsscope.h
--- a/js/src/gc/Marking.cpp
+++ b/js/src/gc/Marking.cpp
@@ -111,17 +111,17 @@ MarkInternal(JSTracer *trc, T **thingp)
      * Don't mark things outside a compartment if we are in a per-compartment
      * GC.
      */
     if (!trc->callback) {
         if (thing->compartment()->isCollecting())
             PushMarkStack(static_cast<GCMarker *>(trc), thing);
     } else {
         trc->callback(trc, (void **)thingp, GetGCThingTraceKind(thing));
-        JS_SET_TRACING_LOCATION(trc, NULL);
+        JS_UNSET_TRACING_LOCATION(trc);
     }
 
     trc->debugPrinter = NULL;
     trc->debugPrintArg = NULL;
 }
 
 #define JS_ROOT_MARKING_ASSERT(trc)                                     \
     JS_ASSERT_IF(IS_GC_MARKING_TRACER(trc),                             \
@@ -307,17 +307,17 @@ MarkIdInternal(JSTracer *trc, jsid *id)
         *id = NON_INTEGER_ATOM_TO_JSID(reinterpret_cast<JSAtom *>(str));
     } else if (JS_UNLIKELY(JSID_IS_OBJECT(*id))) {
         JSObject *obj = JSID_TO_OBJECT(*id);
         JS_SET_TRACING_LOCATION(trc, (void *)id);
         MarkInternal(trc, &obj);
         *id = OBJECT_TO_JSID(obj);
     } else {
         /* Unset realLocation manually if we do not call MarkInternal. */
-        JS_SET_TRACING_LOCATION(trc, NULL);
+        JS_UNSET_TRACING_LOCATION(trc);
     }
 }
 
 void
 MarkId(JSTracer *trc, EncapsulatedId *id, const char *name)
 {
     JS_SET_TRACING_NAME(trc, name);
     MarkIdInternal(trc, id->unsafeGet());
@@ -368,17 +368,17 @@ MarkValueInternal(JSTracer *trc, Value *
         JS_SET_TRACING_LOCATION(trc, (void *)v);
         MarkKind(trc, &thing, v->gcKind());
         if (v->isString())
             v->setString((JSString *)thing);
         else
             v->setObjectOrNull((JSObject *)thing);
     } else {
         /* Unset realLocation manually if we do not call MarkInternal. */
-        JS_SET_TRACING_LOCATION(trc, NULL);
+        JS_UNSET_TRACING_LOCATION(trc);
     }
 }
 
 void
 MarkValue(JSTracer *trc, EncapsulatedValue *v, const char *name)
 {
     JS_SET_TRACING_NAME(trc, name);
     MarkValueInternal(trc, v->unsafeGet());
--- a/js/src/gc/Root.h
+++ b/js/src/gc/Root.h
@@ -239,17 +239,17 @@ typedef JSString *                  RawS
 extern mozilla::ThreadLocal<JSRuntime *> TlsRuntime;
 
 /*
  * By default, pointers should use the inheritance hierarchy to find their
  * ThingRootKind. Some pointer types are explicitly set in jspubtd.h so that
  * Rooted<T> may be used without the class definition being available.
  */
 template <typename T>
-struct RootKind<T *> { static ThingRootKind rootKind() { return T::rootKind(); }; };
+struct RootKind<T *> { static ThingRootKind rootKind() { return T::rootKind(); } };
 
 template <typename T>
 struct RootMethods<T *>
 {
     static T *initial() { return NULL; }
     static ThingRootKind kind() { return RootKind<T *>::rootKind(); }
     static bool poisoned(T *v) { return IsPoisonedPtr(v); }
 };
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -3900,20 +3900,27 @@ JS_CallTracer(JSTracer *trc, void *thing
  * in-place.
  */
 #ifdef JS_GC_ZEAL
 # define JS_SET_TRACING_LOCATION(trc, location)                               \
     JS_BEGIN_MACRO                                                            \
         if (!(trc)->realLocation || !(location))                              \
             (trc)->realLocation = (location);                                 \
     JS_END_MACRO
+# define JS_UNSET_TRACING_LOCATION(trc)                                       \
+    JS_BEGIN_MACRO                                                            \
+        (trc)->realLocation = NULL;                                           \
+    JS_END_MACRO
 #else
 # define JS_SET_TRACING_LOCATION(trc, location)                               \
     JS_BEGIN_MACRO                                                            \
     JS_END_MACRO
+# define JS_UNSET_TRACING_LOCATION(trc)                                       \
+    JS_BEGIN_MACRO                                                            \
+    JS_END_MACRO
 #endif
 
 
 /*
  * Convenience macro to describe the argument of JS_CallTracer using C string
  * and index.
  */
 # define JS_SET_TRACING_INDEX(trc, name, index)                               \
--- a/js/src/jsopcode.cpp
+++ b/js/src/jsopcode.cpp
@@ -5767,26 +5767,21 @@ GetBlockChainAtPC(JSContext *cx, JSScrip
         }
     }
 
     return blockChain;
 }
 
 class PCStack
 {
-    JSContext *cx;
     jsbytecode **stack;
     int depth_;
 
   public:
-    explicit PCStack(JSContext *cx)
-        : cx(cx),
-          stack(NULL),
-          depth_(0)
-    {}
+    PCStack() : stack(NULL), depth_(0) {}
     ~PCStack();
     bool init(JSContext *cx, JSScript *script, jsbytecode *pc);
     int depth() const { return depth_; }
     jsbytecode *operator[](int i) const;
 };
 
 PCStack::~PCStack()
 {
@@ -5876,17 +5871,17 @@ struct ExpressionDecompiler
     bool getOutput(char **out);
 };
 
 bool
 ExpressionDecompiler::decompilePC(jsbytecode *pc)
 {
     JS_ASSERT(script->code <= pc && pc < script->code + script->length);
 
-    PCStack pcstack(cx);
+    PCStack pcstack;
     if (!pcstack.init(cx, script, pc))
         return false;
 
     JSOp op = (JSOp)*pc;
 
     // None of these stack-writing ops generates novel values.
     JS_ASSERT(op != JSOP_CASE && op != JSOP_DUP && op != JSOP_DUP2);
 
@@ -6129,17 +6124,17 @@ FindStartPC(JSContext *cx, JSScript *scr
 {
     jsbytecode *current = *valuepc;
 
     if (spindex == JSDVG_IGNORE_STACK)
         return true;
 
     *valuepc = NULL;
 
-    PCStack pcstack(cx);
+    PCStack pcstack;
     if (!pcstack.init(cx, script, current))
         return false;
 
     if (spindex == JSDVG_SEARCH_STACK) {
         // We search from fp->sp to base to find the most recently calculated
         // value matching v under assumption that it is it that caused
         // exception.
         Value *stackBase = cx->regs().spForStackDepth(0);
@@ -6289,17 +6284,17 @@ DecompileExpression(JSContext *cx, JSScr
 
     ptrdiff_t len = end - begin;
     if (len <= 0)
         return FAILED_EXPRESSION_DECOMPILER;
 
     struct Guard {
         jsbytecode **pcstack;
         JSPrinter *printer;
-        Guard() : pcstack(NULL), printer(NULL) {}
+        Guard() : pcstack(), printer(NULL) {}
         ~Guard() {
             if (printer)
                 js_DestroyPrinter(printer);
             js_free(pcstack);
         }
     } g;
 
     g.pcstack = js_pod_malloc<jsbytecode*>(StackDepth(script));
--- a/js/src/jsproxy.h
+++ b/js/src/jsproxy.h
@@ -46,17 +46,17 @@ class JS_FRIEND_API(Wrapper);
  * the derived traps in terms of the fundamental ones. This allows consumers of
  * this class to define any custom behavior they want.
  */
 class JS_FRIEND_API(BaseProxyHandler) {
     void *mFamily;
     bool mHasPrototype;
   protected:
     // Subclasses may set this in their constructor.
-    void setHasPrototype(bool hasPrototype) { mHasPrototype = hasPrototype; };
+    void setHasPrototype(bool hasPrototype) { mHasPrototype = hasPrototype; }
 
   public:
     explicit BaseProxyHandler(void *family);
     virtual ~BaseProxyHandler();
 
     bool hasPrototype() {
         return mHasPrototype;
     }
--- a/js/src/jspubtd.h
+++ b/js/src/jspubtd.h
@@ -243,22 +243,28 @@ enum ThingRootKind
 template <typename T>
 struct RootKind;
 
 /*
  * Specifically mark the ThingRootKind of externally visible types, so that
  * JSAPI users may use JSRooted... types without having the class definition
  * available.
  */
-template <> struct RootKind<JSObject *> { static ThingRootKind rootKind() { return THING_ROOT_OBJECT; }; };
-template <> struct RootKind<JSFunction *> { static ThingRootKind rootKind() { return THING_ROOT_OBJECT; }; };
-template <> struct RootKind<JSString *> { static ThingRootKind rootKind() { return THING_ROOT_STRING; }; };
-template <> struct RootKind<JSScript *> { static ThingRootKind rootKind() { return THING_ROOT_SCRIPT; }; };
-template <> struct RootKind<jsid> { static ThingRootKind rootKind() { return THING_ROOT_ID; }; };
-template <> struct RootKind<Value> { static ThingRootKind rootKind() { return THING_ROOT_VALUE; }; };
+template<typename T, ThingRootKind Kind>
+struct SpecificRootKind
+{
+    static ThingRootKind rootKind() { return Kind; }
+};
+
+template <> struct RootKind<JSObject *> : SpecificRootKind<JSObject *, THING_ROOT_OBJECT> {};
+template <> struct RootKind<JSFunction *> : SpecificRootKind<JSFunction *, THING_ROOT_OBJECT> {};
+template <> struct RootKind<JSString *> : SpecificRootKind<JSString *, THING_ROOT_STRING> {};
+template <> struct RootKind<JSScript *> : SpecificRootKind<JSScript *, THING_ROOT_SCRIPT> {};
+template <> struct RootKind<jsid> : SpecificRootKind<jsid, THING_ROOT_ID> {};
+template <> struct RootKind<Value> : SpecificRootKind<Value, THING_ROOT_VALUE> {};
 
 struct ContextFriendFields {
     JSRuntime *const    runtime;
 
     ContextFriendFields(JSRuntime *rt)
       : runtime(rt) { }
 
     static const ContextFriendFields *get(const JSContext *cx) {
--- a/js/src/jsscope.h
+++ b/js/src/jsscope.h
@@ -1130,13 +1130,15 @@ MarkNonNativePropertyFound(HandleObject 
 #pragma warning(pop)
 #pragma warning(pop)
 #endif
 
 namespace JS {
     template<> class AnchorPermitted<js::Shape *> { };
     template<> class AnchorPermitted<const js::Shape *> { };
 
-    template<> struct RootKind<js::Shape *> { static ThingRootKind rootKind() { return THING_ROOT_SHAPE; }; };
-    template<> struct RootKind<js::BaseShape *> { static ThingRootKind rootKind() { return THING_ROOT_BASE_SHAPE; }; };
+    template<>
+    struct RootKind<js::Shape *> : SpecificRootKind<js::Shape *, THING_ROOT_SHAPE> {};
+    template<>
+    struct RootKind<js::BaseShape *> : SpecificRootKind<js::BaseShape *, THING_ROOT_BASE_SHAPE> {};
 }
 
 #endif /* jsscope_h___ */