This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PATCH to extend tree stringification operators namespace



The patch below is inspired by an up-coming patch from Nathan Sidwell
to improve error.c.

Actually Nathan's patch crosses my project to improve the tree
stringification machinery found in error.c in various places.

Nathan and I have noticed that the use the overloaded '#' operator to
control tree dump verbosity is somehow limited and makes good tree
dump very hard.  Therefore, he is proposing (in his up-coming patch)
to define various constants that will increase the 'V' parameter
expressiveness, while retaining '#' operator use.  

Nevertheless, the same symptoms that led him to such a proposal are
still there: '#' operator alone is insufficient to control tree dump
verbosity.

Therefore I'm proposing to extend the tree stringification operators
namespace to include '*', '^', '!', '~', '=', '?', '{', '&', '#', '@',
'}', '-' whose meanings are as follow.

'*': look through typedefs.  It has been repeatedly suggested that G++
     should print typedefs as they are and not the original type,
     unless needed.  This operator tells whether we should print the
     original type. Notice that this fonctionnality will be wellcome by
     libstdc++-v3 folks. 

'^': decorate declarations.  Whether function declaration should be
     preceded by 'virtual', 'static'.

'!': hide function return type. This operator tells not to dump a
     function return type.

~': show function exception specification list.

'=': show parameter default value.  Can be used to tell whether we
     want function/template paramter default value in the dump.

'(': show expression in parentheses.

'?': show class type tag ({struct, class, union}).

'{': show decleration's type.

'&': show the scopre in which a function is declared.

'#': old TS operator.  Will be made obsolete.

'@': mark core type with @.  This functionnality is needed by Nathan
     Sidwell.

'}': name entity pedantically.

'-': decl is a non-type template argument.  (Nathan's proposal).


Also I'm writing a documentation for the tree stringification
interface.  Notice that that iinterface can actually be used by any
source browser or automatic documentation generator that manipulates
G++ Internal Representation as defined in cp/ir.texi.

Below is patch to define various constants that maps to the above
proposed operators.  For the time being there are not (yet) used - hence
no breakage.  But up-coming patches will make extensive use of them.
I'm proposing this in order to sync Nathan's and my work on error.c

A final note: in Nathan's patch the constants are prepended by ERRSTR_
to mean (probably) "error string".  As the tree stringification
machinery can be used by any software that needs to turn trees into
strings - not just the error message reporters - I'm proposing to use
TS_ standing for "tree stringification".

Jason, Mark?

-- Gaby
CodeSourcery, LLC


1999-09-20  Gabriel Dos Reis <gdr@codesourcery.com>
        * (cp-tree.h): New tree stringification flags.       


*** cp-tree.h   Sun Sep 19 23:22:02 1999
--- cp-tree.h.new       Sun Sep 19 23:09:01 1999
*************** extern tree current_class_name; /* IDENT
*** 2872,2877 ****
--- 2872,2898 ----
  #define TEMPLATE_TYPE_DECL(NODE) \
    (TEMPLATE_PARM_DECL (TEMPLATE_TYPE_PARM_INDEX (NODE)))
  
+ 
+ /* These constants control tree stringification.  Mainly used in 
     error.c and any program interested in TS.  */
+ #define TS_PLAIN              (0x0000) /* nothing special */
+ #define TS_CHASE_TYPEDEFS     (0x0001) /* '*': look through typedefs */
+ #define TS_DECORATE           (0x0002) /* '^': decorate declarations */
+ #define TS_FUNC_NORETURN      (0x0004) /* '!': hide function return type */
+ #define TS_FUNC_THROW         (0x0008) /* '~': show func exception spec */
+ #define TS_DEFAULT_VALUE      (0x0010) /* '=': show param default value */
+ #define TS_EXPR_PARENS        (0x0020) /* '(': show expression in parens */
+ #define TS_AGGR_TAGS          (0x0040) /* '?': show class type tag */
+ #define TS_DECL_TYPE          (0x0080) /* '{': show decl's type */
+ #define TS_FUNC_SCOPE         (0x0100) /* '&': show function's scope */
+ #define TS_OLD_FLAGS          (0x0200) /* '#': old TS operator. Obsolete */
+ 
+ #define TS_MARK_CODE          (0x0400) /* '@': mark core type with @*/
+ #define TS_PEDANTIC_NAME      (0x0800) /* '}': name entity pedantically */
+ #define TS_NONTYPE_PARM       (0x1000) /* '-': decl is a template parm */
+ 
+ 
+ 
  /* in lex.c  */
  /* Indexed by TREE_CODE, these tables give C-looking names to
     operators represented by TREE_CODES.  For example,




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]