[PATCH 1/3] Refactor entry point to -Wmisleading-indentation

Patrick Palka patrick@parcs.ath.cx
Tue Jun 23 19:14:00 GMT 2015


On Mon, Jun 22, 2015 at 2:56 PM, Patrick Palka <patrick@parcs.ath.cx> wrote:
> On Mon, Jun 22, 2015 at 1:29 PM, Jeff Law <law@redhat.com> wrote:
>> On 06/09/2015 11:31 AM, Patrick Palka wrote:
>>>
>>> This patch refactors the entry point of -Wmisleading-indentation from:
>>>
>>>    void
>>>    warn_for_misleading_indentation (location_t guard_loc,
>>>                                     location_t body_loc,
>>>                                     location_t next_stmt_loc,
>>>                                     enum cpp_ttype next_tok_type,
>>>                                     const char *guard_kind);
>>>
>>> to
>>>
>>>    struct token_indent_info
>>>    {
>>>      location_t location;
>>>      cpp_ttype type;
>>>      rid keyword;
>>>    };
>>>
>>>    void
>>>    warn_for_misleading_indentation (const token_indent_info &guard_tinfo,
>>>                                     const token_indent_info &body_tinfo,
>>>                                     const token_indent_info &next_tinfo);
>>>
>>> The purpose of this refactoring is to expose more information to the
>>> -Wmisleading-indentation implementation to allow for more advanced
>>> heuristics and for better coverage.
>>>
>>> (I decided to keep the usage of const references because nobody
>>> seems to mind.  Also I added a new header file, c-indentation.h.)
>>>
>>> gcc/c-family/ChangeLog:
>>>
>>>         * c-indentation.h (struct token_indent_info): Define.
>>>         (get_token_indent_info): Define.
>>>         (warn_for_misleading_information): Declare.
>>>         * c-common.h (warn_for_misleading_information): Remove.
>>>         * c-identation.c (warn_for_misleading_indentation):
>>>         Change declaration to take three token_indent_infos.  Adjust
>>>         accordingly.
>>>         * c-identation.c (should_warn_for_misleading_indentation):
>>>         Likewise.  Bail out early if the body is a compound statement.
>>>         (guard_tinfo_to_string): Define.
>>>
>>> gcc/c/ChangeLog:
>>>
>>>         * c-parser.c (c_parser_if_body): Take token_indent_info
>>>         argument. Call warn_for_misleading_indentation even when the
>>>         body is a semicolon.  Extract token_indent_infos corresponding
>>>         to the guard, body and next tokens.  Adjust call to
>>>         warn_for_misleading_indentation accordingly.
>>>         (c_parser_else_body): Likewise.
>>>         (c_parser_if_statement): Likewise.
>>>         (c_parser_while_statement): Likewise.
>>>         (c_parser_for_statement): Likewise.
>>>
>>> gcc/cp/ChangeLog:
>>>
>>>         * parser.c (cp_parser_selection_statement): Move handling of
>>>         semicolon body to ...
>>>         (cp_parser_implicitly_scoped_statement): .. here.  Call
>>>         warn_for_misleading_indentation even when the body is a
>>>         semicolon.  Extract token_indent_infos corresponding to the
>>>         guard, body and next tokens.  Adjust call to
>>>         warn_for_misleading_indentation accordingly.  Take
>>>         token_indent_info argument.
>>>         (cp_parser_already_scoped_statement): Likewise.
>>>         (cp_parser_selection_statement, cp_parser_iteration_statement):
>>>         Extract a token_indent_info corresponding to the guard token.
>>
>> The only question in my mind is bootstrap & regression testing.  From
>> reading the thread for the earlier version of this patch I got the
>> impression you had bootstrapped and regression tested earlier versions.
>>
>> If you could confirm that you've bootstrapped and regression tested this
>> version it'd be appreciated.  You can do it on the individual patches or the
>> set as a whole.
>
> I think I successfully bootstrapped + regtested this exact version but
> I'm not sure.  I was going to do so again before committing anyway.
> I will fire off a build tonight and confirm the results tomorrow.

Bootstrap + regtest on x86_64-linux-gnu was successful with no new regressions.

>
>>
>> Jeff
>>
>>



More information about the Gcc-patches mailing list