Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4582)

Issue 4802047: [pph] Add filter to prevent streaming out builtin identifiers (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 9 months ago by Gabriel Charette
Modified:
12 years, 9 months ago
CC:
gcc-patches_gcc.gnu.org
Visibility:
Public.

Patch Set 1 #

Patch Set 2 : [pph] Add filter to prevent streaming out builtin identifiers #

Unified diffs Side-by-side diffs Delta from patch set Stats (+23 lines, -3 lines) Patch
M libcpp/ChangeLog.pph View 1 1 chunk +6 lines, -0 lines 0 comments Download
M libcpp/include/cpplib.h View 1 1 chunk +9 lines, -0 lines 0 comments Download
M libcpp/symtab.c View 1 2 chunks +8 lines, -3 lines 0 comments Download

Messages

Total messages: 3
Gabriel Charette
Added a filter to prevent streaming out builtin identifiers. This filter is copied from symtab.c:497 ...
12 years, 9 months ago (2011-07-20 20:54:31 UTC) #1
Diego Novillo
On 2011/07/20 20:54:31, Gabriel Charette wrote: > Should I instead add a new macro IS_BUILTIN ...
12 years, 9 months ago (2011-07-20 21:09:05 UTC) #2
Gabriel Charette
12 years, 9 months ago (2011-07-21 00:15:07 UTC) #3
Changed to use new cpp_is_builtin inline function.

Gab

diff --git a/libcpp/ChangeLog.pph b/libcpp/ChangeLog.pph
index de21994..36369a5 100644
--- a/libcpp/ChangeLog.pph
+++ b/libcpp/ChangeLog.pph
@@ -1,3 +1,9 @@
+2011-07-20  Gabriel Charette  <gchare@google.com>
+
+	* include/cpplib.h (cpp_is_builtin): New.
+	* symtab.c (lt_query_macro): Use cpp_is_builtin.
+	* symtab.c (cpp_lt_capture): Filter out builtin identifiers.
+
 2011-06-08  Lawrence Crowl  <crowl@google.com>
 
 	* symtab.c (lt_query_macro): Querying "user builtin" macros should not
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index 70d72a4..74e076c 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -667,6 +667,15 @@ struct GTY(()) cpp_hashnode {
   union _cpp_hashnode_value GTY ((desc ("CPP_HASHNODE_VALUE_IDX (%1)"))) value;
 };
 
+
+/* Return true if CHN has a builtin type.  */
+
+static inline bool
+cpp_is_builtin (cpp_hashnode *chn)
+{
+  return (chn->flags & NODE_BUILTIN) && chn->value.builtin < BT_FIRST_USER;
+}
+
 /* Call this first to get a handle to pass to other functions.
 
    If you want cpplib to manage its own hashtable, pass in a NULL
diff --git a/libcpp/symtab.c b/libcpp/symtab.c
index 48c5dcc..aad7277 100644
--- a/libcpp/symtab.c
+++ b/libcpp/symtab.c
@@ -494,8 +494,7 @@ static const char *
 lt_query_macro (cpp_reader *reader, cpp_hashnode *cpp_node)
 {
   const char *definition = NULL;
-  if ((cpp_node->flags & NODE_BUILTIN)
-      && cpp_node->value.builtin < BT_FIRST_USER)
+  if (cpp_is_builtin (cpp_node))
     {
       const char *str = (const char *)cpp_node->ident.str;
       if (   strcmp(str, "__DATE__") == 0
@@ -589,9 +588,15 @@ cpp_lt_capture (cpp_reader *reader)
       hashnode node = table_entry->node;
       if (node)
         {
-          cpp_ident_use *summary_entry = used.entries + summary_index++;
+          cpp_ident_use *summary_entry;
           cpp_hashnode *cpp_node = CPP_HASHNODE (node);
 
+          /* Filter out builtin identifiers.  */
+          if (cpp_is_builtin (cpp_node))
+            continue;
+
+          summary_entry = used.entries + summary_index++;
+
           summary_entry->used_by_directive = cpp_node->used_by_directive;
           summary_entry->expanded_to_text = cpp_node->expanded_to_text;
           summary_entry->ident_len = node->len;

--
This patch is available for review at http://codereview.appspot.com/4802047
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b