From: Patrick Palka Date: Thu, 28 Jan 2016 01:06:29 +0000 (+0000) Subject: Low-hanging C++-lexer speedup (PR c++/24208) X-Git-Tag: basepoints/gcc-7~1264 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2b4f7b944d1f1a45948b10d4d9ba1169cc187016;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 52fb9d8c3642..6b790e10511d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2016-01-28 Patrick Palka + + 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 PR c/68062 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 33f1df3ca025..d03b0c9596d0 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; }