]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Low-hanging C++-lexer speedup (PR c++/24208)
authorPatrick Palka <ppalka@gcc.gnu.org>
Thu, 28 Jan 2016 01:06:29 +0000 (01:06 +0000)
committerPatrick Palka <ppalka@gcc.gnu.org>
Thu, 28 Jan 2016 01:06:29 +0000 (01:06 +0000)
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

gcc/cp/ChangeLog
gcc/cp/parser.c

index 52fb9d8c36428830a2f093f0103452d03da1e714..6b790e10511d5e28ee106e5200310d1d7d31f5d5 100644 (file)
@@ -1,3 +1,11 @@
+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
index 33f1df3ca025869788aae0a3be746325b654fde4..d03b0c9596d09dae0b273f2e76bbad1bb6fd8873 100644 (file)
@@ -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;
 }