diff options
author | George Burgess IV <gbiv@google.com> | 2017-08-22 10:37:54 -0700 |
---|---|---|
committer | George Burgess <george.burgess.iv@gmail.com> | 2017-08-22 10:38:23 -0700 |
commit | 6cecd20e259b09dd09a78d0f1b742be41e715806 (patch) | |
tree | e09684e29689d5b65eac81b83415467b40f2071c /src/google/protobuf/metadata_lite.h | |
parent | 5e39ecc569153db63bc4e1587f703c7894223375 (diff) | |
download | protobuf-6cecd20e259b09dd09a78d0f1b742be41e715806.tar.gz protobuf-6cecd20e259b09dd09a78d0f1b742be41e715806.tar.bz2 protobuf-6cecd20e259b09dd09a78d0f1b742be41e715806.zip |
Work around a bug in clang's static analyzer
Due to https://bugs.llvm.org/show_bug.cgi?id=34198, clang's static
analyzer emits diagnostics about leaking `container`. Doing this
assignment in two steps works around this, and shouldn't cause these
issues.
Diffstat (limited to 'src/google/protobuf/metadata_lite.h')
-rw-r--r-- | src/google/protobuf/metadata_lite.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/google/protobuf/metadata_lite.h b/src/google/protobuf/metadata_lite.h index 64fde0c6..6022be92 100644 --- a/src/google/protobuf/metadata_lite.h +++ b/src/google/protobuf/metadata_lite.h @@ -150,8 +150,11 @@ class InternalMetadataWithArenaBase { GOOGLE_ATTRIBUTE_NOINLINE T* mutable_unknown_fields_slow() { Arena* my_arena = arena(); Container* container = Arena::Create<Container>(my_arena); + // Two-step assignment works around a bug in clang's static analyzer: + // https://bugs.llvm.org/show_bug.cgi?id=34198. + ptr_ = container; ptr_ = reinterpret_cast<void*>( - reinterpret_cast<intptr_t>(container) | kTagContainer); + reinterpret_cast<intptr_t>(ptr_) | kTagContainer); container->arena = my_arena; return &(container->unknown_fields); } |