Commit 9a1b4763 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[config] Add V8_NODISCARD to Scopes in v8.h

Like  https://crrev.com/c/v8/v8/+/2555001 for v8.h. Done in a separate
CL in case it needed to be reverted.

Change-Id: I0c7a7cb24e8f0855c8b80ddeeaab979f10011c4a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2562252Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71455}
parent bea99787
...@@ -1197,7 +1197,7 @@ class TracedReference : public BasicTracedReference<T> { ...@@ -1197,7 +1197,7 @@ class TracedReference : public BasicTracedReference<T> {
* handle and may deallocate it. The behavior of accessing a handle * handle and may deallocate it. The behavior of accessing a handle
* for which the handle scope has been deleted is undefined. * for which the handle scope has been deleted is undefined.
*/ */
class V8_EXPORT HandleScope { class V8_EXPORT V8_NODISCARD HandleScope {
public: public:
explicit HandleScope(Isolate* isolate); explicit HandleScope(Isolate* isolate);
...@@ -1244,12 +1244,11 @@ class V8_EXPORT HandleScope { ...@@ -1244,12 +1244,11 @@ class V8_EXPORT HandleScope {
friend class Context; friend class Context;
}; };
/** /**
* A HandleScope which first allocates a handle in the current scope * A HandleScope which first allocates a handle in the current scope
* which will be later filled with the escape value. * which will be later filled with the escape value.
*/ */
class V8_EXPORT EscapableHandleScope : public HandleScope { class V8_EXPORT V8_NODISCARD EscapableHandleScope : public HandleScope {
public: public:
explicit EscapableHandleScope(Isolate* isolate); explicit EscapableHandleScope(Isolate* isolate);
V8_INLINE ~EscapableHandleScope() = default; V8_INLINE ~EscapableHandleScope() = default;
...@@ -1290,7 +1289,7 @@ class V8_EXPORT EscapableHandleScope : public HandleScope { ...@@ -1290,7 +1289,7 @@ class V8_EXPORT EscapableHandleScope : public HandleScope {
* are allowed. It can be useful for debugging handle leaks. * are allowed. It can be useful for debugging handle leaks.
* Handles can be allocated within inner normal HandleScopes. * Handles can be allocated within inner normal HandleScopes.
*/ */
class V8_EXPORT SealHandleScope { class V8_EXPORT V8_NODISCARD SealHandleScope {
public: public:
explicit SealHandleScope(Isolate* isolate); explicit SealHandleScope(Isolate* isolate);
~SealHandleScope(); ~SealHandleScope();
...@@ -1311,7 +1310,6 @@ class V8_EXPORT SealHandleScope { ...@@ -1311,7 +1310,6 @@ class V8_EXPORT SealHandleScope {
int prev_sealed_level_; int prev_sealed_level_;
}; };
// --- Special objects --- // --- Special objects ---
/** /**
...@@ -7590,7 +7588,7 @@ class V8_EXPORT MicrotaskQueue { ...@@ -7590,7 +7588,7 @@ class V8_EXPORT MicrotaskQueue {
* kDoNotRunMicrotasks should be used to annotate calls not intended to trigger * kDoNotRunMicrotasks should be used to annotate calls not intended to trigger
* microtasks. * microtasks.
*/ */
class V8_EXPORT MicrotasksScope { class V8_EXPORT V8_NODISCARD MicrotasksScope {
public: public:
enum Type { kRunMicrotasks, kDoNotRunMicrotasks }; enum Type { kRunMicrotasks, kDoNotRunMicrotasks };
...@@ -7623,7 +7621,6 @@ class V8_EXPORT MicrotasksScope { ...@@ -7623,7 +7621,6 @@ class V8_EXPORT MicrotasksScope {
bool run_; bool run_;
}; };
// --- Failed Access Check Callback --- // --- Failed Access Check Callback ---
typedef void (*FailedAccessCheckCallback)(Local<Object> target, typedef void (*FailedAccessCheckCallback)(Local<Object> target,
AccessType type, AccessType type,
...@@ -8415,7 +8412,7 @@ class V8_EXPORT Isolate { ...@@ -8415,7 +8412,7 @@ class V8_EXPORT Isolate {
* Stack-allocated class which sets the isolate for all operations * Stack-allocated class which sets the isolate for all operations
* executed within a local scope. * executed within a local scope.
*/ */
class V8_EXPORT Scope { class V8_EXPORT V8_NODISCARD Scope {
public: public:
explicit Scope(Isolate* isolate) : isolate_(isolate) { explicit Scope(Isolate* isolate) : isolate_(isolate) {
isolate->Enter(); isolate->Enter();
...@@ -8431,11 +8428,10 @@ class V8_EXPORT Isolate { ...@@ -8431,11 +8428,10 @@ class V8_EXPORT Isolate {
Isolate* const isolate_; Isolate* const isolate_;
}; };
/** /**
* Assert that no Javascript code is invoked. * Assert that no Javascript code is invoked.
*/ */
class V8_EXPORT DisallowJavascriptExecutionScope { class V8_EXPORT V8_NODISCARD DisallowJavascriptExecutionScope {
public: public:
enum OnFailure { CRASH_ON_FAILURE, THROW_ON_FAILURE, DUMP_ON_FAILURE }; enum OnFailure { CRASH_ON_FAILURE, THROW_ON_FAILURE, DUMP_ON_FAILURE };
...@@ -8453,11 +8449,10 @@ class V8_EXPORT Isolate { ...@@ -8453,11 +8449,10 @@ class V8_EXPORT Isolate {
void* internal_; void* internal_;
}; };
/** /**
* Introduce exception to DisallowJavascriptExecutionScope. * Introduce exception to DisallowJavascriptExecutionScope.
*/ */
class V8_EXPORT AllowJavascriptExecutionScope { class V8_EXPORT V8_NODISCARD AllowJavascriptExecutionScope {
public: public:
explicit AllowJavascriptExecutionScope(Isolate* isolate); explicit AllowJavascriptExecutionScope(Isolate* isolate);
~AllowJavascriptExecutionScope(); ~AllowJavascriptExecutionScope();
...@@ -8478,7 +8473,7 @@ class V8_EXPORT Isolate { ...@@ -8478,7 +8473,7 @@ class V8_EXPORT Isolate {
* Do not run microtasks while this scope is active, even if microtasks are * Do not run microtasks while this scope is active, even if microtasks are
* automatically executed otherwise. * automatically executed otherwise.
*/ */
class V8_EXPORT SuppressMicrotaskExecutionScope { class V8_EXPORT V8_NODISCARD SuppressMicrotaskExecutionScope {
public: public:
explicit SuppressMicrotaskExecutionScope( explicit SuppressMicrotaskExecutionScope(
Isolate* isolate, MicrotaskQueue* microtask_queue = nullptr); Isolate* isolate, MicrotaskQueue* microtask_queue = nullptr);
...@@ -8502,7 +8497,7 @@ class V8_EXPORT Isolate { ...@@ -8502,7 +8497,7 @@ class V8_EXPORT Isolate {
* This scope allows terminations inside direct V8 API calls and forbid them * This scope allows terminations inside direct V8 API calls and forbid them
* inside any recursive API calls without explicit SafeForTerminationScope. * inside any recursive API calls without explicit SafeForTerminationScope.
*/ */
class V8_EXPORT SafeForTerminationScope { class V8_EXPORT V8_NODISCARD SafeForTerminationScope {
public: public:
explicit SafeForTerminationScope(v8::Isolate* isolate); explicit SafeForTerminationScope(v8::Isolate* isolate);
~SafeForTerminationScope(); ~SafeForTerminationScope();
...@@ -10638,7 +10633,7 @@ class V8_EXPORT Context { ...@@ -10638,7 +10633,7 @@ class V8_EXPORT Context {
* Stack-allocated class which sets the execution context for all * Stack-allocated class which sets the execution context for all
* operations executed within a local scope. * operations executed within a local scope.
*/ */
class Scope { class V8_NODISCARD Scope {
public: public:
explicit V8_INLINE Scope(Local<Context> context) : context_(context) { explicit V8_INLINE Scope(Local<Context> context) : context_(context) {
context_->Enter(); context_->Enter();
...@@ -10654,7 +10649,7 @@ class V8_EXPORT Context { ...@@ -10654,7 +10649,7 @@ class V8_EXPORT Context {
* stack. * stack.
* https://html.spec.whatwg.org/multipage/webappapis.html#backup-incumbent-settings-object-stack * https://html.spec.whatwg.org/multipage/webappapis.html#backup-incumbent-settings-object-stack
*/ */
class V8_EXPORT BackupIncumbentScope final { class V8_EXPORT V8_NODISCARD BackupIncumbentScope final {
public: public:
/** /**
* |backup_incumbent_context| is pushed onto the backup incumbent settings * |backup_incumbent_context| is pushed onto the backup incumbent settings
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment