LibJSGCVerifier: Detect missing JS_CELL() calls

This commit is contained in:
Matthew Olsson 2024-04-08 18:17:32 +00:00 committed by Andreas Kling
parent 5023e5fda3
commit abb4b6d117
2 changed files with 16 additions and 0 deletions

View file

@ -308,6 +308,20 @@ void CollectCellsHandler::check_cells(clang::ast_matchers::MatchFinder::MatchRes
emit_record_json_data(*record);
bool has_base = false;
for (auto const& decl : record->decls()) {
if (auto* alias_decl = llvm::dyn_cast<clang::TypeAliasDecl>(decl); alias_decl && alias_decl->getQualifiedNameAsString().ends_with("::Base")) {
has_base = true;
break;
}
}
if (!has_base) {
auto diag_id = diag_engine.getCustomDiagID(clang::DiagnosticsEngine::Warning, "JS::Cell-inheriting class %0 is missing a JS_CELL() call in its header file");
auto builder = diag_engine.Report(record->getLocation(), diag_id);
builder << record->getName();
}
clang::DeclarationName const name = &result.Context->Idents.get("visit_edges");
auto const* visit_edges_method = record->lookup(name).find_first<clang::CXXMethodDecl>();
if (!visit_edges_method && !fields_that_need_visiting.empty()) {

View file

@ -15,6 +15,8 @@ namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/images.html#img-req-data
class DecodedImageData : public JS::Cell {
JS_CELL(DecodedImageData, JS::Cell);
public:
virtual ~DecodedImageData();