Title: [233410] trunk/Source/_javascript_Core
Revision
233410
Author
[email protected]
Date
2018-07-01 15:38:04 -0700 (Sun, 01 Jul 2018)

Log Message

_javascript_Core: Fix clang static analyzer warnings: Assigned value is garbage or undefined
<https://webkit.org/b/187233>

Reviewed by Mark Lam.

* b3/air/AirEliminateDeadCode.cpp:
(JSC::B3::Air::eliminateDeadCode): Initialize `changed`.
* parser/ParserTokens.h:
(JSC::JSTextPosition::JSTextPosition): Add struct member
initialization. Simplify default constructor.
(JSC::JSTokenLocation::JSTokenData): Move largest struct in the
union to the beginning to make it easy to zero out all fields.
(JSC::JSTokenLocation::JSTokenLocation): Add struct member
initialization.  Simplify default constructor.  Note that
`endOffset` was not being initialized previously.
(JSC::JSTextPosition::JSToken): Add struct member initialization
where necessary.
* runtime/IntlObject.cpp:
(JSC::MatcherResult): Add struct member initialization.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (233409 => 233410)


--- trunk/Source/_javascript_Core/ChangeLog	2018-07-01 18:23:52 UTC (rev 233409)
+++ trunk/Source/_javascript_Core/ChangeLog	2018-07-01 22:38:04 UTC (rev 233410)
@@ -1,3 +1,25 @@
+2018-07-01  David Kilzer  <[email protected]>
+
+        _javascript_Core: Fix clang static analyzer warnings: Assigned value is garbage or undefined
+        <https://webkit.org/b/187233>
+
+        Reviewed by Mark Lam.
+
+        * b3/air/AirEliminateDeadCode.cpp:
+        (JSC::B3::Air::eliminateDeadCode): Initialize `changed`.
+        * parser/ParserTokens.h:
+        (JSC::JSTextPosition::JSTextPosition): Add struct member
+        initialization. Simplify default constructor.
+        (JSC::JSTokenLocation::JSTokenData): Move largest struct in the
+        union to the beginning to make it easy to zero out all fields.
+        (JSC::JSTokenLocation::JSTokenLocation): Add struct member
+        initialization.  Simplify default constructor.  Note that
+        `endOffset` was not being initialized previously.
+        (JSC::JSTextPosition::JSToken): Add struct member initialization
+        where necessary.
+        * runtime/IntlObject.cpp:
+        (JSC::MatcherResult): Add struct member initialization.
+
 2018-06-23  Darin Adler  <[email protected]>
 
         [Cocoa] Improve ARC compatibility of more code in _javascript_Core

Modified: trunk/Source/_javascript_Core/b3/air/AirEliminateDeadCode.cpp (233409 => 233410)


--- trunk/Source/_javascript_Core/b3/air/AirEliminateDeadCode.cpp	2018-07-01 18:23:52 UTC (rev 233409)
+++ trunk/Source/_javascript_Core/b3/air/AirEliminateDeadCode.cpp	2018-07-01 22:38:04 UTC (rev 233410)
@@ -43,7 +43,7 @@
 
     TmpSet liveTmps;
     IndexSet<StackSlot*> liveStackSlots;
-    bool changed;
+    bool changed { false };
     
     auto isArgLive = [&] (const Arg& arg) -> bool {
         switch (arg.kind()) {

Modified: trunk/Source/_javascript_Core/parser/ParserTokens.h (233409 => 233410)


--- trunk/Source/_javascript_Core/parser/ParserTokens.h	2018-07-01 18:23:52 UTC (rev 233409)
+++ trunk/Source/_javascript_Core/parser/ParserTokens.h	2018-07-01 22:38:04 UTC (rev 233410)
@@ -191,7 +191,7 @@
 };
 
 struct JSTextPosition {
-    JSTextPosition() : line(0), offset(0), lineStartOffset(0) { }
+    JSTextPosition() = default;
     JSTextPosition(int _line, int _offset, int _lineStartOffset) : line(_line), offset(_offset), lineStartOffset(_lineStartOffset) { }
     JSTextPosition(const JSTextPosition& other) : line(other.line), offset(other.offset), lineStartOffset(other.lineStartOffset) { }
 
@@ -213,13 +213,18 @@
         return !(*this == other);
     }
 
-    int line;
-    int offset;
-    int lineStartOffset;
+    int line { 0 };
+    int offset { 0 };
+    int lineStartOffset { 0 };
 };
 
 union JSTokenData {
     struct {
+        const Identifier* cooked;
+        const Identifier* raw;
+        bool isTail;
+    };
+    struct {
         uint32_t line;
         uint32_t offset;
         uint32_t lineStartOffset;
@@ -234,11 +239,6 @@
         uint8_t radix;
     };
     struct {
-        const Identifier* cooked;
-        const Identifier* raw;
-        bool isTail;
-    };
-    struct {
         const Identifier* pattern;
         const Identifier* flags;
     };
@@ -245,7 +245,7 @@
 };
 
 struct JSTokenLocation {
-    JSTokenLocation() : line(0), lineStartOffset(0), startOffset(0) { }
+    JSTokenLocation() = default;
     JSTokenLocation(const JSTokenLocation& location)
     {
         line = location.line;
@@ -254,15 +254,15 @@
         endOffset = location.endOffset;
     }
 
-    int line;
-    unsigned lineStartOffset;
-    unsigned startOffset;
-    unsigned endOffset;
+    int line { 0 };
+    unsigned lineStartOffset { 0 };
+    unsigned startOffset { 0 };
+    unsigned endOffset { 0 };
 };
 
 struct JSToken {
-    JSTokenType m_type;
-    JSTokenData m_data;
+    JSTokenType m_type { ERRORTOK };
+    JSTokenData m_data { { nullptr, nullptr, false } };
     JSTokenLocation m_location;
     JSTextPosition m_startPosition;
     JSTextPosition m_endPosition;

Modified: trunk/Source/_javascript_Core/runtime/IntlObject.cpp (233409 => 233410)


--- trunk/Source/_javascript_Core/runtime/IntlObject.cpp	2018-07-01 18:23:52 UTC (rev 233409)
+++ trunk/Source/_javascript_Core/runtime/IntlObject.cpp	2018-07-01 22:38:04 UTC (rev 233410)
@@ -69,7 +69,7 @@
 struct MatcherResult {
     String locale;
     String extension;
-    size_t extensionIndex;
+    size_t extensionIndex { 0 };
 };
 
 const ClassInfo IntlObject::s_info = { "Object", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(IntlObject) };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to