Skip to content

Commit

Permalink
Fix Make Unused Not Compiler Specific (#34357)
Browse files Browse the repository at this point in the history
Summary:
Use of `__attribute__` and `__unused` is compiler specific. Opt for standard `[[maybe_unused]]` instead.

## Changelog

[General] [Fixed] - Remove compiler-specific syntax.

Pull Request resolved: #34357

Test Plan: Built on react-native-windows.

Reviewed By: cipolleschi

Differential Revision: D38498481

Pulled By: javache

fbshipit-source-id: af43206788f54dda3b747b6417e20096c7d520e8
  • Loading branch information
chiaramooney authored and facebook-github-bot committed Aug 8, 2022
1 parent 60e7eb4 commit 33dbb6c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion React/Base/RCTModuleMethod.mm
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static BOOL RCTParseSelectorPart(const char **input, NSMutableString *selector)
static BOOL RCTParseUnused(const char **input)
{
return RCTReadString(input, "__attribute__((unused))") || RCTReadString(input, "__attribute__((__unused__))") ||
RCTReadString(input, "__unused");
RCTReadString(input, "__unused") || RCTReadString(input, "[[maybe_unused]]");
}

static RCTNullability RCTParseNullability(const char **input)
Expand Down
3 changes: 1 addition & 2 deletions ReactCommon/cxxreact/JSExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ class RN_EXPORT JSExecutor {
*/
virtual std::string getDescription() = 0;

virtual void handleMemoryPressure(__attribute__((unused)) int pressureLevel) {
}
virtual void handleMemoryPressure([[maybe_unused]] int pressureLevel) {}

virtual void destroy() {}
virtual ~JSExecutor() {}
Expand Down
4 changes: 2 additions & 2 deletions ReactCommon/cxxreact/NativeToJsBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class JsToNativeBridge : public react::ExecutorDelegate {
}

void callNativeModules(
__attribute__((unused)) JSExecutor &executor,
[[maybe_unused]] JSExecutor &executor,
folly::dynamic &&calls,
bool isEndOfBatch) override {
CHECK(m_registry || calls.empty())
Expand Down Expand Up @@ -85,7 +85,7 @@ class JsToNativeBridge : public react::ExecutorDelegate {
}

MethodCallResult callSerializableNativeHook(
__attribute__((unused)) JSExecutor &executor,
[[maybe_unused]] JSExecutor &executor,
unsigned int moduleId,
unsigned int methodId,
folly::dynamic &&args) override {
Expand Down
2 changes: 1 addition & 1 deletion ReactCommon/cxxreact/SampleCxxModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void SampleCxxModule::save(folly::dynamic args) {
sample_->save(std::move(m));
}

void SampleCxxModule::load(__unused folly::dynamic args, Callback cb) {
void SampleCxxModule::load([[maybe_unused]] folly::dynamic args, Callback cb) {
dynamic d = dynamic::object;
for (const auto &p : sample_->load()) {
d.insert(p.first, p.second);
Expand Down
2 changes: 1 addition & 1 deletion ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void JSIExecutor::setBundleRegistry(std::unique_ptr<RAMBundleRegistry> r) {
PropNameID::forAscii(*runtime_, "nativeRequire"),
2,
[this](
__unused Runtime &rt,
[[maybe_unused]] Runtime &rt,
const facebook::jsi::Value &,
const facebook::jsi::Value *args,
size_t count) { return nativeRequire(args, count); }));
Expand Down

0 comments on commit 33dbb6c

Please sign in to comment.