Bug 54287

Summary: -finstrument-functions-exclude-function-list ignores class/namespace scope
Product: gcc Reporter: Markus Geimer <mg1102>
Component: middle-endAssignee: Not yet assigned to anyone <unassigned>
Status: UNCONFIRMED ---    
Severity: normal    
Priority: P3    
Version: 4.7.1   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:

Description Markus Geimer 2012-08-16 16:17:43 UTC
In it's current implementation, the symbol matching of -finstrument-functions-exclude-function-list performs a strstr() on the function name only, ignoring the class/namespace scope. That is, with sym=func, both foo::func() and bar::func() with foo and bar being either classes or namespaces will be matched and excluded from instrumentation.

To allow for a more fine-grained specification, the function name used for matching should include the class/namespace scope. This can easily be achived using the patch given below (against the 4.7.1 release). A matching based on regular expressions would be even more convenient, but the proposed change would already help a lot.


diff -Nrup gcc-4.7.1.orig/gcc/gimplify.c gcc-4.7.1/gcc/gimplify.c
--- gcc-4.7.1.orig/gcc/gimplify.c	2012-05-10 17:00:11.000000000 +0200
+++ gcc-4.7.1/gcc/gimplify.c	2012-08-16 18:12:45.793020996 +0200
@@ -8079,7 +8079,7 @@ flag_instrument_functions_exclude_p (tre
       int i;
       char *s;
 
-      name = lang_hooks.decl_printable_name (fndecl, 0);
+      name = lang_hooks.decl_printable_name (fndecl, 1);
       FOR_EACH_VEC_ELT (char_p, vec, i, s)
 	if (strstr (name, s) != NULL)
 	  return true;