Commit 2b4f7b94 by Patrick Palka

Low-hanging C++-lexer speedup (PR c++/24208)

gcc/cp/ChangeLog:

	PR c++/24208
	* parser.c (LEXER_DEBUGGING_ENABLED_P): New macro.
	(cp_lexer_debugging_p): Use it.
	(cp_lexer_start_debugging): Likewise.
	(cp_lexer_stop_debugging): Likewise.

From-SVN: r232912
parent 069ec73a
2016-01-28 Patrick Palka <ppalka@gcc.gnu.org>
PR c++/24208
* parser.c (LEXER_DEBUGGING_ENABLED_P): New macro.
(cp_lexer_debugging_p): Use it.
(cp_lexer_start_debugging): Likewise.
(cp_lexer_stop_debugging): Likewise.
2016-01-27 Marek Polacek <polacek@redhat.com>
PR c/68062
......
......@@ -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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment