Skip to content
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

Bonyuk Peter. Lab 1. Option 3. #12

Closed
wants to merge 69 commits into from

Conversation

PetrBonyuk
Copy link

No description provided.

AveZorgen and others added 30 commits March 4, 2024 22:18
* first commit

* remove redundant foreach

* getting funcname shorter
* first commit

* make action

* made tests more diversed and got rid of using namespace
* Task is ready!

* Update!

* Update for workflow

* Update code

* Update code

* 1. The ASTContext *Context field was removed from the PrintClassVisitor class as unnecessary.
2. The CreateASTConsumer method of the PrintClassLASTAction class now returns make_unique, not new.
3. The help option for the plugin has been added and tested.

* Update code for reload actions (windows-build failed).
This code represents a plugin for Clang that allows outputting information about class members in C++. The program relies on using the Clang tooling and its Abstract Syntax Tree (AST) to analyze and output information about structures and classes in the source code.

The program consists of several components:

- **MemberInfoPrinter:** This class is responsible for printing information about class members, such as fields, methods, and static members. It accesses the Clang AST to retrieve information about each member and prints its name, type, and access specifier.

- **UserTypePrinter:** This class is responsible for printing information about user-defined types, such as structures and classes. It determines the type of each user-defined type and prints the corresponding information.

- **ClassMembersPrinter:** This class is a subclass of `clang::RecursiveASTVisitor` and traverses the AST to find and print information about class members. It uses `MemberInfoPrinter` and `UserTypePrinter` to print information about members and types.

- **ClassMembersConsumer:** This class is an `ASTConsumer` that processes the AST and runs `ClassMembersPrinter` for each detected class or structure.

- **ClassFieldPrinterAction:** This class represents the action of the Clang plugin. It creates an instance of `ClassMembersConsumer` to process the AST and output information about class members.

The program allows analyzing C++ source code and outputting information about class members, their types, and access specifiers.

Example:
```
// CHECK: TestClass (class)
class TestClass {
public:
  int publicInt; // CHECK-NEXT: |_ publicInt (int|public)
  static int publicStaticInt; // CHECK-NEXT: |_ publicStaticInt (int|public|static)
  void publicFunc() {} // CHECK-NEXT: |_ publicFunc (void (void)|public|method)

private:
  int privateInt; // CHECK-NEXT: |_ privateInt (int|private)
  static int privateStaticInt; // CHECK-NEXT: |_ privateStaticInt (int|private|static)
  void privateFunc() {} // CHECK-NEXT: |_ privateFunc (void (void)|private|method)
};
```

In the provided example, a class `TestClass` is shown with various members, including public, private, static variables, and methods. The `CHECK` comments represent the expected output of the program in the format defined in the main code.
* warning plugin

* fixed

* add -i option

* fix clang-tidy

* fix CMakeLists

* fix clang-tidy 2

---------

Co-authored-by: m-ly4 <mikelitch@gmail.com>
Add a plugin printing a warning on deprecated function.
…omplr-tech#18)

* refactoring

* refactoring

* changes

* changes2

* change

* finish

---------

Co-authored-by: root <root@DESKTOP-J78SGPM>
Co-authored-by: m-ly4 <mikelitch@gmail.com>
A plugin that adds the attribute((always_inline)) to functions without condition.
The plugin allows all functions that don't have conditions (for example, if, do...while, etc.), add the always_inline attribute.
Struct fields printer plugin
Implemented identifier renaming (variable name, function name, class name).
Kuznetsov-Artyom and others added 29 commits March 29, 2024 19:12
Implemented a plugin that inserts the instruction_start()/insrtuction_end() functions at the beginning and end of the function, respectively.
Реализован плагин
Добавлены CMakeLists для подтягивания написанных плагинов в тесты
Added a pass for opt that adds loop_start()/loop_end() calls before the start and in the end of loops.
This plugin prints the names of all classes and their fields.
реализовал добавление атрибута inline всем функциям, в которых нет условий (if, for, while, switch).
Inserts instrument_start() and instrument_end() functions into the begining and end of every function in a module.
Example:
void func() {}
will be turned into
void func() { instrument_start(); instrument_end(); }
Plugin that replaces integer multiplication to bit shift, if it is possible
Let's call function that returns void and has no parameters "empty function". Let's say empty function has n blocks. In order to put this empty function in a place it's called, we split called function, create n blocks in calling function and create association list, which associate each created block with it's corresponding block from empty function. Next we copy all instructions from associated blocks. Also we change branch instructions so they send to correct block in called function. And we replace return statements to branch instruction that sends to block with instructions after empty function call.
Реализован плагин и тесты по задаче:
Найти все циклы внутри функции и обернуть их в вызовы loop_start()/loop_end(). Можно использовать Loop Analysis.
Add a plugin inserting instrument_start()/instrument_end() calls.
In this lab, a pass was implemented that does the instrumentation of functions by adding instrument_start() to the beginning and instrument_end() to the end of each function.
A plugin that adds loop_start() and loop_end() functions to the beginning and end of loops.
* Tests

* Tests 2

* Reduce win build
Написал плагин, который добавляет функции loop_start() в начало цикла , и loop_end() в конец цикла
Add a plugin that wraps loops in loop_start/loop_end
Added a plugin that changes integer multiplication by bitwise shift if at least one of the operands is power of two.
A plugin that adds loop_start()/loop_end() calls to all loops inside functions
During the laboratory work, a plugin was implemented that replaces integer multiplications with a bitwise shift in the case when the operands are powers of two.
@PetrBonyuk PetrBonyuk closed this Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.