Files
ladybird/Meta/Lagom/Tools/LibJSGCVerifier/src/main.cpp
Matthew Olsson b33b950e45 Lagom: Add a tool to verify correctness of the LibJS GC
This is implemented as a Clang frontend tool, and currently does two
things:
  - Ensure for all fields wrapped in {Nonnull,}GCPtr<T>, T inherits from
    JS::Cell
  - Ensure for all fields not wrapped in {Nonnull,}GCPtr, that the type
    does not inherit from JS::Cell (otherwise it should be wrapped in a
    Ptr class).

In the future, this tool could be extended further. For example, we may
consider validating all implementations of Cell::visit_impl.
2023-03-06 13:05:43 +00:00

28 lines
901 B
C++

/*
* Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "CellsHandler.h"
#include <clang/Tooling/CommonOptionsParser.h>
#include <clang/Tooling/Tooling.h>
#include <llvm/Support/CommandLine.h>
int main(int argc, char const** argv)
{
llvm::cl::OptionCategory s_tool_category("LibJSGCVerifier options");
auto maybe_parser = clang::tooling::CommonOptionsParser::create(argc, argv, s_tool_category);
if (!maybe_parser) {
llvm::errs() << maybe_parser.takeError();
return 1;
}
auto& parser = maybe_parser.get();
clang::tooling::ClangTool tool(parser.getCompilations(), parser.getSourcePathList());
CollectCellsHandler collect_handler;
auto collect_action = clang::tooling::newFrontendActionFactory(&collect_handler.finder(), &collect_handler);
return tool.run(collect_action.get());
}