Skip to content

Commit

Permalink
Cherry-pick 262664@main (2b34340). https://bugs.webkit.org/show_bug.c…
Browse files Browse the repository at this point in the history
…gi?id=254758

    Fix build with GCC 13 -Werror
    https://bugs.webkit.org/show_bug.cgi?id=254758

    Reviewed by Adrian Perez de Castro.

    This allows building with GCC 13 in DEVELOPER_MODE (where warnings are
    now fatal).

    * Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:
    (JSC::BytecodeGenerator::BytecodeGenerator):
    * Source/JavaScriptCore/heap/AbstractSlotVisitorInlines.h:
    (JSC::AbstractSlotVisitor::ReferrerContext::ReferrerContext):
    * Source/WebCore/animation/DocumentTimeline.cpp:
    (WebCore::DocumentTimeline::animationCanBeRemoved):
    * Source/WebCore/platform/animation/TimingFunction.h:
    * Source/WebCore/platform/graphics/AudioTrackPrivate.h:
    (WebCore::AudioTrackPrivate::operator== const):
    * Source/WebCore/platform/graphics/InbandTextTrackPrivate.h:
    (WebCore::InbandTextTrackPrivate::operator== const):
    * Source/WebCore/platform/graphics/TrackPrivateBase.h:
    * Source/WebCore/platform/graphics/VideoTrackPrivate.h:
    (WebCore::VideoTrackPrivate::operator== const):
    * Source/WebCore/style/ElementRuleCollector.cpp:
    (WebCore::Style::leftToRightDeclaration):
    (WebCore::Style::rightToLeftDeclaration):
    * Source/WebCore/svg/SVGPathSeg.h:
    * Source/bmalloc/libpas/src/libpas/pas_fast_megapage_table.c:
    (pas_fast_megapage_table_set_by_index):
    * Tools/TestWebKitAPI/Tests/WTF/BoxPtr.cpp:
    (TestWebKitAPI::TEST):
    * Tools/TestWebKitAPI/Tests/WTF/CompactRefPtr.cpp:
    (TestWebKitAPI::TEST):
    * Tools/TestWebKitAPI/Tests/WTF/NakedPtr.cpp:
    (TestWebKitAPI::TEST):
    * Tools/TestWebKitAPI/Tests/WTF/PackedRefPtr.cpp:
    (TestWebKitAPI::TEST):
    * Tools/TestWebKitAPI/Tests/WTF/RefPtr.cpp:
    (TestWebKitAPI::TEST):

    Canonical link: https://commits.webkit.org/262664@main
  • Loading branch information
mcatanzaro authored and aperezdc committed Apr 6, 2023
1 parent c9c32c1 commit 2804afc
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 43 deletions.
2 changes: 2 additions & 0 deletions Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
Expand Up @@ -626,8 +626,10 @@ BytecodeGenerator::BytecodeGenerator(VM& vm, FunctionNode* functionNode, Unlinke
}

ScopeOffset offset = functionSymbolTable->takeNextScopeOffset(NoLockingNecessary);
IGNORE_GCC_WARNINGS_BEGIN("dangling-reference")
const Identifier& ident =
static_cast<const BindingNode*>(parameters.at(i).first)->boundProperty();
IGNORE_GCC_WARNINGS_END
functionSymbolTable->set(NoLockingNecessary, name, SymbolTableEntry(VarOffset(offset)));

OpPutToScope::emit(this, m_lexicalEnvironmentRegister, addConstant(ident), virtualRegisterForArgumentIncludingThis(1 + i), GetPutInfo(ThrowIfNotFound, ResolvedClosureVar, InitializationMode::NotInitialization, ecmaMode), SymbolTableOrScopeDepth::symbolTable(VirtualRegister { symbolTableConstantIndex }), offset.offset());
Expand Down
2 changes: 2 additions & 0 deletions Source/JavaScriptCore/heap/AbstractSlotVisitorInlines.h
Expand Up @@ -88,7 +88,9 @@ inline AbstractSlotVisitor::ReferrerContext::ReferrerContext(AbstractSlotVisitor
// An OpaqueRoot contexts can only be on the leaf.
RELEASE_ASSERT(!m_previous->m_isOpaqueRootContext);
}
IGNORE_GCC_WARNINGS_BEGIN("dangling-pointer")
m_visitor.m_context = this;
IGNORE_GCC_WARNINGS_END
}

inline AbstractSlotVisitor::ReferrerContext::~ReferrerContext()
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/animation/DocumentTimeline.cpp
Expand Up @@ -241,11 +241,13 @@ bool DocumentTimeline::animationCanBeRemoved(WebAnimation& animation)
if (!target || !target->element.isDescendantOf(*m_document))
return false;

IGNORE_GCC_WARNINGS_BEGIN("dangling-reference")
auto& style = [&]() -> const RenderStyle& {
if (auto* renderer = target->renderer())
return renderer->style();
return RenderStyle::defaultStyle();
}();
IGNORE_GCC_WARNINGS_END

auto resolvedProperty = [&] (AnimatableProperty property) -> AnimatableProperty {
if (std::holds_alternative<CSSPropertyID>(property))
Expand Down
9 changes: 5 additions & 4 deletions Source/WebCore/platform/animation/TimingFunction.h
Expand Up @@ -26,6 +26,7 @@

#include "CSSValue.h"
#include "ExceptionOr.h"
#include <wtf/NeverDestroyed.h>
#include <wtf/Ref.h>
#include <wtf/RefCounted.h>

Expand Down Expand Up @@ -72,8 +73,8 @@ class LinearTimingFunction final : public TimingFunction {

static const LinearTimingFunction& sharedLinearTimingFunction()
{
static const LinearTimingFunction& function = create().leakRef();
return function;
static NeverDestroyed<Ref<LinearTimingFunction>> function { create() };
return function.get();
}

private:
Expand Down Expand Up @@ -138,8 +139,8 @@ class CubicBezierTimingFunction final : public TimingFunction {

static const CubicBezierTimingFunction& defaultTimingFunction()
{
static const CubicBezierTimingFunction& function = create().leakRef();
return function;
static NeverDestroyed<Ref<CubicBezierTimingFunction>> function { create() };
return function.get();
}

Ref<CubicBezierTimingFunction> createReversed() const
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/platform/graphics/AudioTrackPrivate.h
Expand Up @@ -76,7 +76,7 @@ class AudioTrackPrivate : public TrackPrivateBase {
m_client->configurationChanged(m_configuration);
}

virtual bool operator==(const AudioTrackPrivate& track) const
bool operator==(const AudioTrackPrivate& track) const
{
return TrackPrivateBase::operator==(track)
&& configuration() == track.configuration()
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/platform/graphics/InbandTextTrackPrivate.h
Expand Up @@ -77,7 +77,7 @@ class InbandTextTrackPrivate : public TrackPrivateBase {

CueFormat cueFormat() const { return m_format; }

virtual bool operator==(const InbandTextTrackPrivate& track) const
bool operator==(const InbandTextTrackPrivate& track) const
{
return TrackPrivateBase::operator==(track)
&& cueFormat() == track.cueFormat()
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/platform/graphics/TrackPrivateBase.h
Expand Up @@ -66,7 +66,7 @@ class WEBCORE_EXPORT TrackPrivateBase
client->willRemove();
}

virtual bool operator==(const TrackPrivateBase&) const;
bool operator==(const TrackPrivateBase&) const;

#if !RELEASE_LOG_DISABLED
virtual void setLogger(const Logger&, const void*);
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/platform/graphics/VideoTrackPrivate.h
Expand Up @@ -72,7 +72,7 @@ class VideoTrackPrivate : public TrackPrivateBase {
m_client->configurationChanged(m_configuration);
}

virtual bool operator==(const VideoTrackPrivate& track) const
bool operator==(const VideoTrackPrivate& track) const
{
return TrackPrivateBase::operator==(track)
&& configuration() == track.configuration()
Expand Down
4 changes: 4 additions & 0 deletions Source/WebCore/style/ElementRuleCollector.cpp
Expand Up @@ -57,21 +57,25 @@ namespace Style {

static const StyleProperties& leftToRightDeclaration()
{
IGNORE_GCC_WARNINGS_BEGIN("dangling-reference")
static auto& declaration = [] () -> const StyleProperties& {
auto properties = MutableStyleProperties::create();
properties->setProperty(CSSPropertyDirection, CSSValueLtr);
return properties.leakRef();
}();
IGNORE_GCC_WARNINGS_END
return declaration;
}

static const StyleProperties& rightToLeftDeclaration()
{
IGNORE_GCC_WARNINGS_BEGIN("dangling-reference")
static auto& declaration = [] () -> const StyleProperties& {
auto properties = MutableStyleProperties::create();
properties->setProperty(CSSPropertyDirection, CSSValueRtl);
return properties.leakRef();
}();
IGNORE_GCC_WARNINGS_END
return declaration;
}

Expand Down
5 changes: 5 additions & 0 deletions Source/WebCore/svg/SVGPathSeg.h
Expand Up @@ -79,7 +79,12 @@ class SVGPathSeg : public SVGProperty {

virtual unsigned short pathSegType() const = 0;
virtual String pathSegTypeAsLetter() const = 0;

IGNORE_GCC_WARNINGS_BEGIN("overloaded-virtual")
// FIXME: SVGPathSegValue has a templated (and therefore non-virtual) clone
// function that hides this one, which is fragile and very confusing.
virtual Ref<SVGPathSeg> clone() const = 0;
IGNORE_GCC_WARNINGS_END

protected:
using SVGProperty::SVGProperty;
Expand Down
2 changes: 1 addition & 1 deletion Source/bmalloc/libpas/src/libpas/pas_fast_megapage_table.c
Expand Up @@ -83,7 +83,7 @@ void pas_fast_megapage_table_initialize_static(pas_fast_megapage_table* table,
}

void pas_fast_megapage_table_set_by_index(pas_fast_megapage_table* table,
size_t index, unsigned value,
size_t index, pas_fast_megapage_kind value,
pas_lock_hold_mode heap_lock_hold_mode)
{
pas_fast_megapage_table_impl* instance;
Expand Down
4 changes: 2 additions & 2 deletions Tools/TestWebKitAPI/Tests/WTF/BoxPtr.cpp
Expand Up @@ -172,9 +172,9 @@ TEST(WTF_BoxPtr, Assignment)
BoxPtrLogger* a = BoxPtrLogger::create("a");
BoxPtr<BoxPtrLogger> ptr = adoptInBoxPtr(a);
EXPECT_EQ(a, ptr->get());
IGNORE_CLANG_WARNINGS_BEGIN("self-move")
IGNORE_WARNINGS_BEGIN("self-move")
ptr = WTFMove(ptr);
IGNORE_CLANG_WARNINGS_END
IGNORE_WARNINGS_END
EXPECT_EQ(a, ptr->get());
}
EXPECT_STREQ("create(a) delete(a) ", takeLogStr().c_str());
Expand Down
10 changes: 2 additions & 8 deletions Tools/TestWebKitAPI/Tests/WTF/CompactRefPtr.cpp
Expand Up @@ -290,15 +290,9 @@ TEST(WTF_CompactRefPtr, Assignment)
{
CompactRefPtr<AlignedRefLogger> ptr(&a);
EXPECT_EQ(&a, ptr.get());
#if COMPILER(CLANG)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wself-move"
#endif
IGNORE_WARNINGS_BEGIN("self-move")
ptr = WTFMove(ptr);
#if COMPILER(CLANG)
#pragma clang diagnostic pop
#endif
IGNORE_WARNINGS_END
EXPECT_EQ(&a, ptr.get());
}
EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
Expand Down
10 changes: 2 additions & 8 deletions Tools/TestWebKitAPI/Tests/WTF/NakedPtr.cpp
Expand Up @@ -188,15 +188,9 @@ TEST(WTF_NakedPtr, Assignment)
{
NakedPtr<RefLogger> ptr(&a);
ASSERT_EQ(&a, ptr.get());
#if COMPILER(CLANG)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wself-move"
#endif
IGNORE_WARNINGS_BEGIN("self-move")
ptr = WTFMove(ptr);
#if COMPILER(CLANG)
#pragma clang diagnostic pop
#endif
IGNORE_WARNINGS_END
ASSERT_EQ(&a, ptr.get());
}
}
Expand Down
10 changes: 2 additions & 8 deletions Tools/TestWebKitAPI/Tests/WTF/PackedRefPtr.cpp
Expand Up @@ -277,15 +277,9 @@ TEST(WTF_PackedRefPtr, Assignment)
{
PackedRefPtr<RefLogger> ptr(&a);
EXPECT_EQ(&a, ptr.get());
#if COMPILER(CLANG)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wself-move"
#endif
IGNORE_WARNINGS_BEGIN("self-move")
ptr = WTFMove(ptr);
#if COMPILER(CLANG)
#pragma clang diagnostic pop
#endif
IGNORE_WARNINGS_END
EXPECT_EQ(&a, ptr.get());
}
EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
Expand Down
10 changes: 2 additions & 8 deletions Tools/TestWebKitAPI/Tests/WTF/RefPtr.cpp
Expand Up @@ -276,15 +276,9 @@ TEST(WTF_RefPtr, Assignment)
{
RefPtr<RefLogger> ptr(&a);
EXPECT_EQ(&a, ptr.get());
#if COMPILER(CLANG)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wself-move"
#endif
IGNORE_WARNINGS_BEGIN("self-move")
ptr = WTFMove(ptr);
#if COMPILER(CLANG)
#pragma clang diagnostic pop
#endif
IGNORE_WARNINGS_END
EXPECT_EQ(&a, ptr.get());
}
EXPECT_STREQ("ref(a) deref(a) ", takeLogStr().c_str());
Expand Down

0 comments on commit 2804afc

Please sign in to comment.