From patchwork Fri Dec 11 14:43:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1414926 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=dW598Qn8; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Cstp816vlz9sR4 for ; Sat, 12 Dec 2020 01:43:58 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B59C73972C3B; Fri, 11 Dec 2020 14:43:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by sourceware.org (Postfix) with ESMTPS id 2BBB23972C1E for ; Fri, 11 Dec 2020 14:43:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2BBB23972C1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nathanmsidwell@gmail.com Received: by mail-qt1-x82a.google.com with SMTP id f14so6521619qto.12 for ; Fri, 11 Dec 2020 06:43:53 -0800 (PST) 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=KD9orbABKRwpT5/g2ks4+Y+CgRtktCH+T8eZ3p0hnug=; b=dW598Qn8TQMSHHNJzQjW9TDf3igEM2oHeeChc2AmEtV400qUIgllOwzMqQqDEmDruK T607B/8EZPrwHUnBPG6Z3eVGshVOK+IwodRDD8msIf7Sap3luK0uCkL/nHh1PFfikIz/ 9Vu0fLC8hLWMdvCvmv+8GkhEOXYc/MfytBROF01lNNMZxXJVAGgtZkhc2DGVW7Y4EwgO LZXaZNhHSXFwoEdHWLLVmURanyfw2SHDlOBxufR5SobRAP1+q1UnqBYmZmrZD+3WKbOq aUGoYlKQ2qUtdk4rDdppkQG9Sd8aE3x4UXuXPn7Mbp28i+8Ul4ZY1SCoaFj0XACy7m7x iIrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=KD9orbABKRwpT5/g2ks4+Y+CgRtktCH+T8eZ3p0hnug=; b=ZclcOjoMv5TujsaN21SfjD7zAl/+4hkvhZdip3EEDknjWJe/USQwVMK3SqCRxVE6vR J2yZUg9QBfbrHAwEPKkyhJW6dqZu+np+NmFtGUdfWTOeKH2Xa7ivQAijy6jkEUdYF6Ey tfYxiYEF7oTaUJXyUgPBiyTME3bXRVZifxQLnk92Ty4tdxbQSzx/4rzEmskI38Si5pHH hO3VZL1pwYrYraIiskYiSPAms6caqvzX3OAcMoViL7vCR7aXaIiwuHVmVoghQnkFhh1v 8pRLsxUL4oZY3JZDTHHk3OT4Xh0I5uSVg2HrkZLlhiNfIRTUeuVcJzC63bfV9Ymijx7l b+uQ== X-Gm-Message-State: AOAM533+O38XWfgDJ/rR+F+Y5xkB3vlxfZ4lTwFD7JpOiPpjKay96TKC 0gUG2bl2GCHi+hFVDW6+NOk= X-Google-Smtp-Source: ABdhPJywXPHE0+GgMlwQ4yTa4xfP/PKhCFdWteIW1kYMN9fz+jzt21ESec0P03jgc6u8Xu1QqO6cbQ== X-Received: by 2002:ac8:5911:: with SMTP id 17mr15926468qty.218.1607697832433; Fri, 11 Dec 2020 06:43:52 -0800 (PST) Received: from ?IPv6:2620:10d:c0a8:1102:7d2d:1a8a:7a22:aa55? ([2620:10d:c091:480::1:e048]) by smtp.googlemail.com with ESMTPSA id c14sm6836447qtg.85.2020.12.11.06.43.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Dec 2020 06:43:51 -0800 (PST) To: GCC Patches From: Nathan Sidwell Subject: c++: Module lang hook overriding Message-ID: Date: Fri, 11 Dec 2020 09:43:50 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This installs stub lang hooks for modules and creates the module dump file. gcc/cp/ * cp-lang.c (LANG_HOOKS_PREPROCESS_MAIN_FILE): Override. (LANG_HOOKS_PREPROCESS_OPTIONS): Override. (LANG_HOOKS_PREPROCESS_TOKEN): Override. * cp-objcp-common.c (cp_register_dumps): Add module dump. (cp_handle_option): New. * cp-objcp-common.h (cp_handle_option): Declare. (LANG_HOOKS_HANDLE_OPTION): Override. * cp-tree.h (module_dump_id): Declare. * module.cc (module_dump_id): Define. (module_begin_main_file, handle_module_option) (module_preproces_options): Stubs. pushing to trunk diff --git i/gcc/cp/cp-lang.c w/gcc/cp/cp-lang.c index 9e980bc6de9..5d2aef45a7d 100644 --- i/gcc/cp/cp-lang.c +++ w/gcc/cp/cp-lang.c @@ -77,6 +77,12 @@ static tree cxx_enum_underlying_base_type (const_tree); #define LANG_HOOKS_EH_RUNTIME_TYPE build_eh_type_type #undef LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE #define LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE cxx_enum_underlying_base_type +#undef LANG_HOOKS_PREPROCESS_MAIN_FILE +#define LANG_HOOKS_PREPROCESS_MAIN_FILE module_begin_main_file +#undef LANG_HOOKS_PREPROCESS_OPTIONS +#define LANG_HOOKS_PREPROCESS_OPTIONS module_preprocess_options +#undef LANG_HOOKS_PREPROCESS_TOKEN +#define LANG_HOOKS_PREPROCESS_TOKEN module_token_pre #if CHECKING_P #undef LANG_HOOKS_RUN_LANG_SELFTESTS diff --git i/gcc/cp/cp-objcp-common.c w/gcc/cp/cp-objcp-common.c index 7ff4d3951b6..84f0b5986e1 100644 --- i/gcc/cp/cp-objcp-common.c +++ w/gcc/cp/cp-objcp-common.c @@ -438,6 +438,9 @@ cp_register_dumps (gcc::dump_manager *dumps) class_dump_id = dumps->dump_register (".class", "lang-class", "lang-class", DK_lang, OPTGROUP_NONE, false); + module_dump_id = dumps->dump_register + (".module", "lang-module", "lang-module", DK_lang, OPTGROUP_NONE, false); + raw_dump_id = dumps->dump_register (".raw", "lang-raw", "lang-raw", DK_lang, OPTGROUP_NONE, false); } @@ -551,4 +554,16 @@ cp_common_init_ts (void) c_common_init_ts (); } +/* Handle C++-specficic options here. Punt to c_common otherwise. */ + +bool +cp_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value, + int kind, location_t loc, + const struct cl_option_handlers *handlers) +{ + if (handle_module_option (unsigned (scode), arg, value)) + return true; + return c_common_handle_option (scode, arg, value, kind, loc, handlers); +} + #include "gt-cp-cp-objcp-common.h" diff --git i/gcc/cp/cp-objcp-common.h w/gcc/cp/cp-objcp-common.h index 0936f166d5b..4b5b96fedbc 100644 --- i/gcc/cp/cp-objcp-common.h +++ w/gcc/cp/cp-objcp-common.h @@ -34,6 +34,8 @@ extern tree cp_unit_size_without_reusable_padding (tree); extern tree cp_get_global_decls (); extern tree cp_pushdecl (tree); extern void cp_register_dumps (gcc::dump_manager *); +extern bool cp_handle_option (size_t, const char *, HOST_WIDE_INT, int, + location_t, const struct cl_option_handlers *); extern tree cxx_make_type_hook (tree_code); extern tree cxx_simulate_enum_decl (location_t, const char *, vec); @@ -63,7 +65,7 @@ extern tree cxx_simulate_enum_decl (location_t, const char *, #undef LANG_HOOKS_REGISTER_DUMPS #define LANG_HOOKS_REGISTER_DUMPS cp_register_dumps #undef LANG_HOOKS_HANDLE_OPTION -#define LANG_HOOKS_HANDLE_OPTION c_common_handle_option +#define LANG_HOOKS_HANDLE_OPTION cp_handle_option #undef LANG_HOOKS_HANDLE_FILENAME #define LANG_HOOKS_HANDLE_FILENAME c_common_handle_filename #undef LANG_HOOKS_POST_OPTIONS diff --git i/gcc/cp/cp-tree.h w/gcc/cp/cp-tree.h index 5cd2999ca85..63170fc013d 100644 --- i/gcc/cp/cp-tree.h +++ w/gcc/cp/cp-tree.h @@ -6330,6 +6330,7 @@ extern cp_parameter_declarator *no_parameters; /* Various dump ids. */ extern int class_dump_id; +extern int module_dump_id; extern int raw_dump_id; /* in call.c */ diff --git i/gcc/cp/module.cc w/gcc/cp/module.cc index 11eb6dabb04..02b5af81189 100644 --- i/gcc/cp/module.cc +++ w/gcc/cp/module.cc @@ -65,6 +65,9 @@ along with GCC; see the file COPYING3. If not see #include "intl.h" #include "langhooks.h" +/* Id for dumping module information. */ +int module_dump_id; + /* What the current TU is. */ unsigned module_kind; @@ -189,6 +192,11 @@ preprocessed_module (cpp_reader *) { } +void +module_begin_main_file (cpp_reader *, line_maps *, const line_map_ordinary *) +{ +} + void init_modules (cpp_reader *) { @@ -207,3 +215,14 @@ void fini_modules () { } + +bool +handle_module_option (unsigned, const char *, int) +{ + return false; +} + +void +module_preprocess_options (cpp_reader *) +{ +}