This is an archive of the discontinued LLVM Phabricator instance.

[Bash-autocompletion] Auto complete cc1 options if -cc1 is specified
ClosedPublic

Authored by yamaguchi on Jun 28 2017, 12:10 PM.

Details

Summary

We don't want to autocomplete flags whose Flags class has NoDriverOption when argv[1] is not -cc1.

Another idea for this implementation is to make --autocomplete a cc1
option and handle it in clang Frontend, by porting --autocomplete
handler from Driver to Frontend, so that we can handle Driver options
and CC1 options in unified manner.

Diff Detail

Repository
rL LLVM

Event Timeline

yamaguchi created this revision.Jun 28 2017, 12:10 PM

Update patch.

teemperor edited edge metadata.Jun 29 2017, 6:48 AM

Two thought from me on this:

  1. I think we want to support completing both -cc1 and normal driver invocation. Most people use the driver, but for example during debugging people use the cc1 version, so both are valid use cases. I just saw we actually have the completion code in the Driver, so what do you think about moving the code to the Frontend part and call it from the Driver/Frontend part?
  1. I think it makes the most sense if we complete cc1 options but return "-Xclang OPTION" when we encounter a cc1 option from the Driver (because it's the least intrusive thing to do and the cc1 options are the ones everyone forgets about :) ).

@teemperor

I think we want to support completing both -cc1 and normal driver invocation. Most people use the driver, but for example during debugging people use the cc1 version, so both are valid use cases. I just saw we actually have the completion code in the Driver, so what do you think about moving the code to the Frontend part and call it from the Driver/Frontend part?

I'm not sure what you refer to by I just saw we actually have the completion code in the Driver. We are already auto completing both cc1 options and driver options, right?
I'm sorry but I don't understand your main point. What am I missing?

I think it makes the most sense if we complete cc1 options but return "-Xclang OPTION" when we encounter a cc1 option from the Driver (because it's the least intrusive thing to do and the cc1 options are the ones everyone forgets about :) ).

What about completing cc1 options only when -cc1 is passed or -Xclang is passed before current input?

I'm not sure what you refer to by I just saw we actually have the completion code in the Driver. We are already auto completing both cc1 options and driver options, right?

Woops, I misread the code there. Never mind!

What about completing cc1 options only when -cc1 is passed or -Xclang is passed before current input?

That actually sounds like the best solution, let's go with that!

yamaguchi updated this revision to Diff 104982.Jul 1 2017, 2:05 AM

Update diff. Autocomplete cc1 flags when argv[1] is -cc1 or previous flag is -Xclang.

yamaguchi updated this revision to Diff 104983.Jul 1 2017, 2:08 AM

Update code comments.

compnerd accepted this revision.Jul 3 2017, 2:31 PM
compnerd edited reviewers, added: compnerd; removed: abdulras.
compnerd added inline comments.
clang/lib/Driver/Driver.cpp
1236 ↗(On Diff #104983)

Typo: ther -> the.

clang/utils/bash-autocomplete.sh
16 ↗(On Diff #104983)

prefix may be a better term?

This revision is now accepted and ready to land.Jul 3 2017, 2:33 PM
yamaguchi updated this revision to Diff 105209.Jul 4 2017, 7:22 PM

Fixed typo.

yamaguchi added inline comments.Jul 4 2017, 7:24 PM
clang/utils/bash-autocomplete.sh
16 ↗(On Diff #104983)

Thanks for reviewing!
$arg has string like -stdlib=,plat, so prefix seems not very appropriate?

This revision was automatically updated to reflect the committed changes.