Ping^2 GCC trunk 4.9: documentation patch on plugins

Submitted by Basile Starynkevitch on March 8, 2014, 10:15 a.m.


Message ID
State New
Headers show

Commit Message

Basile Starynkevitch March 8, 2014, 10:15 a.m.
Hello All,

I am pinging again this documentation patch
(pinged at on febĀµ.17th 2014)

#### gcc/ChangeLog entry

2014-03-08  Basile Starynkevitch  <>

	* doc/plugins.texi (Plugin callbacks): Mention PLUGIN_INCLUDE_FILE.
	Italicize plugin event names in description.  Explain that 
	PLUGIN_PRAGMAS has no sense for lto1. Explain PLUGIN_INCLUDE_FILE. 
	Remind that no GCC functions should be called after PLUGIN_FINISH.
	Explain what pragmas with expansion are.

#### the patch:


Patch hide | download patch | download mbox

Index: gcc/doc/plugins.texi
--- gcc/doc/plugins.texi	(revision 207422)
+++ gcc/doc/plugins.texi	(working copy)
@@ -209,6 +209,10 @@ 
   /* Called when a pass is first instantiated.  */
+/* Called when a file is #include-d or given thru #line directive.
+   Could happen many times.  The event data is the included file path,
+   as a const char* pointer.  */
   PLUGIN_EVENT_FIRST_DYNAMIC    /* Dummy event used for indexing callback
                                    array.  */
@@ -229,15 +233,27 @@ 
 @item @code{void *user_data}: Pointer to plugin-specific data.
 @end itemize
-and PLUGIN_REGISTER_GGC_CACHES pseudo-events the @code{callback} should be
-null, and the @code{user_data} is specific.
+pseudo-events the @code{callback} should be null, and the
+@code{user_data} is specific.
-When the PLUGIN_PRAGMAS event is triggered (with a null
-pointer as data from GCC), plugins may register their own pragmas
-using functions like @code{c_register_pragma} or
+When the @i{PLUGIN_PRAGMAS} event is triggered (with a null pointer as
+data from GCC), plugins may register their own pragmas.  Notice that
+pragmas are not available from @file{lto1}, so plugins used with
+@code{-flto} option to GCC during link-time optimization cannot use
+pragmas and do not even see functions like @code{c_register_pragma} or
+The @i{PLUGIN_INCLUDE_FILE} event, with a @code{const char*} file path as
+GCC data, is triggered for processing of @code{#include} or
+@code{#line} directives.
+The @i{PLUGIN_FINISH} event is the last time that plugins can call GCC
+functions, notably emit diagnostics with @code{warning}, @code{error}
 @node Plugins pass
 @section Interacting with the pass manager
@@ -376,10 +392,13 @@ 
 @end smallexample
-The @code{PLUGIN_PRAGMAS} callback is called during pragmas
-registration. Use the @code{c_register_pragma} or
-@code{c_register_pragma_with_expansion} functions to register custom
+The @i{PLUGIN_PRAGMAS} callback is called once during pragmas
+registration. Use the @code{c_register_pragma},
+@code{c_register_pragma_with_expansion_and_data} functions to register
+custom pragmas and their handlers (which often want to call
+@code{pragma_lex}) from @file{c-family/c-pragma.h}.
 /* Plugin callback called during pragmas registration. Registered with
@@ -397,7 +416,15 @@ 
 It is suggested to pass @code{"GCCPLUGIN"} (or a short name identifying
 your plugin) as the ``space'' argument of your pragma.
+Pragmas registered with @code{c_register_pragma_with_expansion} or
+@code{c_register_pragma_with_expansion_and_data} are allowing
+preprocessor expansions, like e.g.
+#define NUMBER 10
+#pragma GCCPLUGIN foothreshold (NUMBER)
+@end smallexample
 @node Plugins recording
 @section Recording information about pass execution