mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibJSGCVerifier: Fix dangling-reference errors
When building, clang would throw errors about dangling references. Extracting `template_args` to a variable before the loop and indexing into that seems to fix the errors.
This commit is contained in:
parent
bf722d49b0
commit
7743dcf4a9
Notes:
sideshowbarker
2024-07-17 06:29:49 +09:00
Author: https://github.com/0x4261756D 🔰 Commit: https://github.com/SerenityOS/serenity/commit/7743dcf4a9 Pull-request: https://github.com/SerenityOS/serenity/pull/23828 Issue: https://github.com/SerenityOS/serenity/issues/23790 Reviewed-by: https://github.com/mattco98 ✅
1 changed files with 6 additions and 4 deletions
|
@ -90,8 +90,9 @@ std::vector<clang::QualType> get_all_qualified_types(clang::QualType const& type
|
|||
if (specialization_name == "JS::GCPtr" || specialization_name == "JS::NonnullGCPtr") {
|
||||
qualified_types.push_back(type);
|
||||
} else {
|
||||
for (size_t i = 0; i < template_specialization->template_arguments().size(); i++) {
|
||||
auto const& template_arg = template_specialization->template_arguments()[i];
|
||||
auto const template_arguments = template_specialization->template_arguments();
|
||||
for (size_t i = 0; i < template_arguments.size(); i++) {
|
||||
auto const& template_arg = template_arguments[i];
|
||||
if (template_arg.getKind() == clang::TemplateArgument::Type) {
|
||||
auto template_qualified_types = get_all_qualified_types(template_arg.getAsType());
|
||||
std::move(template_qualified_types.begin(), template_qualified_types.end(), std::back_inserter(qualified_types));
|
||||
|
@ -143,10 +144,11 @@ FieldValidationResult validate_field(clang::FieldDecl const* field_decl)
|
|||
if (template_type_name != "GCPtr" && template_type_name != "NonnullGCPtr")
|
||||
return result;
|
||||
|
||||
if (specialization->template_arguments().size() != 1)
|
||||
auto const template_args = specialization->template_arguments();
|
||||
if (template_args.size() != 1)
|
||||
return result; // Not really valid, but will produce a compilation error anyway
|
||||
|
||||
auto const& type_arg = specialization->template_arguments()[0];
|
||||
auto const& type_arg = template_args[0];
|
||||
auto const* record_type = type_arg.getAsType()->getAs<clang::RecordType>();
|
||||
if (!record_type)
|
||||
return result;
|
||||
|
|
Loading…
Add table
Reference in a new issue