From d86c7648fb9643640d8c82be19d49927aa488768 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Thu, 28 Jun 2018 09:11:16 +0200 Subject: Come up with new --completion option. 2018-06-28 Martin Liska * common.opt: Introduce -completion option. * gcc.c (driver_handle_option): Handle it. (driver::main): Print completions if completion is set. * opt-suggestions.c (option_proposer::get_completions): New function. (option_proposer::suggest_completion): Likewise. (option_proposer::find_param_completions): Likewise. (verify_autocompletions): Likewise. (test_completion_valid_options): Likewise. (test_completion_valid_params): Likewise. (in_completion_p): Likewise. (empty_completion_p): Likewise. (test_completion_partial_match): Likewise. (test_completion_garbage): Likewise. (opt_proposer_c_tests): Likewise. * opt-suggestions.h: Declare new functions. * opts.c (common_handle_option): Handle OPT__completion_. * selftest-run-tests.c (selftest::run_tests): Add opt_proposer_c_tests. * selftest.c (assert_str_startswith): New. * selftest.h (assert_str_startswith): Likewise. (opt_proposer_c_tests): New. (ASSERT_STR_STARTSWITH): Likewise. From-SVN: r262210 --- gcc/selftest.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'gcc/selftest.h') diff --git a/gcc/selftest.h b/gcc/selftest.h index a5507cc..d66fb93 100644 --- a/gcc/selftest.h +++ b/gcc/selftest.h @@ -78,6 +78,15 @@ extern void assert_str_contains (const location &loc, const char *val_haystack, const char *val_needle); +/* Implementation detail of ASSERT_STR_STARTSWITH. */ + +extern void assert_str_startswith (const location &loc, + const char *desc_str, + const char *desc_prefix, + const char *val_str, + const char *val_prefix); + + /* A named temporary file for use in selftests. Usable for writing out files, and as the base class for temp_source_file. @@ -217,6 +226,7 @@ extern void unique_ptr_tests_cc_tests (); extern void vec_c_tests (); extern void vec_perm_indices_c_tests (); extern void wide_int_cc_tests (); +extern void opt_proposer_c_tests (); extern int num_passes; @@ -402,6 +412,16 @@ extern int num_passes; (HAYSTACK), (NEEDLE)); \ SELFTEST_END_STMT +/* Evaluate STR and PREFIX and determine if STR starts with PREFIX. + ::selftest::pass if STR does start with PREFIX. + ::selftest::fail if does not, or either is NULL. */ + +#define ASSERT_STR_STARTSWITH(STR, PREFIX) \ + SELFTEST_BEGIN_STMT \ + ::selftest::assert_str_startswith (SELFTEST_LOCATION, #STR, #PREFIX, \ + (STR), (PREFIX)); \ + SELFTEST_END_STMT + /* Evaluate PRED1 (VAL1), calling ::selftest::pass if it is true, ::selftest::fail if it is false. */ -- cgit v1.1