Message ID | 1453783536-23868-1-git-send-email-patrick@parcs.ath.cx |
---|---|
State | New |
Headers | show |
On 01/25/2016 11:45 PM, Patrick Palka wrote: > +/* This needs to be set to TRUE before the lexer-debugging infrastructure can > + be used. The point of this flag is to help the compiler to fold away calls > + to cp_lexer_debugging_p within this source file at compile time, when the > + lexer is not being debugged. */ > + > +#define LEXER_DEBUGGING_ENABLED_P false I wonder about using an existing flag, such as CHECKING_P, but I guess this is OK too. Jason
On Wed, Jan 27, 2016 at 4:33 PM, Jason Merrill <jason@redhat.com> wrote: > On 01/25/2016 11:45 PM, Patrick Palka wrote: >> >> +/* This needs to be set to TRUE before the lexer-debugging infrastructure >> can >> + be used. The point of this flag is to help the compiler to fold away >> calls >> + to cp_lexer_debugging_p within this source file at compile time, when >> the >> + lexer is not being debugged. */ >> + >> +#define LEXER_DEBUGGING_ENABLED_P false > > > I wonder about using an existing flag, such as CHECKING_P, but I guess this > is OK too. The way I look at it is that you need to deliberately add calls to cp_lexer_[start|stop]_debugging in parser.c in order to make use of the lexer debugging stuff anyway, so it's not too invasive to guard this functionality behind a distinct flag that needs to be manually toggled within parser.c. And it is nice to avoid this overhead even when CHECKING_P, to provide a minor speed-up in bootstrap times and stuff.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 33f1df3..d03b0c9 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -706,11 +706,21 @@ cp_lexer_destroy (cp_lexer *lexer) ggc_free (lexer); } +/* This needs to be set to TRUE before the lexer-debugging infrastructure can + be used. The point of this flag is to help the compiler to fold away calls + to cp_lexer_debugging_p within this source file at compile time, when the + lexer is not being debugged. */ + +#define LEXER_DEBUGGING_ENABLED_P false + /* Returns nonzero if debugging information should be output. */ static inline bool cp_lexer_debugging_p (cp_lexer *lexer) { + if (!LEXER_DEBUGGING_ENABLED_P) + return false; + return lexer->debugging_p; } @@ -1296,6 +1306,10 @@ debug (cp_token *ptr) static void cp_lexer_start_debugging (cp_lexer* lexer) { + if (!LEXER_DEBUGGING_ENABLED_P) + fatal_error (input_location, + "LEXER_DEBUGGING_ENABLED_P is not set to true"); + lexer->debugging_p = true; cp_lexer_debug_stream = stderr; } @@ -1305,6 +1319,10 @@ cp_lexer_start_debugging (cp_lexer* lexer) static void cp_lexer_stop_debugging (cp_lexer* lexer) { + if (!LEXER_DEBUGGING_ENABLED_P) + fatal_error (input_location, + "LEXER_DEBUGGING_ENABLED_P is not set to true"); + lexer->debugging_p = false; cp_lexer_debug_stream = NULL; }