Patches for Flutter * BUILD.gn file * Workaround for a clang-tidy warning Change-Id: I8f187d9021777260759f16a710c4529cfbaf31a9 Reviewed-on: https://flutter-review.googlesource.com/c/third_party/rapidjson/+/75740 Reviewed-by: John McDole <codefu@google.com>
diff --git a/BUILD.gn b/BUILD.gn new file mode 100644 index 0000000..92b7a01 --- /dev/null +++ b/BUILD.gn
@@ -0,0 +1,86 @@ +# Copyright 2016 The Fuchsia Authors. All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +config("rapidjson_config") { + include_dirs = [ + ".", + "include", + ] + + # rapidjson needs these defines to support C++11 features. These features + # are intentionally not autodetected by rapidjson. + defines = [ + "RAPIDJSON_HAS_STDSTRING", + "RAPIDJSON_HAS_CXX11_RANGE_FOR", + "RAPIDJSON_HAS_CXX11_RVALUE_REFS", + "RAPIDJSON_HAS_CXX11_TYPETRAITS", + "RAPIDJSON_HAS_CXX11_NOEXCEPT", + ] +} + +source_set("rapidjson") { + sources = [ + "include/rapidjson/allocators.h", + "include/rapidjson/cursorstreamwrapper.h", + "include/rapidjson/document.h", + "include/rapidjson/encodedstream.h", + "include/rapidjson/encodings.h", + "include/rapidjson/error/en.h", + "include/rapidjson/error/error.h", + "include/rapidjson/filereadstream.h", + "include/rapidjson/filewritestream.h", + "include/rapidjson/fwd.h", + "include/rapidjson/internal/biginteger.h", + "include/rapidjson/internal/diyfp.h", + "include/rapidjson/internal/dtoa.h", + "include/rapidjson/internal/ieee754.h", + "include/rapidjson/internal/itoa.h", + "include/rapidjson/internal/meta.h", + "include/rapidjson/internal/pow10.h", + "include/rapidjson/internal/regex.h", + "include/rapidjson/internal/stack.h", + "include/rapidjson/internal/strfunc.h", + "include/rapidjson/internal/strtod.h", + "include/rapidjson/internal/swap.h", + "include/rapidjson/istreamwrapper.h", + "include/rapidjson/memorybuffer.h", + "include/rapidjson/memorystream.h", + "include/rapidjson/msinttypes/inttypes.h", + "include/rapidjson/msinttypes/stdint.h", + "include/rapidjson/ostreamwrapper.h", + "include/rapidjson/pointer.h", + "include/rapidjson/prettywriter.h", + "include/rapidjson/rapidjson.h", + "include/rapidjson/reader.h", + "include/rapidjson/schema.h", + "include/rapidjson/stream.h", + "include/rapidjson/stringbuffer.h", + "include/rapidjson/writer.h", + ] + + public_configs = [ ":rapidjson_config" ] +}
diff --git a/include/rapidjson/internal/stack.h b/include/rapidjson/internal/stack.h index 73abd70..f83e841 100644 --- a/include/rapidjson/internal/stack.h +++ b/include/rapidjson/internal/stack.h
@@ -175,7 +175,10 @@ } bool Empty() const { return stackTop_ == stack_; } - size_t GetSize() const { return static_cast<size_t>(stackTop_ - stack_); } + size_t GetSize() const { + // NOLINTNEXTLINE(clang-analyzer-core.NullPointerArithm) + return static_cast<size_t>(stackTop_ - stack_); + } size_t GetCapacity() const { return static_cast<size_t>(stackEnd_ - stack_); } private: