mirror of
https://github.com/RGBCube/serenity
synced 2025-05-24 14:35:06 +00:00

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.
30 lines
855 B
C++
30 lines
855 B
C++
/*
|
|
* Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <clang/ASTMatchers/ASTMatchFinder.h>
|
|
#include <clang/ASTMatchers/ASTMatchers.h>
|
|
#include <clang/Tooling/Tooling.h>
|
|
#include <unordered_set>
|
|
|
|
class CollectCellsHandler
|
|
: public clang::tooling::SourceFileCallbacks
|
|
, public clang::ast_matchers::MatchFinder::MatchCallback {
|
|
public:
|
|
CollectCellsHandler();
|
|
virtual ~CollectCellsHandler() override = default;
|
|
|
|
virtual bool handleBeginSource(clang::CompilerInstance&) override;
|
|
|
|
virtual void run(clang::ast_matchers::MatchFinder::MatchResult const& result) override;
|
|
|
|
clang::ast_matchers::MatchFinder& finder() { return m_finder; }
|
|
|
|
private:
|
|
std::unordered_set<std::string> m_visited_classes;
|
|
clang::ast_matchers::MatchFinder m_finder;
|
|
};
|