Skip to content

Бессонов Егор. Лабораторная работа 1. Clang AST. Вариант 2 #68

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

Open
wants to merge 8 commits into
base: course-spring-2025
Choose a base branch
from

Conversation

nCUXe
Copy link

@nCUXe nCUXe commented Mar 30, 2025

плагин для Clang, который автоматически добавляет атрибут [[maybe_unused]] к неиспользуемым переменным и параметрам

@@ -0,0 +1,28 @@
// RUN: %clang_cc1 -load %llvmshlibdir/first_lab_Bessonov_Egor_FIIT2_ClangAST%pluginext -plugin bessonov_e_unused_var_plugin -fsyntax-only %s 2>&1 | FileCheck %s

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add the test for the variable that already has such attribute

Comment on lines +6 to +8
// CHECK: int foo(int a, int b, \[\[maybe_unused\]\] int c) {
// CHECK: \[\[maybe_unused\]\] double temp = 0.0;
// CHECK: return a + b;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// CHECK: int foo(int a, int b, \[\[maybe_unused\]\] int c) {
// CHECK: \[\[maybe_unused\]\] double temp = 0.0;
// CHECK: return a + b;
// CHECK-LABEL: int foo(int a, int b, \[\[maybe_unused\]\] int c) {
// CHECK-NEXT: \[\[maybe_unused\]\] double temp = 0.0;
// CHECK-NEXT: return a + b;

Also in other tests

void process(int p, int q, int r) {
int local = p + r;
int used = p * r;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test with already present __attribute__((unused))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants