From patchwork Wed Aug 28 18:42:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1154726 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-507863-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="xHUIFvsF"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="H8KVHIEc"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46JZPX5ydkz9sBF for ; Thu, 29 Aug 2019 04:43:11 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=oTgoTrBoauLxllAaqgSQw5jACg5oAyt3mFYrtFEf1djh1cnz91 jSc2+LeXFXq850WQ5qsEi1FrgPY+tcPqSLgkpc0VTDiYaEASmqzKyGOA+d5f+/Ez L3oWENjdK5jREvIdPetpNyPmdG/LgWofOPLgwbWybQR3EtiVNPoA5ogOY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=8KE4h9Y9lyhR9DJJPjUsfMZ/Fps=; b=xHUIFvsFyQ10KAvOZXHG iaJumTeGQl8GH/TzGWHmSzg2GlLSH+u0147TQER/oQCDLjZWIRW2WIy6kRoLDkza khrHpjDQLZFz0ZUThvYKC8sfOTatct18DOkCggoGfLV2KM5SLmMn0TZKxetE2MwM ZAXDeJ4hJmR1X9uH1SnBeB8= Received: (qmail 48604 invoked by alias); 28 Aug 2019 18:43:02 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 48589 invoked by uid 89); 28 Aug 2019 18:43:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=mess X-HELO: mail-qt1-f171.google.com Received: from mail-qt1-f171.google.com (HELO mail-qt1-f171.google.com) (209.85.160.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 28 Aug 2019 18:43:00 +0000 Received: by mail-qt1-f171.google.com with SMTP id b11so675950qtp.10 for ; Wed, 28 Aug 2019 11:43:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=lxpPAff/VCkxLUOeil8i72/zrBjqXKFy7MfbqFw9sjU=; b=H8KVHIEcix3iR4vLnhsjOKuVF1bEnnpmYKKeAtfGlrXLlstmtWlpjrVnyG4V39Jc0g 8P3Uj4Rl//+BFcaRkZLAMw84vK2j2XfsE5eWfAV/bY0W82a4EhAXXyU9g9qfvRyOZfXr B4gD3DEWyB5B+SbJM/+U9qnmUDaQ+qpFK1z1BKNhKHgsbXUZYXAErTcef8MCtbacFXLU ZAMoSxMqLud3m4Vdqtk2mH86gVNrw/Zp+jINQHef11reEtQ9VbxAC7p/6jBNpkXoZBHO KwqdDLcB+YFwOrZxnj3ATH9W3lOoV4n+fLnfqF8ER8S6GTOAo/FSGwIe5tagvqZ++745 KD3w== Received: from ?IPv6:2620:10d:c0a3:1407:3af3:91be:230:4c6f? ([2620:10d:c091:500::3:b419]) by smtp.googlemail.com with ESMTPSA id m3sm1632366qki.10.2019.08.28.11.42.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 Aug 2019 11:42:58 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [Preprocessor] small cleanups Message-ID: <045ef743-bc78-1268-5773-49e66d3044b6@acm.org> Date: Wed, 28 Aug 2019 14:42:57 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 From the modules branch, here are some cleanups inspired by changes I've made there. 1) directive handling gets a bool arg, not a 0/1 int 2) documented the enumerators of an enum 3) make a bunch of structure flags 1-bit bools. applying to trunk. nathan 2019-08-28 Nathan Sidwell * directives-only.c (_cpp_preprocess_dir_only): Use false, not zero for _cpp_handle_directive call. * directives.c (_cpp_handle_directive): Indented is bool. * files.c (struct _cpp_file): Make bools 1 bit bitfields. * internal.h (enum include_type): Reformat and comment. (struct cpp_buffer): Make flags 1 bit bitfields. (_cpp_handle_directive): Indented is bool. Index: libcpp/directives-only.c =================================================================== --- libcpp/directives-only.c (revision 274992) +++ libcpp/directives-only.c (working copy) @@ -102,5 +102,5 @@ _cpp_preprocess_dir_only (cpp_reader *pf buffer->line_base -= col - 1; - _cpp_handle_directive (pfile, 0 /* ignore indented */); + _cpp_handle_directive (pfile, false /* ignore indented */); /* Sanitize the line settings. Duplicate #include's can mess Index: libcpp/directives.c =================================================================== --- libcpp/directives.c (revision 274992) +++ libcpp/directives.c (working copy) @@ -407,5 +407,5 @@ directive_diagnostics (cpp_reader *pfile } -/* Check if we have a known directive. INDENTED is nonzero if the +/* Check if we have a known directive. INDENTED is true if the '#' of the directive was indented. This function is in this file to save unnecessarily exporting dtable etc. to lex.c. Returns @@ -413,5 +413,5 @@ directive_diagnostics (cpp_reader *pfile continue processing the line. */ int -_cpp_handle_directive (cpp_reader *pfile, int indented) +_cpp_handle_directive (cpp_reader *pfile, bool indented) { const directive *dir = 0; Index: libcpp/files.c =================================================================== --- libcpp/files.c (revision 274992) +++ libcpp/files.c (working copy) @@ -99,17 +99,17 @@ struct _cpp_file /* If opened with #import or contains #pragma once. */ - bool once_only; + bool once_only : 1; /* If read() failed before. */ - bool dont_read; + bool dont_read : 1; /* If this file is the main file. */ - bool main_file; + bool main_file : 1; /* If BUFFER above contains the true contents of the file. */ - bool buffer_valid; + bool buffer_valid : 1; /* If this file is implicitly preincluded. */ - bool implicit_preinclude; + bool implicit_preinclude : 1; }; Index: libcpp/internal.h =================================================================== --- libcpp/internal.h (revision 274992) +++ libcpp/internal.h (working copy) @@ -114,5 +114,15 @@ extern unsigned char *_cpp_unaligned_all /* #include types. */ -enum include_type {IT_INCLUDE, IT_INCLUDE_NEXT, IT_IMPORT, IT_CMDLINE, IT_DEFAULT}; +enum include_type + { + /* Directive-based including mechanisms. */ + IT_INCLUDE, /* #include */ + IT_INCLUDE_NEXT, /* #include_next */ + IT_IMPORT, /* #import */ + + /* Non-directive including mechanisms. */ + IT_CMDLINE, /* -include */ + IT_DEFAULT, /* forced header */ + }; union utoken @@ -328,5 +338,5 @@ struct cpp_buffer /* True if we need to get the next clean line. */ - bool need_line; + bool need_line : 1; /* True if we have already warned about C++ comments in this file. @@ -334,15 +344,15 @@ struct cpp_buffer or for -Wtraditional, and only once per file (otherwise it would be far too noisy). */ - unsigned int warned_cplusplus_comments : 1; + bool warned_cplusplus_comments : 1; /* True if we don't process trigraphs and escaped newlines. True for preprocessed input, command line directives, and _Pragma buffers. */ - unsigned int from_stage3 : 1; + bool from_stage3 : 1; /* At EOF, a buffer is automatically popped. If RETURN_AT_EOF is true, a CPP_EOF token is then returned. Otherwise, the next token from the enclosing buffer is returned. */ - unsigned int return_at_eof : 1; + bool return_at_eof : 1; /* One for a system header, two for a C system header file that therefore @@ -420,5 +430,5 @@ struct cpp_reader /* This is the node representing the macro being expanded at top-level. The value of this data member is valid iff - in_macro_expansion_p() returns TRUE. */ + cpp_in_macro_expansion_p() returns TRUE. */ cpp_hashnode *top_most_macro_node; @@ -426,5 +436,5 @@ struct cpp_reader really expanding a macro, the function macro_of_context returns the macro being expanded and this flag is set to false. Client - code should use the function in_macro_expansion_p to know if we + code should use the function cpp_in_macro_expansion_p to know if we are either about to expand a macro, or are actually expanding one. */ @@ -712,5 +722,5 @@ extern const char *cpp_named_operator2na /* In directives.c */ extern int _cpp_test_assertion (cpp_reader *, unsigned int *); -extern int _cpp_handle_directive (cpp_reader *, int); +extern int _cpp_handle_directive (cpp_reader *, bool); extern void _cpp_define_builtin (cpp_reader *, const char *); extern char ** _cpp_save_pragma_names (cpp_reader *);