driver: an unknown --opt= goal should name the valid goals

オープン 初心者向け
#190 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
83/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
c
領域
cli

調査の方向性

src/driver/main.cの8580行目付近にある--pass=/--no-pass=の処理と、src/driver/options.def(114~121行目)の--opt=エントリを読む。tests/golden/options-table.shまたはtests/golden/gcc-flags.shにテストを追加し、無効な目標を指定したときに有効な目標が列挙され、使用方法のテキストが省略されることを確認する。メッセージがオプションテーブルから生成され、テストが通れば完了。

索引モデルが issue の本文から書いたものです。

説明

enhancement good first issue

Context. --opt= takes a goal (none, basic, debug, speed, max, size, min-size). A wrong one gets a generic error and the whole usage text:

$ ./embcc --opt=sped -c t.c
embcc: error: unknown argument '--opt=sped'
usage: embcc [-c|-S|-E] SOURCE... [-o FILE] ...

--pass= already does better: embcc: error: --pass=X: no optimizer pass has that name; the passes are a, b and c. --opt= should do the same, and suggest the closest goal.

Where.

  • src/driver/main.c, around line 8580: the --pass= / --no-pass= branch, which is the pattern to follow. The generic unknown argument error comes right after it.
  • src/driver/options.def, lines 114–121: the --opt= goals are entries in the option table, so the list does not need typing in again.
  • Tests: tests/golden/options-table.sh and tests/golden/gcc-flags.sh already check option errors.

Steps.

  1. When opt_typed(argv[i]) starts with --opt= and matched no entry, print embcc: error: --opt=sped: not a goal; the goals are none, basic, debug, speed, max, size and min-size. Build the list from the option table.
  2. Optionally, add did you mean --opt=speed? when one goal is close.
  3. Add a test that checks the message, and that the usage text is no longer printed.

Done when an unknown --opt= names the valid goals, the list comes from options.def (adding a goal there updates the message), 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.

主要言語
C
スター
1
フォーク
2
平均マージ
20時間 55分
マージ済み PR(30日)
73

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

EmbLinkOs/EmbCC のほかの issue

EmbLinkOs/EmbCC の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。