From patchwork Mon May 23 19:28:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 54314 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CF2633858407 for ; Mon, 23 May 2022 19:31:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CF2633858407 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1653334318; bh=QBJWme2uVQ57mSCE+8/SNsUzDSmpYisyuzOOFegHa90=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=stiY/oyGJ2Tv7tqsVpPmU7rQ5i40p7Zz9PpqG8WExhIUAIS+t9rYhHqE2SsuhzoRY Xc+n1RwcUp/4vSuw8wNis1fczBamDtBDOsPuECrhsuzIHYGX2JPh5uys5GqNkWiBOz 9d6b7WYsebrA5xBuAlDTwNyqWz8zKO9gSBvxG6dw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 428AA3858C51 for ; Mon, 23 May 2022 19:28:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 428AA3858C51 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-1-lo-oFK9DMTeUFInojpx9Kw-1; Mon, 23 May 2022 15:28:38 -0400 X-MC-Unique: lo-oFK9DMTeUFInojpx9Kw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7C0E4101AA44 for ; Mon, 23 May 2022 19:28:38 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.2.17.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F5072166B25; Mon, 23 May 2022 19:28:38 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [PATCH 00/10] Add 'final' and 'override' where missing Date: Mon, 23 May 2022 15:28:24 -0400 Message-Id: <20220523192834.3785673-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , X-Patchwork-Original-From: David Malcolm via Gcc-patches From: David Malcolm Reply-To: David Malcolm Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" With C++11 we can add "final" and "override" to the decls of vfuncs in derived classes, which documents to both human and automated readers of the code that a decl is intended to override a vfunc in a base class, and can help catch mistakes where we intended to override a vfunc, but messed up the prototypes. The following patch kit adds "final" and "override" specifiers to the decls of vfunc implementations throughout the source tree. I added "final override" everywhere where this was possible, or just "override" for the places where the overridden vfunc gets further overridden. I also removed "virtual" from such decls, since this isn't required when overriding an existing vfunc, and the "final override" better implies the intent of the code. I temporarily hacked -Werror=suggest-override into the Makefile whilst I was creating the patches, but I skipped the following: (a) gcc/d/dmd/ ...since these sources are copied from an upstream (b) gcc/go/gofrontend/ ...likewise (c) gcc/range.op.cc: as I believe this code is under heavy development (d) target-specific passes other than i386 (for ease of testing); I can do these in a followup, if desired. I didn't attempt to add -Wsuggest-override into our compile flags "properly". No functional changes intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. I split them up into separate patches by topic for ease of review, and for ease of writing the ChangeLog entries. Worth an update to https://gcc.gnu.org/codingconventions.html ? OK for trunk? Dave David Malcolm (10): Add 'final' and 'override' to opt_pass vfunc impls Add 'final' and 'override' on dom_walker vfunc impls expr.cc: use final/override on op_by_pieces_d vfuncs tree-switch-conversion.h: use final/override for cluster vfunc impls d: add 'final' and 'override' to gcc/d/*.cc 'visit' impls ipa: add 'final' and 'override' to call_summary_base vfunc impls value-relation.h: add 'final' and 'override' to relation_oracle vfunc impls i386: add 'final' and 'override' to scalar_chain vfunc impls tree-vect-slp-patterns.cc: add 'final' and 'override' to vect_pattern::build impls Add 'final' and 'override' in various places gcc/adjust-alignment.cc | 2 +- gcc/asan.cc | 19 ++++++--- gcc/auto-inc-dec.cc | 4 +- gcc/auto-profile.cc | 8 ++-- gcc/bb-reorder.cc | 12 +++--- gcc/cfgcleanup.cc | 8 ++-- gcc/cfgexpand.cc | 2 +- gcc/cfgrtl.cc | 6 +-- gcc/cgraphbuild.cc | 13 +++--- gcc/combine-stack-adj.cc | 4 +- gcc/combine.cc | 4 +- gcc/compare-elim.cc | 6 +-- gcc/config/i386/i386-features.cc | 20 ++++----- gcc/config/i386/i386-features.h | 16 +++---- gcc/coroutine-passes.cc | 8 ++-- gcc/cp/cxx-pretty-print.h | 38 ++++++++--------- gcc/cp/module.cc | 4 +- gcc/cprop.cc | 9 ++-- gcc/cse.cc | 18 +++++--- gcc/d/decl.cc | 36 ++++++++-------- gcc/d/expr.cc | 2 +- gcc/d/toir.cc | 64 ++++++++++++++-------------- gcc/d/typeinfo.cc | 34 +++++++-------- gcc/d/types.cc | 30 ++++++------- gcc/dce.cc | 8 ++-- gcc/df-core.cc | 10 ++--- gcc/dse.cc | 14 ++++-- gcc/dwarf2cfi.cc | 7 ++- gcc/early-remat.cc | 4 +- gcc/except.cc | 6 +-- gcc/expr.cc | 14 +++--- gcc/final.cc | 14 ++++-- gcc/function.cc | 10 ++--- gcc/fwprop.cc | 8 ++-- gcc/gcse.cc | 14 ++++-- gcc/genmatch.cc | 22 +++++----- gcc/gensupport.cc | 2 +- gcc/gimple-harden-conditionals.cc | 20 ++++++--- gcc/gimple-if-to-switch.cc | 4 +- gcc/gimple-isel.cc | 4 +- gcc/gimple-laddress.cc | 6 +-- gcc/gimple-loop-interchange.cc | 6 +-- gcc/gimple-loop-jam.cc | 4 +- gcc/gimple-loop-versioning.cc | 7 ++- gcc/gimple-low.cc | 5 ++- gcc/gimple-range-cache.h | 4 +- gcc/gimple-ssa-backprop.cc | 6 +-- gcc/gimple-ssa-evrp.cc | 6 +-- gcc/gimple-ssa-isolate-paths.cc | 9 ++-- gcc/gimple-ssa-nonnull-compare.cc | 4 +- gcc/gimple-ssa-split-paths.cc | 9 ++-- gcc/gimple-ssa-store-merging.cc | 10 ++--- gcc/gimple-ssa-strength-reduction.cc | 6 +-- gcc/gimple-ssa-warn-access.cc | 8 ++-- gcc/gimple-ssa-warn-alloca.cc | 8 ++-- gcc/gimple-ssa-warn-restrict.cc | 4 +- gcc/gimple-warn-recursion.cc | 4 +- gcc/graphite.cc | 9 ++-- gcc/ifcvt.cc | 12 +++--- gcc/init-regs.cc | 4 +- gcc/ipa-comdats.cc | 4 +- gcc/ipa-cp.cc | 10 ++--- gcc/ipa-devirt.cc | 8 ++-- gcc/ipa-fnsummary.cc | 20 ++++++--- gcc/ipa-fnsummary.h | 21 ++++----- gcc/ipa-free-lang-data.cc | 2 +- gcc/ipa-icf-gimple.h | 6 ++- gcc/ipa-icf.cc | 4 +- gcc/ipa-icf.h | 36 +++++++++------- gcc/ipa-inline.cc | 4 +- gcc/ipa-modref.cc | 48 ++++++++++----------- gcc/ipa-param-manipulation.cc | 8 ++-- gcc/ipa-profile.cc | 10 ++--- gcc/ipa-prop.cc | 4 +- gcc/ipa-prop.h | 26 +++++------ gcc/ipa-pure-const.cc | 34 +++++++++------ gcc/ipa-reference.cc | 14 +++--- gcc/ipa-split.cc | 8 ++-- gcc/ipa-sra.cc | 21 +++++---- gcc/ipa-visibility.cc | 6 +-- gcc/ipa.cc | 9 ++-- gcc/ira.cc | 8 ++-- gcc/jump.cc | 5 ++- gcc/loop-init.cc | 18 ++++---- gcc/lower-subreg.cc | 16 ++++--- gcc/lto/lto-dump.cc | 8 ++-- gcc/mode-switching.cc | 6 +-- gcc/modulo-sched.cc | 4 +- gcc/multiple_target.cc | 7 ++- gcc/omp-expand.cc | 14 ++++-- gcc/omp-low.cc | 9 ++-- gcc/omp-oacc-kernels-decompose.cc | 4 +- gcc/omp-oacc-neuter-broadcast.cc | 4 +- gcc/omp-offload.cc | 16 +++---- gcc/omp-simd-clone.cc | 7 ++- gcc/passes.cc | 34 +++++++++------ gcc/postreload-gcse.cc | 7 ++- gcc/postreload.cc | 7 ++- gcc/predict.cc | 13 +++--- gcc/read-md.h | 2 +- gcc/read-rtl-function.cc | 6 +-- gcc/recog.cc | 32 ++++++++------ gcc/ree.cc | 7 ++- gcc/reg-stack.cc | 4 +- gcc/regcprop.cc | 4 +- gcc/reginfo.cc | 2 +- gcc/regrename.cc | 7 ++- gcc/reorg.cc | 8 ++-- gcc/rtl-ssa/blocks.cc | 4 +- gcc/sancov.cc | 10 ++--- gcc/sanopt.cc | 4 +- gcc/sched-rgn.cc | 19 +++++---- gcc/stack-ptr-mod.cc | 2 +- gcc/store-motion.cc | 4 +- gcc/symbol-summary.h | 8 ++-- gcc/symtab-thunks.cc | 8 ++-- gcc/tracer.cc | 4 +- gcc/trans-mem.cc | 34 ++++++++++----- gcc/tree-call-cdce.cc | 4 +- gcc/tree-cfg.cc | 28 ++++++++---- gcc/tree-cfgcleanup.cc | 6 +-- gcc/tree-complex.cc | 14 ++++-- gcc/tree-eh.cc | 23 +++++----- gcc/tree-emutls.cc | 7 ++- gcc/tree-if-conv.cc | 4 +- gcc/tree-into-ssa.cc | 14 +++--- gcc/tree-loop-distribution.cc | 4 +- gcc/tree-nrv.cc | 6 +-- gcc/tree-object-size.cc | 6 +-- gcc/tree-parloops.cc | 11 +++-- gcc/tree-predcom.cc | 8 ++-- gcc/tree-profile.cc | 4 +- gcc/tree-sra.cc | 11 +++-- gcc/tree-ssa-ccp.cc | 21 +++++---- gcc/tree-ssa-copy.cc | 9 ++-- gcc/tree-ssa-dce.cc | 14 +++--- gcc/tree-ssa-dom.cc | 12 +++--- gcc/tree-ssa-dse.cc | 6 +-- gcc/tree-ssa-forwprop.cc | 6 +-- gcc/tree-ssa-ifcombine.cc | 2 +- gcc/tree-ssa-loop-ch.cc | 14 +++--- gcc/tree-ssa-loop-im.cc | 6 +-- gcc/tree-ssa-loop-ivcanon.cc | 10 ++--- gcc/tree-ssa-loop-prefetch.cc | 7 ++- gcc/tree-ssa-loop-split.cc | 4 +- gcc/tree-ssa-loop-unswitch.cc | 4 +- gcc/tree-ssa-loop.cc | 27 ++++++------ gcc/tree-ssa-math-opts.cc | 17 +++++--- gcc/tree-ssa-phiopt.cc | 19 +++++---- gcc/tree-ssa-phiprop.cc | 4 +- gcc/tree-ssa-pre.cc | 4 +- gcc/tree-ssa-propagate.cc | 4 +- gcc/tree-ssa-reassoc.cc | 8 ++-- gcc/tree-ssa-sccvn.cc | 16 +++---- gcc/tree-ssa-sink.cc | 8 ++-- gcc/tree-ssa-strlen.cc | 14 +++--- gcc/tree-ssa-structalias.cc | 13 +++--- gcc/tree-ssa-uncprop.cc | 10 ++--- gcc/tree-ssa-uninit.cc | 13 +++--- gcc/tree-ssanames.cc | 2 +- gcc/tree-stdarg.cc | 8 ++-- gcc/tree-switch-conversion.cc | 15 ++++--- gcc/tree-switch-conversion.h | 32 +++++++------- gcc/tree-tailcall.cc | 16 ++++--- gcc/tree-vect-generic.cc | 11 +++-- gcc/tree-vect-slp-patterns.cc | 12 +++--- gcc/tree-vectorizer.cc | 26 ++++++----- gcc/tree-vrp.cc | 8 ++-- gcc/tsan.cc | 10 ++--- gcc/ubsan.cc | 4 +- gcc/value-relation.h | 38 +++++++++-------- gcc/var-tracking.cc | 4 +- gcc/vtable-verify.cc | 4 +- gcc/web.cc | 4 +- 174 files changed, 1082 insertions(+), 852 deletions(-)