driver: suggest the closest warning for an unknown -W name

Đang mở
#189 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
72/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c
Lĩnh vực
cli, compilers

Hướng nghiên cứu

Read the unknown warning handling in src/driver/main.c around lines 7625 and 7729, then inspect warning enumeration in src/driver/diag.c and edit_distance() in src/sema/sema.c. Start with tests/golden/driver-wp.sh to see the current output. Add close and distant typo cases; done means the three specified misspellings suggest unused-variable, distant names get no suggestion, and the tests pass.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement good first issue

Context. A misspelled warning is reported, but EmbCC does not say what was probably meant:

$ ./embcc -Wunused-vairable -c t.c
embcc: warning: -Wunused-vairable is not a warning EmbCC has, so it turns nothing on (--help-warnings lists them)

It should add did you mean -Wunused-variable?.

Where.

  • src/driver/main.c, around line 7729, where a -W or -Wno- name is looked up. Near line 7625 there is a second message of the same kind, for -Werror=NAME ("names no warning EmbCC has"); give it the suggestion too.
  • src/driver/diag.c, line 1068: diag_warning_count() and diag_warning_name(i) list every warning name.
  • src/sema/sema.c, line 2108: edit_distance(). It is static; share it with the driver instead of copying it. Another good first issue moves the same function, for --target=; whichever lands first, the other reuses it.
  • Tests: tests/golden/driver-wp.sh checks the current message.

Steps.

  1. For an unknown name, find the closest diag_warning_name(i). Suggest it only if it is within max(2, len / 3) edits.
  2. Add the suggestion to the warning, keeping the existing wording, so scripts that grep for it still match.
  3. Add cases to the test: one with a close typo, and one with a name far from every warning.

Done when -Wunused-vairable, -Wno-unused-vairable and -Werror=unused-vairable all suggest unused-variable, a far-off name suggests nothing, and the tests pass.

Before you start: the contributor's guide has the rules. A new test counts only after it has failed against the code before your change, and a commit subject reads area: summary. Questions are welcome in the comments or in Discussions.

Ngôn ngữ chính
C
Star
1
Fork
2
Merge trung bình
20 giờ 55 phút
Pull request đã merge (30 ngày)
73

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của EmbLinkOs/EmbCC

Tất cả issue của EmbLinkOs/EmbCC

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.