From patchwork Tue May 5 18:21:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 468295 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5E33A1406AA for ; Wed, 6 May 2015 04:08:35 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=m1WClYtp; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=eU2K1T9PcnoLJta8fP6BNrN3JA2FidpqbFWSiQJsp6D+ox3GWjvrq 0LsxJjwlVmRKl5+rWv6Zl0R4dn9B51mlrYV7l6zQSojZK/NLsvdSIVJLYYRkys4G UzmkFCOu9snc4NcRUXJh7vvzXLD2YTSxZVagiZ9SQVAdWi0DbJQxTM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=+oH6SxZlp/k42ZWrcgqlpRR4anA=; b=m1WClYtpgCPl0UqFcEKi Zdw7GeaWcVz5NR1khrAtCrff/c9D0lAWwzIYm3+Vw+vIfd6a7hQOh27xyjnyE3uE r1DfN9T1C0/pCtwbZiRUniaWZV5+ZnKC9z5PEr3JkDj1bq06SZj1uSMvwiP92P7g dW1x4o30RJe32nc0Y0lhs0U= Received: (qmail 110379 invoked by alias); 5 May 2015 18:08:11 -0000 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 Received: (qmail 110317 invoked by uid 89); 5 May 2015 18:08:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 05 May 2015 18:08:09 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t45I873b025792 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 5 May 2015 14:08:07 -0400 Received: from c64.redhat.com (vpn-225-80.phx2.redhat.com [10.3.225.80]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t45I86lb012150; Tue, 5 May 2015 14:08:07 -0400 From: David Malcolm To: Jeff Law Cc: gcc-patches@gcc.gnu.org, David Malcolm Subject: [PATCH 2/4 v2: part 1] Move linemap_assert higher up within the file Date: Tue, 5 May 2015 14:21:12 -0400 Message-Id: <1430850074-40522-2-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1430850074-40522-1-git-send-email-dmalcolm@redhat.com> References: <5547C538.5000606@redhat.com> <1430850074-40522-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes --- libcpp/include/line-map.h | 71 ++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index e1681ea..7001552 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -279,6 +279,42 @@ struct GTY(()) line_map { } GTY((desc ("%1.reason == LC_ENTER_MACRO"))) d; }; +#if defined ENABLE_CHECKING && (GCC_VERSION >= 2007) + +/* Assertion macro to be used in line-map code. */ +#define linemap_assert(EXPR) \ + do { \ + if (! (EXPR)) \ + abort (); \ + } while (0) + +/* Assert that becomes a conditional expression when checking is disabled at + compilation time. Use this for conditions that should not happen but if + they happen, it is better to handle them gracefully rather than crash + randomly later. + Usage: + + if (linemap_assert_fails(EXPR)) handle_error(); */ +#define linemap_assert_fails(EXPR) __extension__ \ + ({linemap_assert (EXPR); false;}) + +/* Assert that MAP encodes locations of tokens that are not part of + the replacement-list of a macro expansion. */ +#define linemap_check_ordinary(LINE_MAP) __extension__ \ + ({linemap_assert (!linemap_macro_expansion_map_p (LINE_MAP)); \ + (LINE_MAP);}) +#else +/* Include EXPR, so that unused variable warnings do not occur. */ +#define linemap_assert(EXPR) ((void)(0 && (EXPR))) +#define linemap_assert_fails(EXPR) (! (EXPR)) +#define linemap_check_ordinary(LINE_MAP) (LINE_MAP) +#endif + +/* Return TRUE if MAP encodes locations coming from a macro + replacement-list at macro expansion point. */ +bool +linemap_macro_expansion_map_p (const struct line_map *); + #define MAP_START_LOCATION(MAP) (MAP)->start_location #define ORDINARY_MAP_FILE_NAME(MAP) \ @@ -568,10 +604,6 @@ extern const struct line_map *linemap_lookup macro expansion, FALSE otherwise. */ bool linemap_tracks_macro_expansion_locs_p (struct line_maps *); -/* Return TRUE if MAP encodes locations coming from a macro - replacement-list at macro expansion point. */ -bool linemap_macro_expansion_map_p (const struct line_map *); - /* Return the name of the macro associated to MACRO_MAP. */ const char* linemap_map_get_macro_name (const struct line_map*); @@ -638,37 +670,6 @@ bool linemap_location_from_macro_expansion_p (const struct line_maps *, #define MAIN_FILE_P(MAP) \ ((linemap_check_ordinary (MAP)->d.ordinary.included_from < 0)) -#if defined ENABLE_CHECKING && (GCC_VERSION >= 2007) - -/* Assertion macro to be used in line-map code. */ -#define linemap_assert(EXPR) \ - do { \ - if (! (EXPR)) \ - abort (); \ - } while (0) - -/* Assert that becomes a conditional expression when checking is disabled at - compilation time. Use this for conditions that should not happen but if - they happen, it is better to handle them gracefully rather than crash - randomly later. - Usage: - - if (linemap_assert_fails(EXPR)) handle_error(); */ -#define linemap_assert_fails(EXPR) __extension__ \ - ({linemap_assert (EXPR); false;}) - -/* Assert that MAP encodes locations of tokens that are not part of - the replacement-list of a macro expansion. */ -#define linemap_check_ordinary(LINE_MAP) __extension__ \ - ({linemap_assert (!linemap_macro_expansion_map_p (LINE_MAP)); \ - (LINE_MAP);}) -#else -/* Include EXPR, so that unused variable warnings do not occur. */ -#define linemap_assert(EXPR) ((void)(0 && (EXPR))) -#define linemap_assert_fails(EXPR) (! (EXPR)) -#define linemap_check_ordinary(LINE_MAP) (LINE_MAP) -#endif - /* Encode and return a source_location from a column number. The source line considered is the last source line used to call linemap_line_start, i.e, the last source line which a location was