From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 2C3923858D33 for ; Tue, 22 Aug 2023 01:21:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2C3923858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692667291; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tMltGonohCeYn5thFFsQJwAL55CPut++skL7OpJI0HA=; b=djPfC/Dib1DAz4EqTz4czhYDo4xc3FCSfrr5pchIb5VrKPqJBsxdGqnJuQV7/tIUG9ZSPO uqinMHr09tBcYImAOTN4YRQipG1rBtszjLSrKUj3Vg71Xk5+yQc9CvU5pLb0plnBITjV1U kXPSJaq7LL1f2YzAXxEERHEJQrR9vE8= 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-540-tSx_YgBEP3eqk53Q0OMguQ-1; Mon, 21 Aug 2023 21:21:30 -0400 X-MC-Unique: tSx_YgBEP3eqk53Q0OMguQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DD271833941 for ; Tue, 22 Aug 2023 01:21:29 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.22.16.93]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DAC040D2843; Tue, 22 Aug 2023 01:21:29 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [pushed 1/6] analyzer: convert note_adding_context to annotating_context Date: Mon, 21 Aug 2023 21:21:22 -0400 Message-Id: <20230822012127.2817996-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This is enabling work towards the context being able to inject events into diagnostic paths, rather than just notes after the warning. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r14-3371-ge40a935db29cfd. gcc/analyzer/ChangeLog: * region-model.cc (class check_external_function_for_access_attr::annotating_ctxt): Convert to an annotating_context. * region-model.h (class note_adding_context): Rename to... (class annotating_context): ...this, updating the "warn" method. (note_adding_context::make_note): Replace with... (annotating_context::add_annotations): ...this. --- gcc/analyzer/region-model.cc | 12 ++++++------ gcc/analyzer/region-model.h | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index 494a9cdf149e..5c165ff127f8 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -1641,23 +1641,23 @@ check_external_function_for_access_attr (const gcall *call, if (access->mode == access_write_only || access->mode == access_read_write) { - /* Subclass of decorated_region_model_context that + /* Subclass of annotating_context that adds a note about the attr access to any saved diagnostics. */ - class annotating_ctxt : public note_adding_context + class annotating_ctxt : public annotating_context { public: annotating_ctxt (tree callee_fndecl, const attr_access &access, region_model_context *ctxt) - : note_adding_context (ctxt), + : annotating_context (ctxt), m_callee_fndecl (callee_fndecl), m_access (access) { } - std::unique_ptr make_note () final override + void add_annotations () final override { - return make_unique - (m_callee_fndecl, m_access); + add_note (make_unique + (m_callee_fndecl, m_access)); } private: tree m_callee_fndecl; diff --git a/gcc/analyzer/region-model.h b/gcc/analyzer/region-model.h index 4f09f2e585ac..88772655bc5b 100644 --- a/gcc/analyzer/region-model.h +++ b/gcc/analyzer/region-model.h @@ -922,28 +922,28 @@ protected: region_model_context *m_inner; }; -/* Subclass of region_model_context_decorator that adds a note - when saving diagnostics. */ +/* Subclass of region_model_context_decorator with a hook for adding + notes/events when saving diagnostics. */ -class note_adding_context : public region_model_context_decorator +class annotating_context : public region_model_context_decorator { public: bool warn (std::unique_ptr d) override { if (m_inner->warn (std::move (d))) { - add_note (make_note ()); + add_annotations (); return true; } else return false; } - /* Hook to make the new note. */ - virtual std::unique_ptr make_note () = 0; + /* Hook to add new event(s)/note(s) */ + virtual void add_annotations () = 0; protected: - note_adding_context (region_model_context *inner) + annotating_context (region_model_context *inner) : region_model_context_decorator (inner) { } -- 2.26.3