public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-2956] analyzer: gather builtin/internal fn handling into switch statements
@ 2020-08-31 22:31 David Malcolm
  0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2020-08-31 22:31 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:ee7bfbe5eb70a23bbf3a2cedfdcbd2ea1a20c3f2

commit r11-2956-gee7bfbe5eb70a23bbf3a2cedfdcbd2ea1a20c3f2
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Mon Aug 31 16:20:55 2020 -0400

    analyzer: gather builtin/internal fn handling into switch statements
    
    Clean up this code in preparation for fixing PR analyzer/96798.
    
    gcc/analyzer/ChangeLog:
            * region-model.cc (region_model::on_call_pre): Gather handling of
            builtins and of internal fns into switch statements.  Handle
            "alloca" and BUILT_IN_ALLOCA_WITH_ALIGN.

Diff:
---
 gcc/analyzer/region-model.cc | 48 ++++++++++++++++++++++++++++++++++++--------
 1 file changed, 40 insertions(+), 8 deletions(-)

diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc
index 1f794dacc13..ec5094cac28 100644
--- a/gcc/analyzer/region-model.cc
+++ b/gcc/analyzer/region-model.cc
@@ -652,18 +652,50 @@ region_model::on_call_pre (const gcall *call, region_model_context *ctxt)
 	 in region-model-impl-calls.cc.
 	 Having them split out into separate functions makes it easier
 	 to put breakpoints on the handling of specific functions.  */
-      if (is_named_call_p (callee_fndecl, "malloc", call, 1))
+
+      if (fndecl_built_in_p (callee_fndecl)
+	  && gimple_builtin_call_types_compatible_p (call, callee_fndecl))
+	switch (DECL_UNCHECKED_FUNCTION_CODE (callee_fndecl))
+	  {
+	  default:
+	    break;
+	  case BUILT_IN_ALLOCA:
+	  case BUILT_IN_ALLOCA_WITH_ALIGN:
+	    return impl_call_alloca (cd);
+	  case BUILT_IN_CALLOC:
+	    return impl_call_calloc (cd);
+	  case BUILT_IN_EXPECT:
+	  case BUILT_IN_EXPECT_WITH_PROBABILITY:
+	    return impl_call_builtin_expect (cd);
+	  case BUILT_IN_FREE:
+	    /* Handle in "on_call_post".  */
+	    break;
+	  case BUILT_IN_MALLOC:
+	    return impl_call_malloc (cd);
+	  case BUILT_IN_MEMSET:
+	    impl_call_memset (cd);
+	    return false;
+	    break;
+	  case BUILT_IN_STRLEN:
+	    if (impl_call_strlen (cd))
+	      return false;
+	    break;
+	  }
+      else if (gimple_call_internal_p (call))
+	switch (gimple_call_internal_fn (call))
+	  {
+	  default:
+	    break;
+	  case IFN_BUILTIN_EXPECT:
+	    return impl_call_builtin_expect (cd);
+	  }
+      else if (is_named_call_p (callee_fndecl, "malloc", call, 1))
 	return impl_call_malloc (cd);
       else if (is_named_call_p (callee_fndecl, "calloc", call, 2))
 	return impl_call_calloc (cd);
-      else if (is_named_call_p (callee_fndecl, "__builtin_alloca", call, 1))
+      else if (is_named_call_p (callee_fndecl, "alloca", call, 1))
 	return impl_call_alloca (cd);
-      else if (gimple_call_builtin_p (call, BUILT_IN_EXPECT)
-	       || gimple_call_builtin_p (call, BUILT_IN_EXPECT_WITH_PROBABILITY)
-	       || gimple_call_internal_p (call, IFN_BUILTIN_EXPECT))
-	return impl_call_builtin_expect (cd);
-      else if (is_named_call_p (callee_fndecl, "memset", call, 3)
-	       || gimple_call_builtin_p (call, BUILT_IN_MEMSET))
+      else if (is_named_call_p (callee_fndecl, "memset", call, 3))
 	{
 	  impl_call_memset (cd);
 	  return false;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-31 22:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-31 22:31 [gcc r11-2956] analyzer: gather builtin/internal fn handling into switch statements 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).