Skip to content

Commit 9041714

Browse files
committed
Fix JSCRuntime invalidate() specifier ordering (noexcept before JSI_DISABLE_ASAN)
Clang requires noexcept to appear before compiler attributes like __attribute__((no_sanitize("address"))). Having JSI_DISABLE_ASAN (which expands to that attribute when ASAN is enabled) after noexcept causes a build error: error: expected function body after function declarator Reorder to: noexcept JSI_DISABLE_ASAN across all four affected sites.
1 parent eb3bccb commit 9041714

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

packages/react-native/ReactCommon/jsc/JSCRuntime.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
#include "JSCRuntime.h"
99

1010
#include <JavaScriptCore/JavaScript.h>
11+
12+
#if __has_feature(address_sanitizer)
13+
#define JSI_DISABLE_ASAN __attribute__((no_sanitize("address")))
14+
#else
15+
#define JSI_DISABLE_ASAN
16+
#endif
1117
#include <jsi/jsilib.h>
1218
#include <array>
1319
#include <atomic>
@@ -527,7 +533,7 @@ JSCRuntime::JSCSymbolValue::JSCSymbolValue(
527533
#endif
528534
}
529535

530-
void JSCRuntime::JSCSymbolValue::invalidate() noexcept {
536+
void JSCRuntime::JSCSymbolValue::invalidate() noexcept JSI_DISABLE_ASAN {
531537
#ifndef NDEBUG
532538
counter_ -= 1;
533539
#endif
@@ -552,7 +558,7 @@ JSCRuntime::JSCStringValue::JSCStringValue(JSStringRef str)
552558
: str_(JSStringRetain(str)) {}
553559
#endif
554560

555-
void JSCRuntime::JSCStringValue::invalidate() noexcept {
561+
void JSCRuntime::JSCStringValue::invalidate() noexcept JSI_DISABLE_ASAN {
556562
// These JSC{String,Object}Value objects are implicitly owned by the
557563
// {String,Object} objects, thus when a String/Object is destructed
558564
// the JSC{String,Object}Value should be released.
@@ -587,7 +593,7 @@ JSCRuntime::JSCObjectValue::JSCObjectValue(
587593
#endif
588594
}
589595

590-
void JSCRuntime::JSCObjectValue::invalidate() noexcept {
596+
void JSCRuntime::JSCObjectValue::invalidate() noexcept JSI_DISABLE_ASAN {
591597
#ifndef NDEBUG
592598
counter_ -= 1;
593599
#endif
@@ -863,7 +869,7 @@ jsi::Object JSCRuntime::createObject(std::shared_ptr<jsi::HostObject> ho) {
863869
static void getPropertyNames(
864870
JSContextRef ctx,
865871
JSObjectRef object,
866-
JSPropertyNameAccumulatorRef propertyNames) noexcept {
872+
JSPropertyNameAccumulatorRef propertyNames) noexcept JSI_DISABLE_ASAN {
867873
JSC_UNUSED(ctx);
868874
auto proxy = static_cast<HostObjectProxy*>(JSObjectGetPrivate(object));
869875
auto& rt = proxy->runtime;

0 commit comments

Comments
 (0)