Files
ladybird/Meta/Lagom/ClangPlugins/LibJSGCPluginAction.h
Matthew Olsson c3ed1a7995 Lagom: Add ClangPlugins
This is a more general and robust replacement of the LibJSGCVerifier.
We want to add more generic static analysis, and this new plugin will
be built in a way that integrates into the rest of the system.
2024-05-13 16:50:54 -06:00

48 lines
1.1 KiB
C++

/*
* Copyright (c) 2024, Matthew Olsson <mattco@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <clang/AST/ASTConsumer.h>
#include <clang/AST/RecursiveASTVisitor.h>
#include <clang/Frontend/FrontendAction.h>
class LibJSGCVisitor : public clang::RecursiveASTVisitor<LibJSGCVisitor> {
public:
explicit LibJSGCVisitor(clang::ASTContext& context)
: m_context(context)
{
}
bool VisitCXXRecordDecl(clang::CXXRecordDecl*);
private:
clang::ASTContext& m_context;
};
class LibJSGCASTConsumer : public clang::ASTConsumer {
public:
virtual void HandleTranslationUnit(clang::ASTContext& context) override;
};
class LibJSGCPluginAction : public clang::PluginASTAction {
public:
virtual bool ParseArgs(clang::CompilerInstance const&, std::vector<std::string> const&) override
{
return true;
}
virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(clang::CompilerInstance&, llvm::StringRef) override
{
return std::make_unique<LibJSGCASTConsumer>();
}
ActionType getActionType() override
{
return AddAfterMainAction;
}
};