mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-02 07:37:03 +00:00
ClangPlugin: Emit diagnostics for incorrect usage of JS_CELL-like macros
This commit is contained in:
parent
54fffef902
commit
36d032b208
Notes:
sideshowbarker
2024-07-17 10:10:18 +09:00
Author: https://github.com/mattco98
Commit: 36d032b208
Pull-request: https://github.com/SerenityOS/serenity/pull/24422
Issue: https://github.com/SerenityOS/serenity/issues/23880
Issue: https://github.com/SerenityOS/serenity/issues/23881
Issue: https://github.com/SerenityOS/serenity/issues/23900
Reviewed-by: https://github.com/ADKaster ✅
2 changed files with 180 additions and 4 deletions
|
@ -53,20 +53,36 @@ private:
|
|||
|
||||
class LibJSGCVisitor : public clang::RecursiveASTVisitor<LibJSGCVisitor> {
|
||||
public:
|
||||
explicit LibJSGCVisitor(clang::ASTContext& context)
|
||||
explicit LibJSGCVisitor(clang::ASTContext& context, LibJSCellMacroMap const& macro_map)
|
||||
: m_context(context)
|
||||
, m_macro_map(macro_map)
|
||||
{
|
||||
}
|
||||
|
||||
bool VisitCXXRecordDecl(clang::CXXRecordDecl*);
|
||||
|
||||
private:
|
||||
struct CellMacroExpectation {
|
||||
LibJSCellMacro::Type type;
|
||||
std::string base_name;
|
||||
};
|
||||
|
||||
void validate_record_macros(clang::CXXRecordDecl const&);
|
||||
CellMacroExpectation get_record_cell_macro_expectation(clang::CXXRecordDecl const&);
|
||||
|
||||
clang::ASTContext& m_context;
|
||||
LibJSCellMacroMap const& m_macro_map;
|
||||
};
|
||||
|
||||
class LibJSGCASTConsumer : public clang::ASTConsumer {
|
||||
public:
|
||||
explicit LibJSGCASTConsumer(clang::CompilerInstance&);
|
||||
|
||||
private:
|
||||
virtual void HandleTranslationUnit(clang::ASTContext& context) override;
|
||||
|
||||
clang::CompilerInstance& m_compiler;
|
||||
LibJSCellMacroMap m_macro_map;
|
||||
};
|
||||
|
||||
class LibJSGCPluginAction : public clang::PluginASTAction {
|
||||
|
@ -76,9 +92,9 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(clang::CompilerInstance&, llvm::StringRef) override
|
||||
virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(clang::CompilerInstance& compiler, llvm::StringRef) override
|
||||
{
|
||||
return std::make_unique<LibJSGCASTConsumer>();
|
||||
return std::make_unique<LibJSGCASTConsumer>(compiler);
|
||||
}
|
||||
|
||||
ActionType getActionType() override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue