Mercurial > hg > CbC > CbC_gcc
diff gcc/opt-suggestions.c @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 84e7813d76e9 |
children |
line wrap: on
line diff
--- a/gcc/opt-suggestions.c Thu Oct 25 07:37:49 2018 +0900 +++ b/gcc/opt-suggestions.c Thu Feb 13 11:34:05 2020 +0900 @@ -1,6 +1,6 @@ /* Provide option suggestion for --complete option and a misspelled used by a user. - Copyright (C) 2016-2018 Free Software Foundation, Inc. + Copyright (C) 2016-2020 Free Software Foundation, Inc. This file is part of GCC. @@ -23,7 +23,6 @@ #include "coretypes.h" #include "tm.h" #include "opts.h" -#include "params.h" #include "spellcheck.h" #include "opt-suggestions.h" #include "common/common-target.h" @@ -65,32 +64,17 @@ size_t length = strlen (option_prefix); - /* Handle OPTION_PREFIX starting with "-param". */ - const char *prefix = "-param"; - if (length >= strlen (prefix) - && strstr (option_prefix, prefix) == option_prefix) + /* Lazily populate m_option_suggestions. */ + if (!m_option_suggestions) + build_option_suggestions (option_prefix); + gcc_assert (m_option_suggestions); + + for (unsigned i = 0; i < m_option_suggestions->length (); i++) { - /* We support both '-param-xyz=123' and '-param xyz=123' */ - option_prefix += strlen (prefix); - char separator = option_prefix[0]; - option_prefix++; - if (separator == ' ' || separator == '=') - find_param_completions (separator, option_prefix, results); - } - else - { - /* Lazily populate m_option_suggestions. */ - if (!m_option_suggestions) - build_option_suggestions (option_prefix); - gcc_assert (m_option_suggestions); - - for (unsigned i = 0; i < m_option_suggestions->length (); i++) - { - char *candidate = (*m_option_suggestions)[i]; - if (strlen (candidate) >= length - && strstr (candidate, option_prefix) == candidate) - results.safe_push (concat ("-", candidate, NULL)); - } + char *candidate = (*m_option_suggestions)[i]; + if (strlen (candidate) >= length + && strstr (candidate, option_prefix) == candidate) + results.safe_push (concat ("-", candidate, NULL)); } } @@ -134,15 +118,21 @@ with_arg); free (with_arg); } + + /* Add also variant without an option argument. */ + add_misspelling_candidates (m_option_suggestions, option, + opt_text); } else { + bool option_added = false; if (option->flags & CL_TARGET) { vec<const char *> option_values = targetm_common.get_valid_option_values (i, prefix); if (!option_values.is_empty ()) { + option_added = true; for (unsigned j = 0; j < option_values.length (); j++) { char *with_arg = concat (opt_text, option_values[j], @@ -154,7 +144,8 @@ } option_values.release (); } - else + + if (!option_added) add_misspelling_candidates (m_option_suggestions, option, opt_text); } @@ -172,6 +163,10 @@ "-fsanitize=address" rather than to "-Wframe-address" (PR driver/69265). */ { + /* Add also variant without an option argument. */ + add_misspelling_candidates (m_option_suggestions, option, + opt_text); + for (int j = 0; sanitizer_opts[j].name != NULL; ++j) { struct cl_option optb; @@ -202,25 +197,6 @@ } } -/* Find parameter completions for --param format with SEPARATOR. - Again, save the completions into results. */ - -void -option_proposer::find_param_completions (const char separator, - const char *param_prefix, - auto_string_vec &results) -{ - char separator_str[] = {separator, '\0'}; - size_t length = strlen (param_prefix); - for (unsigned i = 0; i < get_num_compiler_params (); ++i) - { - const char *candidate = compiler_params[i].option; - if (strlen (candidate) >= length - && strstr (candidate, param_prefix) == candidate) - results.safe_push (concat ("--param", separator_str, candidate, NULL)); - } -} - #if CHECKING_P namespace selftest { @@ -296,7 +272,6 @@ "-Wassign-intercept", "-Wno-format-security", "-fno-sched-stalled-insns", - "-fbtr-bb-exclusive", "-fno-tree-tail-merge", "-Wlong-long", "-Wno-unused-but-set-parameter", @@ -391,9 +366,9 @@ ASSERT_TRUE (in_completion_p (proposer, "-fipa-icf", "-fipa-icf-functions")); ASSERT_TRUE (in_completion_p (proposer, "-fipa-icf", "-fipa-icf")); ASSERT_TRUE (in_completion_p (proposer, "--param=", - "--param=max-vartrack-reverse-op-size")); + "--param=max-vartrack-reverse-op-size=")); ASSERT_TRUE (in_completion_p (proposer, "--param ", - "--param max-vartrack-reverse-op-size")); + "--param max-vartrack-reverse-op-size=")); ASSERT_FALSE (in_completion_p (proposer, "-fipa-icf", "-fipa")); ASSERT_FALSE (in_completion_p (proposer, "-fipa-icf-functions", "-fipa-icf"));