From 6a6618f5eab6e6a2c7c3fc03f8063cc6b497a0ec Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 11 Nov 2024 15:51:30 +0100 Subject: [PATCH] LibJS: Add RawNonnullGCPtr This is really just a type alias for NonnullGCPtr, but it provides a way to have non-owning non-visited NonnullGCPtr without getting yelled at by the Clang plugin for catching GC errors. --- Libraries/LibJS/Heap/GCPtr.h | 4 ++++ Meta/Lagom/ClangPlugins/LibJSGCPluginAction.cpp | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Libraries/LibJS/Heap/GCPtr.h b/Libraries/LibJS/Heap/GCPtr.h index 2ddef6058da..ebe8753f096 100644 --- a/Libraries/LibJS/Heap/GCPtr.h +++ b/Libraries/LibJS/Heap/GCPtr.h @@ -190,6 +190,10 @@ private: template using RawGCPtr = GCPtr; +// Non-Owning NonnullGCPtr +template +using RawNonnullGCPtr = NonnullGCPtr; + template inline bool operator==(GCPtr const& a, GCPtr const& b) { diff --git a/Meta/Lagom/ClangPlugins/LibJSGCPluginAction.cpp b/Meta/Lagom/ClangPlugins/LibJSGCPluginAction.cpp index 383b814d877..d3db0519e02 100644 --- a/Meta/Lagom/ClangPlugins/LibJSGCPluginAction.cpp +++ b/Meta/Lagom/ClangPlugins/LibJSGCPluginAction.cpp @@ -61,6 +61,7 @@ static std::vector get_all_qualified_types(clang::QualType cons "JS::GCPtr", "JS::NonnullGCPtr", "JS::RawGCPtr", + "JS::RawNonnullGCPtr", "JS::MarkedVector", "JS::Handle", }; @@ -110,7 +111,7 @@ static std::optional validate_qualified_type(clang::QualType con OuterType outer_type; if (template_type_name == "JS::GCPtr" || template_type_name == "JS::NonnullGCPtr") { outer_type = OuterType::GCPtr; - } else if (template_type_name == "JS::RawGCPtr") { + } else if (template_type_name == "JS::RawGCPtr" || template_type_name == "JS::RawNonnullGCPtr") { outer_type = OuterType::RawGCPtr; } else if (template_type_name == "JS::Handle") { outer_type = OuterType::Handle;