From patchwork Thu Jul 21 00:15:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gab Charette X-Patchwork-Id: 105859 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id EF074B6F75 for ; Thu, 21 Jul 2011 10:15:38 +1000 (EST) Received: (qmail 11919 invoked by alias); 21 Jul 2011 00:15:30 -0000 Received: (qmail 11897 invoked by uid 22791); 21 Jul 2011 00:15:28 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 21 Jul 2011 00:15:09 +0000 Received: from kpbe13.cbf.corp.google.com (kpbe13.cbf.corp.google.com [172.25.105.77]) by smtp-out.google.com with ESMTP id p6L0F6bW019160; Wed, 20 Jul 2011 17:15:06 -0700 Received: from gchare.mtv.corp.google.com (gchare.mtv.corp.google.com [172.18.111.122]) by kpbe13.cbf.corp.google.com with ESMTP id p6L0F4t6032175; Wed, 20 Jul 2011 17:15:05 -0700 Received: by gchare.mtv.corp.google.com (Postfix, from userid 138564) id 249011C128B; Wed, 20 Jul 2011 17:15:04 -0700 (PDT) To: reply@codereview.appspotmail.com, gcc-patches@gcc.gnu.org Subject: [pph] Add filter to prevent streaming out builtin identifiers (issue4802047) Message-Id: <20110721001504.249011C128B@gchare.mtv.corp.google.com> Date: Wed, 20 Jul 2011 17:15:04 -0700 (PDT) From: gchare@google.com (Gabriel Charette) X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Changed to use new cpp_is_builtin inline function. Gab --- This patch is available for review at http://codereview.appspot.com/4802047 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 + + * 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 * 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;