Skip to content

Commit 0b411d0

Browse files
Auto-generate files after cl/762591913
1 parent 974884e commit 0b411d0

File tree

4 files changed

+40
-6
lines changed

4 files changed

+40
-6
lines changed

php/ext/google/protobuf/php-upb.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,12 @@ Error, UINTPTR_MAX is undefined
231231
#define UPB_PRINTF(str, first_vararg)
232232
#endif
233233

234+
#if defined(__clang__)
235+
#define UPB_NODEREF __attribute__((noderef))
236+
#else
237+
#define UPB_NODEREF
238+
#endif
239+
234240
#define UPB_MAX(x, y) ((x) > (y) ? (x) : (y))
235241
#define UPB_MIN(x, y) ((x) < (y) ? (x) : (y))
236242

@@ -8350,7 +8356,9 @@ typedef struct {
83508356
upb_EncodeStatus status;
83518357
jmp_buf err;
83528358
upb_Arena* arena;
8353-
char *buf, *limit;
8359+
// These should only be used for arithmetic and reallocation to allow full
8360+
// aliasing analysis on the ptr argument.
8361+
const char UPB_NODEREF *buf, *limit;
83548362
int options;
83558363
int depth;
83568364
_upb_mapsorter sorter;
@@ -8375,7 +8383,8 @@ static char* encode_growbuffer(char* ptr, upb_encstate* e, size_t bytes) {
83758383
size_t old_size = e->limit - e->buf;
83768384
size_t needed_size = bytes + (e->limit - ptr);
83778385
size_t new_size = upb_roundup_pow2(needed_size);
8378-
char* new_buf = upb_Arena_Realloc(e->arena, e->buf, old_size, new_size);
8386+
char* new_buf =
8387+
upb_Arena_Realloc(e->arena, (void*)e->buf, old_size, new_size);
83798388

83808389
if (!new_buf) encode_err(e, kUpb_EncodeStatus_OutOfMemory);
83818390

@@ -17725,6 +17734,7 @@ upb_ServiceDef* _upb_ServiceDefs_New(upb_DefBuilder* ctx, int n,
1772517734
#undef UPB_NOINLINE
1772617735
#undef UPB_NORETURN
1772717736
#undef UPB_PRINTF
17737+
#undef UPB_NODEREF
1772817738
#undef UPB_MAX
1772917739
#undef UPB_MIN
1773017740
#undef UPB_UNUSED

php/ext/google/protobuf/php-upb.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@ Error, UINTPTR_MAX is undefined
230230
#define UPB_PRINTF(str, first_vararg)
231231
#endif
232232

233+
#if defined(__clang__)
234+
#define UPB_NODEREF __attribute__((noderef))
235+
#else
236+
#define UPB_NODEREF
237+
#endif
238+
233239
#define UPB_MAX(x, y) ((x) > (y) ? (x) : (y))
234240
#define UPB_MIN(x, y) ((x) < (y) ? (x) : (y))
235241

@@ -853,7 +859,7 @@ UPB_INLINE void UPB_PRIVATE(upb_Xsan_AccessReadWrite)(upb_Xsan *xsan) {
853859

854860
struct upb_Arena {
855861
char* UPB_ONLYBITS(ptr);
856-
char* UPB_ONLYBITS(end);
862+
const UPB_NODEREF char* UPB_ONLYBITS(end);
857863
UPB_XSAN_MEMBER
858864
};
859865

@@ -16510,6 +16516,7 @@ upb_MethodDef* _upb_MethodDefs_New(upb_DefBuilder* ctx, int n,
1651016516
#undef UPB_NOINLINE
1651116517
#undef UPB_NORETURN
1651216518
#undef UPB_PRINTF
16519+
#undef UPB_NODEREF
1651316520
#undef UPB_MAX
1651416521
#undef UPB_MIN
1651516522
#undef UPB_UNUSED

ruby/ext/google/protobuf_c/ruby-upb.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,12 @@ Error, UINTPTR_MAX is undefined
231231
#define UPB_PRINTF(str, first_vararg)
232232
#endif
233233

234+
#if defined(__clang__)
235+
#define UPB_NODEREF __attribute__((noderef))
236+
#else
237+
#define UPB_NODEREF
238+
#endif
239+
234240
#define UPB_MAX(x, y) ((x) > (y) ? (x) : (y))
235241
#define UPB_MIN(x, y) ((x) < (y) ? (x) : (y))
236242

@@ -8350,7 +8356,9 @@ typedef struct {
83508356
upb_EncodeStatus status;
83518357
jmp_buf err;
83528358
upb_Arena* arena;
8353-
char *buf, *limit;
8359+
// These should only be used for arithmetic and reallocation to allow full
8360+
// aliasing analysis on the ptr argument.
8361+
const char UPB_NODEREF *buf, *limit;
83548362
int options;
83558363
int depth;
83568364
_upb_mapsorter sorter;
@@ -8375,7 +8383,8 @@ static char* encode_growbuffer(char* ptr, upb_encstate* e, size_t bytes) {
83758383
size_t old_size = e->limit - e->buf;
83768384
size_t needed_size = bytes + (e->limit - ptr);
83778385
size_t new_size = upb_roundup_pow2(needed_size);
8378-
char* new_buf = upb_Arena_Realloc(e->arena, e->buf, old_size, new_size);
8386+
char* new_buf =
8387+
upb_Arena_Realloc(e->arena, (void*)e->buf, old_size, new_size);
83798388

83808389
if (!new_buf) encode_err(e, kUpb_EncodeStatus_OutOfMemory);
83818390

@@ -17268,6 +17277,7 @@ google_protobuf_ServiceDescriptorProto* upb_ServiceDef_ToProto(const upb_Service
1726817277
#undef UPB_NOINLINE
1726917278
#undef UPB_NORETURN
1727017279
#undef UPB_PRINTF
17280+
#undef UPB_NODEREF
1727117281
#undef UPB_MAX
1727217282
#undef UPB_MIN
1727317283
#undef UPB_UNUSED

ruby/ext/google/protobuf_c/ruby-upb.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ Error, UINTPTR_MAX is undefined
232232
#define UPB_PRINTF(str, first_vararg)
233233
#endif
234234

235+
#if defined(__clang__)
236+
#define UPB_NODEREF __attribute__((noderef))
237+
#else
238+
#define UPB_NODEREF
239+
#endif
240+
235241
#define UPB_MAX(x, y) ((x) > (y) ? (x) : (y))
236242
#define UPB_MIN(x, y) ((x) < (y) ? (x) : (y))
237243

@@ -855,7 +861,7 @@ UPB_INLINE void UPB_PRIVATE(upb_Xsan_AccessReadWrite)(upb_Xsan *xsan) {
855861

856862
struct upb_Arena {
857863
char* UPB_ONLYBITS(ptr);
858-
char* UPB_ONLYBITS(end);
864+
const UPB_NODEREF char* UPB_ONLYBITS(end);
859865
UPB_XSAN_MEMBER
860866
};
861867

@@ -16349,6 +16355,7 @@ google_protobuf_ServiceDescriptorProto* upb_ServiceDef_ToProto(
1634916355
#undef UPB_NOINLINE
1635016356
#undef UPB_NORETURN
1635116357
#undef UPB_PRINTF
16358+
#undef UPB_NODEREF
1635216359
#undef UPB_MAX
1635316360
#undef UPB_MIN
1635416361
#undef UPB_UNUSED

0 commit comments

Comments
 (0)