public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [pushed 1/6] analyzer: convert note_adding_context to annotating_context
@ 2023-08-22  1:21 David Malcolm
  2023-08-22  1:21 ` [pushed 2/6] analyzer: add ability for context to add events to a saved_diagnostic David Malcolm
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: David Malcolm @ 2023-08-22  1:21 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

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<pending_note> make_note () final override
+	    void add_annotations () final override
 	    {
-	      return make_unique<reason_attr_access>
-		(m_callee_fndecl, m_access);
+	      add_note (make_unique<reason_attr_access>
+			(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<pending_diagnostic> 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<pending_note> 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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-22  1:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-22  1:21 [pushed 1/6] analyzer: convert note_adding_context to annotating_context David Malcolm
2023-08-22  1:21 ` [pushed 2/6] analyzer: add ability for context to add events to a saved_diagnostic David Malcolm
2023-08-22  1:21 ` [pushed 3/6] analyzer: handle NULL inner context in region_model_context_decorator David Malcolm
2023-08-22  1:21 ` [pushed 4/6] analyzer: replace -Wanalyzer-unterminated-string with scan_for_null_terminator [PR105899] David Malcolm
2023-08-22  1:21 ` [pushed 5/6] analyzer: add kf_fopen David Malcolm
2023-08-22  1:21 ` [pushed 6/6] analyzer: check format strings for null termination [PR105899] David Malcolm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).