-
Notifications
You must be signed in to change notification settings - Fork 55
Дудченко Олеся. Лабораторная работа 1. Clang AST. Вариант 1. #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: course-spring-2025
Are you sure you want to change the base?
Дудченко Олеся. Лабораторная работа 1. Clang AST. Вариант 1. #50
Conversation
if (isPureVirtual) { | ||
llvm::outs() << "|pure"; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess, if the method is not virtual it cannot be pure & virtual at the same time either
void sleep() override { /* something */ } | ||
void eat() override { /* something */ } | ||
void work() { /* something */ } | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, consider adding your own test cases as well
return true; | ||
} | ||
|
||
llvm::outs() << record->getName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More duplication code
Use auto &os = llvm::outs()
} // namespace | ||
|
||
static clang::FrontendPluginRegistry::Add<TypeInfoAction> | ||
X("type_info_plugin", "Prints information about user-defined types"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
X("type_info_plugin", "Prints information about user-defined types"); | |
X("type_info_plugin", "Prints information about user-defined types"); | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add test please
struct A {};
struct B {
struct A {};
};
Это плагин для Clang, который анализирует C++ код и выводит информацию о классах и структурах. Вот что он делает:
TypeInfoVisitor
Задача:
Ищет все классы и структуры в коде. Для каждого класса или структуры:
Выводит имя.
Если есть родительские классы, выводит их имена.
Выводит все поля (переменные) с их типами и доступом (public, protected, private).
Выводит все методы (функции) с их возвращаемыми типами, доступом и дополнительной информацией (например, virtual, override, pure).
Игнорирует автоматически созданные методы (например, конструкторы по умолчанию).
TypeInfoConsumer
Управляет обходом кода.
Использует TypeInfoVisitor для анализа всех классов и структур в файле.
TypeInfoAction
Точка входа для плагина.
Создает TypeInfoConsumer и передает ему данные для анализа.