diff options
author | Yuka Takahashi <yukatkh@gmail.com> | 2017-07-08 17:48:59 +0000 |
---|---|---|
committer | Yuka Takahashi <yukatkh@gmail.com> | 2017-07-08 17:48:59 +0000 |
commit | 33cf63b7f26946e6f14878ad9400f4e77f723f0f (patch) | |
tree | 6389be627ed50ecba138b75f4f60d485a981e333 /clang/utils/bash-autocomplete.sh | |
parent | 15309d1ce1fb1c0934a56d35fdaeaf5b5b088b34 (diff) | |
download | bcm5719-llvm-33cf63b7f26946e6f14878ad9400f4e77f723f0f.tar.gz bcm5719-llvm-33cf63b7f26946e6f14878ad9400f4e77f723f0f.zip |
[Bash-autocompletion] Auto complete cc1 options if -cc1 is specified
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.
Differential Revision: https://reviews.llvm.org/D34770
llvm-svn: 307479
Diffstat (limited to 'clang/utils/bash-autocomplete.sh')
-rw-r--r-- | clang/utils/bash-autocomplete.sh | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/clang/utils/bash-autocomplete.sh b/clang/utils/bash-autocomplete.sh index bab193c56b1..1e38bcfcaad 100644 --- a/clang/utils/bash-autocomplete.sh +++ b/clang/utils/bash-autocomplete.sh @@ -27,25 +27,29 @@ _clang() w1="${COMP_WORDS[$cword - 1]}" if [[ $cword > 1 ]]; then w2="${COMP_WORDS[$cword - 2]}" + # Clang want to know if -cc1 or -Xclang option is specified or not, because we don't want to show + # cc1 options otherwise. + if [[ "${COMP_WORDS[1]}" == "-cc1" || "$w1" == "-Xclang" ]]; then + arg="#" fi if [[ "$cur" == -* ]]; then # -foo<tab> - arg="$cur" + arg="$arg$cur" elif [[ "$w1" == -* && "$cur" == '=' ]]; then # -foo=<tab> - arg="$w1=," + arg="$arg$w1=," elif [[ "$cur" == -*= ]]; then # -foo=<tab> - arg="$cur," + arg="$arg$cur," elif [[ "$w1" == -* ]]; then # -foo <tab> or -foo bar<tab> - arg="$w1,$cur" + arg="$arg$w1,$cur" elif [[ "$w2" == -* && "$w1" == '=' ]]; then # -foo=bar<tab> - arg="$w2=,$cur" + arg="$arg$w2=,$cur" elif [[ ${cur: -1} != '=' && ${cur/=} != $cur ]]; then # -foo=bar<tab> - arg="${cur%=*}=,${cur#*=}" + arg="$arg${cur%=*}=,${cur#*=}" fi # expand ~ to $HOME |