Bug 1508064 - Use clang-format off in parts of js/ r=jandem
authorTed Campbell <tcampbell@mozilla.com>
Mon, 19 Nov 2018 16:04:03 +0000
changeset 447008 1963c82b5abf500d7b8f5d843896028bd2380615
parent 447007 a50839e591523919115247c6bc8290c505fede76
child 447009 d5bbdd582025245de9e2b8e5dd83c257b0cfcc5e
push id35065
push userrmaries@mozilla.com
push dateMon, 19 Nov 2018 21:56:32 +0000
treeherdermozilla-central@bd4cebdbed4b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1508064
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1508064 - Use clang-format off in parts of js/ r=jandem Protect tabular macros or struct initializers that can mangled by clang-format. Differential Revision: https://phabricator.services.mozilla.com/D12239
js/src/builtin/String.cpp
js/src/frontend/SourceNotes.h
js/src/gc/AllocKind.h
--- a/js/src/builtin/String.cpp
+++ b/js/src/builtin/String.cpp
@@ -110,26 +110,28 @@ str_encodeURI_Component(JSContext* cx, u
 
 
 /* ES5 B.2.1 */
 template <typename CharT>
 static bool
 Escape(JSContext* cx, const CharT* chars, uint32_t length, InlineCharBuffer<Latin1Char>& newChars,
        uint32_t* newLengthOut)
 {
+    // clang-format off
     static const uint8_t shouldPassThrough[128] = {
          0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
          0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
          0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,       /*    !"#$%&'()*+,-./  */
          1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,       /*   0123456789:;<=>?  */
          1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,       /*   @ABCDEFGHIJKLMNO  */
          1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,       /*   PQRSTUVWXYZ[\]^_  */
          0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,       /*   `abcdefghijklmno  */
          1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,       /*   pqrstuvwxyz{\}~  DEL */
     };
+    // clang-format on
 
     /* Take a first pass and see how big the result string will need to be. */
     uint32_t newLength = length;
     for (size_t i = 0; i < length; i++) {
         char16_t ch = chars[i];
         if (ch < 128 && shouldPassThrough[ch]) {
             continue;
         }
--- a/js/src/frontend/SourceNotes.h
+++ b/js/src/frontend/SourceNotes.h
@@ -156,16 +156,17 @@ class SrcNote {
         enum Fields {
             // The file-absolute source line number of the current op.
             Line,
             Count
         };
     };
 };
 
+// clang-format off
 #define FOR_EACH_SRC_NOTE_TYPE(M)                                                                  \
     M(SRC_NULL,         "null",        0)  /* Terminates a note vector. */                         \
     M(SRC_IF,           "if",          0)  /* JSOP_IFEQ bytecode is from an if-then. */            \
     M(SRC_IF_ELSE,      "if-else",     0)  /* JSOP_IFEQ bytecode is from an if-then-else. */       \
     M(SRC_COND,         "cond",        0)  /* JSOP_IFEQ is from conditional ?: operator. */        \
     M(SRC_FOR,          "for",         SrcNote::For::Count) \
     M(SRC_WHILE,        "while",       SrcNote::While::Count) \
     M(SRC_DO_WHILE,     "do-while",    SrcNote::DoWhile::Count) \
@@ -184,16 +185,17 @@ class SrcNote {
     M(SRC_TRY,          "try",         SrcNote::Try::Count) \
     /* All notes above here are "gettable".  See SN_IS_GETTABLE below. */                          \
     M(SRC_COLSPAN,      "colspan",     SrcNote::ColSpan::Count) \
     M(SRC_NEWLINE,      "newline",     0)  /* Bytecode follows a source newline. */                \
     M(SRC_SETLINE,      "setline",     SrcNote::SetLine::Count) \
     M(SRC_UNUSED22,     "unused22",    0)  /* Unused. */                                           \
     M(SRC_UNUSED23,     "unused23",    0)  /* Unused. */                                           \
     M(SRC_XDELTA,       "xdelta",      0)  /* 24-31 are for extended delta notes. */
+// clang-format on
 
 enum SrcNoteType {
 #define DEFINE_SRC_NOTE_TYPE(sym, name, arity) sym,
     FOR_EACH_SRC_NOTE_TYPE(DEFINE_SRC_NOTE_TYPE)
 #undef DEFINE_SRC_NOTE_TYPE
 
     SRC_LAST,
     SRC_LAST_GETTABLE = SRC_TRY
--- a/js/src/gc/AllocKind.h
+++ b/js/src/gc/AllocKind.h
@@ -31,16 +31,17 @@ namespace gc {
 //  - the corresponding AllocKind
 //  - their JS::TraceKind
 //  - their C++ base type
 //  - a C++ type of the correct size
 //  - whether they can be finalized on the background thread
 //  - whether they can be allocated in the nursery
 //  - whether they can be compacted
 
+// clang-format off
 #define FOR_EACH_OBJECT_ALLOCKIND(D) \
  /* AllocKind              TraceKind     TypeName           SizedType          BGFinal Nursery Compact */ \
     D(FUNCTION,            Object,       JSObject,          JSFunction,        true,   true,   true) \
     D(FUNCTION_EXTENDED,   Object,       JSObject,          FunctionExtended,  true,   true,   true) \
     D(OBJECT0,             Object,       JSObject,          JSObject_Slots0,   false,  false,  true) \
     D(OBJECT0_BACKGROUND,  Object,       JSObject,          JSObject_Slots0,   true,   true,   true) \
     D(OBJECT2,             Object,       JSObject,          JSObject_Slots2,   false,  false,  true) \
     D(OBJECT2_BACKGROUND,  Object,       JSObject,          JSObject_Slots2,   true,   true,   true) \
@@ -68,43 +69,44 @@ namespace gc {
     IF_BIGINT(D(BIGINT,    BigInt,       JS::BigInt,        JS::BigInt,        true,   false,  false),) \
     D(JITCODE,             JitCode,      js::jit::JitCode,  js::jit::JitCode,  false,  false,  false) \
     D(SCOPE,               Scope,        js::Scope,         js::Scope,         true,   false,  true) \
     D(REGEXP_SHARED,       RegExpShared, js::RegExpShared,  js::RegExpShared,  true,   false,  true)
 
 #define FOR_EACH_NURSERY_STRING_ALLOCKIND(D) \
     D(FAT_INLINE_STRING,   String,        JSFatInlineString, JSFatInlineString, true,   true,  true) \
     D(STRING,              String,        JSString,          JSString,          true,   true,  true)
+// clang-format on
 
 #define FOR_EACH_NONOBJECT_ALLOCKIND(D) \
     FOR_EACH_NONOBJECT_NONNURSERY_ALLOCKIND(D) \
     FOR_EACH_NURSERY_STRING_ALLOCKIND(D)
 
 #define FOR_EACH_ALLOCKIND(D)    \
     FOR_EACH_OBJECT_ALLOCKIND(D) \
     FOR_EACH_NONOBJECT_ALLOCKIND(D)
 
+#define DEFINE_ALLOC_KIND(allocKind, _1, _2, _3, _4, _5, _6) allocKind,
 enum class AllocKind : uint8_t {
-#define DEFINE_ALLOC_KIND(allocKind, _1, _2, _3, _4, _5, _6) allocKind,
-
+    // clang-format off
     FOR_EACH_OBJECT_ALLOCKIND(DEFINE_ALLOC_KIND)
 
     OBJECT_LIMIT,
     OBJECT_LAST = OBJECT_LIMIT - 1,
 
     FOR_EACH_NONOBJECT_ALLOCKIND(DEFINE_ALLOC_KIND)
 
     LIMIT,
     LAST = LIMIT - 1,
 
     FIRST = 0,
     OBJECT_FIRST = FUNCTION // Hardcoded to first object kind.
-
+    // clang-format on
+};
 #undef DEFINE_ALLOC_KIND
-};
 
 static_assert(int(AllocKind::FIRST) == 0,
               "Various places depend on AllocKind starting at 0");
 static_assert(int(AllocKind::OBJECT_FIRST) == 0,
               "OBJECT_FIRST must be defined as the first object kind");
 
 inline bool
 IsAllocKind(AllocKind kind)