aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@gcc.gnu.org>2016-01-28 01:06:29 +0000
committerPatrick Palka <ppalka@gcc.gnu.org>2016-01-28 01:06:29 +0000
commit2b4f7b944d1f1a45948b10d4d9ba1169cc187016 (patch)
tree2e9e77464bd247864b9c633aff892a1fcbfaa05e /gcc
parent069ec73a9bae6d03426a11e9153d1ef01ce2258f (diff)
downloadgcc-2b4f7b944d1f1a45948b10d4d9ba1169cc187016.zip
gcc-2b4f7b944d1f1a45948b10d4d9ba1169cc187016.tar.gz
gcc-2b4f7b944d1f1a45948b10d4d9ba1169cc187016.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/parser.c18
2 files changed, 26 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 52fb9d8..6b790e1 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
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;
}