Push more changes from Google-internal Emboss.

Fixes a couple of tests that are broken with -Wsign-compare when `char` is signed.

Adds extension points for defining site-specific values for various macros in emboss_defines.h.

Deletes a couple of orphaned files.
diff --git a/back_end/cpp/testcode/generated_code_nc.cc b/back_end/cpp/testcode/generated_code_nc.cc
deleted file mode 100644
index 56e0358..0000000
--- a/back_end/cpp/testcode/generated_code_nc.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2019 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include <stdint.h>
-
-#include "testdata/auto_array_size.emb.h"
-
-namespace emboss {
-namespace test {
-namespace {
-
-void X() {
-  static const ::std::uint8_t kAutoSize[36] = {0};
-  (void)kAutoSize;  // Suppress unused variable warning.
-
-#ifdef TEST_WRITER_IS_NOT_CONSTRUCTIBLE_FROM_CONSTANT
-  // A FooWriter should not be constructible from a constant pointer.
-  AutoSizeView view = AutoSizeWriter(kAutoSize, sizeof kAutoSize);
-#endif  // TEST_WRITER_IS_NOT_CONSTRUCTIBLE_FROM_CONSTANT
-
-#ifdef TEST_CANNOT_CALL_SET_ON_CONSTANT_VIEW
-  // A call to FooView::xxx().Write() should not compile.
-  AutoSizeView view = AutoSizeView(kAutoSize, sizeof kAutoSize);
-  // .Read() should be OK.
-  (void)view.array_size().Read();
-  view.array_size().Write(1);
-#endif  // TEST_CANNOT_CALL_SET_ON_CONSTANT_VIEW
-
-#ifdef TEST_CANNOT_CALL_SET_ON_CONSTANT_VIEW_OF_ARRAY
-  // A call to FooView::xxx()[y].Write() should not compile.
-  AutoSizeView view = AutoSizeView(kAutoSize, sizeof kAutoSize);
-  // .Read() should be OK.
-  (void)view.four_byte_array()[1].Read();
-  view.four_byte_array()[1].Write(0);
-#endif  // TEST_CANNOT_CALL_SET_ON_CONSTANT_VIEW_OF_ARRAY
-}
-
-}  // namespace
-}  // namespace test
-}  // namespace emboss
diff --git a/back_end/cpp/testcode/ok_fuzzer.cc b/back_end/cpp/testcode/ok_fuzzer.cc
deleted file mode 100644
index 4800948..0000000
--- a/back_end/cpp/testcode/ok_fuzzer.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2019 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Fuzz test for `Complex::Ok()` from `complex_structure.emb` on arbitrary data.
-//
-// This fuzz target verifies that `Ok()` does not crash on any input.  It does
-// not verify that `Ok()` does the right thing.
-
-#include "testdata/complex_structure.emb.h"
-
-// Entry point for fuzz tester: this must have this exact signature, including
-// the name `LLVMFuzzerTestOneInput`, or it will not work.
-extern "C" int LLVMFuzzerTestOneInput(const ::std::uint8_t *data,
-                                      ::std::size_t size) {
-  auto storage = ::std::basic_string</**/ ::std::uint8_t>(data, size);
-  const auto view = ::emboss_test::MakeComplexView(&storage);
-  (void)view.Ok();
-  return 0;
-}
diff --git a/back_end/cpp/testcode/parameters_test.cc b/back_end/cpp/testcode/parameters_test.cc
index 6e4d956..6179795 100644
--- a/back_end/cpp/testcode/parameters_test.cc
+++ b/back_end/cpp/testcode/parameters_test.cc
@@ -56,7 +56,7 @@
 }
 
 TEST(AxesEnvelope, FieldPassedAsParameter) {
-  ::std::array<char, 9> values = {2, 0, 0, 0, 0x80, 0, 100, 0, 0};
+  ::std::array<unsigned char, 9> values = {2, 0, 0, 0, 0x80, 0, 100, 0, 0};
   auto view = MakeAxesEnvelopeView(&values);
   EXPECT_TRUE(view.Ok());
   EXPECT_EQ(0x80000000U, view.axes().x().value().Read());
@@ -64,7 +64,7 @@
 }
 
 TEST(AxesEnvelope, ParameterValueIsOutOfRange) {
-  ::std::array<char, 9> values = {16, 0, 0, 0, 0x80, 0, 100, 0, 0};
+  ::std::array<unsigned char, 9> values = {16, 0, 0, 0, 0x80, 0, 100, 0, 0};
   auto view = MakeAxesEnvelopeView(&values);
   EXPECT_FALSE(view.Ok());
   EXPECT_FALSE(view.axes().Ok());
@@ -83,7 +83,7 @@
 }
 
 TEST(Multiversion, ParameterUsedToSwitchField) {
-  ::std::array<char, 9> values = {1, 0, 0, 0, 0x80, 0, 100, 0, 0};
+  ::std::array<unsigned char, 9> values = {1, 0, 0, 0, 0x80, 0, 100, 0, 0};
   auto view = MakeMultiversionView(Product::VERSION_1, &values);
   EXPECT_TRUE(view.Ok());
   EXPECT_TRUE(view.config().power().Read());
diff --git a/back_end/cpp/testcode/text_format_fuzzer.cc b/back_end/cpp/testcode/text_format_fuzzer.cc
deleted file mode 100644
index 883c159..0000000
--- a/back_end/cpp/testcode/text_format_fuzzer.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2019 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Fuzz test for reading Emboss text format of the `Complex` struct in
-// `complex_structure.emb`.
-//
-// This fuzz target verifies that ::emboss::UpdateFromText does not crash on any
-// input.  It does not verify that UpdateFromText does the right thing.
-
-#include "testdata/complex_structure.emb.h"
-
-// Entry point for fuzz tester: this must have this exact signature, including
-// the name `LLVMFuzzerTestOneInput`, or it will not work.
-extern "C" int LLVMFuzzerTestOneInput(const ::std::uint8_t *data,
-                                      ::std::size_t size) {
-  ::std::array<char, 64> values = {0};
-  const auto view = ::emboss_test::MakeComplexView(&values);
-  ::emboss::UpdateFromText(
-      view, ::std::string(reinterpret_cast<const char *>(data), size));
-  return 0;
-}
diff --git a/back_end/cpp/testcode/virtual_field_test.cc b/back_end/cpp/testcode/virtual_field_test.cc
index 7655cca..7f00765 100644
--- a/back_end/cpp/testcode/virtual_field_test.cc
+++ b/back_end/cpp/testcode/virtual_field_test.cc
@@ -204,7 +204,7 @@
 }
 
 TEST(ConditionalVirtual, TextFormatWrite) {
-  ::std::array<char, 4> values = {0, 0, 0, 0x80};
+  ::std::array<unsigned char, 4> values = {0, 0, 0, 0x80};
   const auto view = MakeStructureWithConditionalValueView(&values);
   EXPECT_EQ("{ x: 2147483648, x_plus_one: 2147483649 }",
             ::emboss::WriteToString(view));
diff --git a/public/BUILD b/public/BUILD
index c33c069..5837635 100644
--- a/public/BUILD
+++ b/public/BUILD
@@ -25,9 +25,9 @@
     visibility = ["//visibility:public"],
 )
 
-cc_library(
-    name = "cpp_utils",
-    hdrs = [
+filegroup(
+    name = "raw_headers",
+    srcs = [
         "emboss_arithmetic.h",
         "emboss_array_view.h",
         "emboss_bit_util.h",
@@ -42,9 +42,20 @@
         "emboss_text_util.h",
         "emboss_view_parameters.h",
     ],
-    deps = [
+    visibility = ["//visibility:public"],
+)
+
+cc_library(
+    name = "cpp_utils",
+    hdrs = [
+        ":raw_headers",
     ],
     visibility = ["//visibility:public"],
+    deps = [
+        # BEGIN INSERT_MY_SITE_DEFINES_TARGET_HERE
+        # "//MY_SITE_DEFINES:TARGET",
+        # END INSERT_MY_SITE_DEFINES_TARGET_HERE
+    ],
 )
 
 emboss_cc_util_test(
@@ -133,6 +144,18 @@
 )
 
 emboss_cc_util_test(
+    name = "emboss_enum_view_test",
+    srcs = [
+        "emboss_enum_view_test.cc",
+    ],
+    copts = ["-DEMBOSS_FORCE_ALL_CHECKS"],
+    deps = [
+        ":cpp_utils",
+        "@com_google_googletest//:gtest_main",
+    ],
+)
+
+emboss_cc_util_test(
     name = "emboss_maybe_test",
     srcs = [
         "emboss_maybe_test.cc",
@@ -161,10 +184,7 @@
     srcs = [
         "emboss_text_util_test.cc",
     ],
-    copts = [
-        "-DEMBOSS_FORCE_ALL_CHECKS",
-        "-Wsign-compare",
-    ],
+    copts = ["-DEMBOSS_FORCE_ALL_CHECKS"],
     deps = [
         ":cpp_utils",
         "@com_google_googletest//:gtest_main",
diff --git a/public/emboss_defines.h b/public/emboss_defines.h
index 04fc2b5..6ee7cd9 100644
--- a/public/emboss_defines.h
+++ b/public/emboss_defines.h
@@ -14,53 +14,134 @@
 
 // This header contains #defines that are used to control Emboss's generated
 // code.
-#ifndef EMBOSS_PUBLIC_EMBOSS_DEFINES_H_
-#define EMBOSS_PUBLIC_EMBOSS_DEFINES_H_
+//
+// These #defines are global, and *must* be defined the same way in every
+// translation unit.  In particular, if you use `-D` (or your compiler's
+// equivalent) to define some of them on the command line, you *must* pass the
+// *exact* same definition when compiling *every* file that #includes any
+// Emboss-generated or Emboss-related file, directly or indirectly.  Failure to
+// do so will lead to ODR violations and strange behavior.
+//
+// Rather than using the command line, the Emboss authors recommend that you
+// insert an #include of a custom site_defines.h between the two markers below.
+//
+// If you are using [Copybara][1] to import Emboss into your environment, you
+// can use a transform like:
+//
+//     core.replace(
+//         before = '${start_of_line}// #include "MY_SITE_DEFINES.h"',
+//         after = '${start_of_line}#include "MY_SITE_DEFINES.h"',
+//         paths = ['public/emboss_defines.h'],
+//         regex_groups = {
+//             'start_of_line': '^',
+//         },
+//     ),
+//
+// [1]: https://github.com/google/copybara
+//
+// If you are using [Bazel][2], be sure to add a dependency from the
+// //public:cpp_utils target to a target exporting your custom header:
+//
+//     core.replace(
+//         before = '${leading_whitespace}# "//MY_SITE_DEFINES:TARGET",',
+//         after = '${leading_whitespace}"//MY_SITE_DEFINES:TARGET",',
+//         paths = ['public/BUILD'],
+//         regex_groups = {
+//             'leading_whitespace': '^ *',
+//         },
+//     ),
+//
+// [2]: https://bazel.build
+#ifndef THIRD_PARTY_EMBOSS_PUBLIC_EMBOSS_DEFINES_H_
+#define THIRD_PARTY_EMBOSS_PUBLIC_EMBOSS_DEFINES_H_
 
-// TODO(bolms): Add an explicit extension point for these macros.
-#include <assert.h>
+// START INSERT_INCLUDE_SITE_DEFINES_HERE
+// #include "MY_SITE_DEFINES.h"
+// END INSERT_INCLUDE_SITE_DEFINES_HERE
+
+#include <cassert>
+
+// EMBOSS_CHECK should abort the program if the given expression evaluates to
+// false.
+//
+// By default, checks are only enabled on non-NDEBUG builds.  (Note that all
+// translation units MUST be built with the same value of NDEBUG!)
+#if !defined(EMBOSS_CHECK)
 #define EMBOSS_CHECK(x) assert((x))
-#define EMBOSS_CHECK_LE(x, y) assert((x) <= (y))
-#define EMBOSS_CHECK_LT(x, y) assert((x) < (y))
-#define EMBOSS_CHECK_GE(x, y) assert((x) >= (y))
-#define EMBOSS_CHECK_GT(x, y) assert((x) > (y))
-#define EMBOSS_CHECK_EQ(x, y) assert((x) == (y))
+#endif  // !defined(EMBOSS_CHECK)
 
-// If EMBOSS_FORCE_ALL_CHECKS is #defined, then all checks are enabled even in
-// optimized modes.  Otherwise, EMBOSS_DCHECK only runs in debug mode.
-#ifdef EMBOSS_FORCE_ALL_CHECKS
-#define EMBOSS_DCHECK_EQ(x, y) assert((x) == (y))
-#define EMBOSS_DCHECK_GE(x, y) assert((x) >= (y))
-#else
-#define EMBOSS_DCHECK_EQ(x, y) assert((x) == (y))
-#define EMBOSS_DCHECK_GE(x, y) assert((x) >= (y))
-#endif  // EMBOSS_FORCE_ALL_CHECKS
+#if !defined(EMBOSS_CHECK_LE)
+#define EMBOSS_CHECK_LE(x, y) EMBOSS_CHECK((x) <= (y))
+#endif  // !defined(EMBOSS_CHECK_LE)
+
+#if !defined(EMBOSS_CHECK_LT)
+#define EMBOSS_CHECK_LT(x, y) EMBOSS_CHECK((x) < (y))
+#endif  // !defined(EMBOSS_CHECK_LT)
+
+#if !defined(EMBOSS_CHECK_GE)
+#define EMBOSS_CHECK_GE(x, y) EMBOSS_CHECK((x) >= (y))
+#endif  // !defined(EMBOSS_CHECK_GE)
+
+#if !defined(EMBOSS_CHECK_GT)
+#define EMBOSS_CHECK_GT(x, y) EMBOSS_CHECK((x) > (y))
+#endif  // !defined(EMBOSS_CHECK_GT)
+
+#if !defined(EMBOSS_CHECK_EQ)
+#define EMBOSS_CHECK_EQ(x, y) EMBOSS_CHECK((x) == (y))
+#endif  // !defined(EMBOSS_CHECK_EQ)
+
+#if !defined(EMBOSS_CHECK_NE)
+#define EMBOSS_CHECK_NE(x, y) EMBOSS_CHECK((x) == (y))
+#endif  // !defined(EMBOSS_CHECK_NE)
+
+// The EMBOSS_DCHECK macros, by default, work the same way as EMBOSS_CHECK;
+// EMBOSS_DCHECK is used as an assert() for logic embedded in Emboss, where
+// EMBOSS_CHECK is used to check preconditions on application logic.  Depending
+// on how much you trust the correctness of Emboss itself, you may wish to
+// disable EMBOSS_DCHECK in situations where you do not disable EMBOSS_CHECK.
+#if !defined(EMBOSS_DCHECK)
+#define EMBOSS_DCHECK(x) assert((x))
+#endif  // !defined(EMBOSS_DCHECK)
+
+#if !defined(EMBOSS_DCHECK_LE)
+#define EMBOSS_DCHECK_LE(x, y) EMBOSS_DCHECK((x) <= (y))
+#endif  // !defined(EMBOSS_DCHECK_LE)
+
+#if !defined(EMBOSS_DCHECK_LT)
+#define EMBOSS_DCHECK_LT(x, y) EMBOSS_DCHECK((x) < (y))
+#endif  // !defined(EMBOSS_DCHECK_LT)
+
+#if !defined(EMBOSS_DCHECK_GE)
+#define EMBOSS_DCHECK_GE(x, y) EMBOSS_DCHECK((x) >= (y))
+#endif  // !defined(EMBOSS_DCHECK_GE)
+
+#if !defined(EMBOSS_DCHECK_GT)
+#define EMBOSS_DCHECK_GT(x, y) EMBOSS_DCHECK((x) > (y))
+#endif  // !defined(EMBOSS_DCHECK_GT)
+
+#if !defined(EMBOSS_DCHECK_EQ)
+#define EMBOSS_DCHECK_EQ(x, y) EMBOSS_DCHECK((x) == (y))
+#endif  // !defined(EMBOSS_DCHECK_EQ)
+
+#if !defined(EMBOSS_DCHECK_NE)
+#define EMBOSS_DCHECK_NE(x, y) EMBOSS_DCHECK((x) == (y))
+#endif  // !defined(EMBOSS_DCHECK_NE)
 
 // Technically, the mapping from pointers to integers is implementation-defined,
 // but the standard states "[ Note: It is intended to be unsurprising to those
 // who know the addressing structure of the underlying machine. - end note ],"
 // so this should be a reasonably safe way to check that a pointer is aligned.
+#if !defined(EMBOSS_DCHECK_POINTER_ALIGNMENT)
 #define EMBOSS_DCHECK_POINTER_ALIGNMENT(p, align, offset)                  \
   EMBOSS_DCHECK_EQ(reinterpret_cast</**/ ::std::uintptr_t>((p)) % (align), \
                    (static_cast</**/ ::std::uintptr_t>((offset))))
+#endif  // !defined(EMBOSS_DCHECK_POINTER_ALIGNMENT)
+
+#if !defined(EMBOSS_CHECK_POINTER_ALIGNMENT)
 #define EMBOSS_CHECK_POINTER_ALIGNMENT(p, align, offset)                  \
   EMBOSS_CHECK_EQ(reinterpret_cast</**/ ::std::uintptr_t>((p)) % (align), \
                   static_cast</**/ ::std::uintptr_t>((offset)))
-
-// !! WARNING !!
-//
-// It is possible to pre-#define a number of macros used below to influence
-// Emboss's system-specific optimizations.  If so, they *must* be #defined the
-// same way in every compilation unit that #includes any Emboss-related header
-// or generated code, before any such headers are #included, or else there is a
-// real risk of ODR violations.  It is recommended that any EMBOSS_* #defines
-// are added to the global C++ compiler options in your build system, rather
-// than being individually specified in source files.
-//
-// TODO(bolms): Add an #include for a site-specific header file, where
-// site-specific customizations can be placed, and recommend that any overrides
-// be placed in that header.  Further, use that header for the EMBOSS_CHECK_*
-// #defines, above.
+#endif  // !defined(EMBOSS_CHECK_POINTER_ALIGNMENT)
 
 // EMBOSS_NO_OPTIMIZATIONS is used to turn off all system-specific
 // optimizations.  This is mostly intended for testing, but could be used if
@@ -75,9 +156,9 @@
 //
 // TODO(bolms): Are there actually any non-archaic systems that use any integer
 // types other than 2's-complement?
-#ifndef EMBOSS_SYSTEM_IS_TWOS_COMPLEMENT
+#if !defined(EMBOSS_SYSTEM_IS_TWOS_COMPLEMENT)
 #define EMBOSS_SYSTEM_IS_TWOS_COMPLEMENT 1
-#endif
+#endif  // !defined(EMBOSS_SYSTEM_IS_TWOS_COMPLEMENT)
 
 #if !defined(__INTEL_COMPILER)
 // On systems with known host byte order, Emboss can always use memcpy to safely
@@ -123,8 +204,10 @@
 //
 // Note the lack of parentheses around 't' in the expansion: unfortunately,
 // GCC's attribute syntax disallows parentheses in that particular position.
+#if !defined(EMBOSS_ALIAS_SAFE_POINTER_CAST)
 #define EMBOSS_ALIAS_SAFE_POINTER_CAST(t, x) \
   reinterpret_cast<t __attribute__((__may_alias__)) *>((x))
+#endif  // !defined(EMBOSS_LITTLE_ENDIAN_TO_NATIVE)
 #endif  // !defined(__INTEL_COMPILER)
 
 // GCC supports __BYTE_ORDER__ of __ORDER_LITTLE_ENDIAN__, __ORDER_BIG_ENDIAN__,
@@ -140,10 +223,22 @@
 //
 // On little-endian systems, no fixup is needed for little-endian sources, but
 // big-endian sources require a byte swap.
+#if !defined(EMBOSS_LITTLE_ENDIAN_TO_NATIVE)
 #define EMBOSS_LITTLE_ENDIAN_TO_NATIVE(x) (x)
+#endif  // !defined(EMBOSS_LITTLE_ENDIAN_TO_NATIVE)
+
+#if !defined(EMBOSS_NATIVE_TO_LITTLE_ENDIAN)
 #define EMBOSS_NATIVE_TO_LITTLE_ENDIAN(x) (x)
+#endif  // !defined(EMBOSS_NATIVE_TO_LITTLE_ENDIAN)
+
+#if !defined(EMBOSS_BIG_ENDIAN_TO_NATIVE)
 #define EMBOSS_BIG_ENDIAN_TO_NATIVE(x) (::emboss::support::ByteSwap((x)))
+#endif  // !defined(EMBOSS_BIG_ENDIAN_TO_NATIVE)
+
+#if !defined(EMBOSS_NATIVE_TO_BIG_ENDIAN)
 #define EMBOSS_NATIVE_TO_BIG_ENDIAN(x) (::emboss::support::ByteSwap((x)))
+#endif  // !defined(EMBOSS_NATIVE_TO_BIG_ENDIAN)
+
 // TODO(bolms): Find a way to test on a big-endian architecture, and add support
 // for __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
 #endif  // __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
@@ -156,13 +251,25 @@
 // that fails to compile on GCC, even with defined(__has_builtin) &&
 // __has_builtin(__builtin_bswap16), so instead Emboss just checks for
 // defined(__clang__).
+#if !defined(EMBOSS_BYTESWAP16)
 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || defined(__clang__)
 #define EMBOSS_BYTESWAP16(x) __builtin_bswap16((x))
 #endif  // __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
+#endif  // !defined(EMBOSS_BYTESWAP16)
+
+#if !defined(EMBOSS_BYTESWAP32)
 #define EMBOSS_BYTESWAP32(x) __builtin_bswap32((x))
+#endif  // !defined(EMBOSS_BYTESWAP32)
+
+#if !defined(EMBOSS_BYTESWAP64)
 #define EMBOSS_BYTESWAP64(x) __builtin_bswap64((x))
+#endif  // !defined(EMBOSS_BYTESWAP64)
 
 #endif  // defined(__GNUC__)
 #endif  // !defined(EMBOSS_NO_OPTIMIZATIONS)
 
-#endif  // EMBOSS_PUBLIC_EMBOSS_DEFINES_H_
+#if !defined(EMBOSS_SYSTEM_IS_TWOS_COMPLEMENT)
+#define EMBOSS_SYSTEM_IS_TWOS_COMPLEMENT 0
+#endif  // !defined(EMBOSS_SYSTEM_IS_TWOS_COMPLEMENT)
+
+#endif  // THIRD_PARTY_EMBOSS_PUBLIC_EMBOSS_DEFINES_H_