From patchwork Sat May 23 10:46:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWFudWVsIEzDs3Blei1JYsOhw7Fleg==?= X-Patchwork-Id: 475897 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 F3A0F14029D for ; Sat, 23 May 2015 20:47:43 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=dD3eeNf1; 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 :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=q9Eo5s3wKJ8d7k6XIZWCmlb/Dtuiu3LnFNoQPdzIGFbcA+ oN101AWlvtiPbIWIeiE833jU0U7J5OdxbXtS0uHNIWl7epf+9RajxhwEPh3togu7 7U9TnUaNHJP0aHaAdF7zbItB1Dq8jxKOqvJ/bk+pu7ey7k+pzsxX0k6YxHPTw= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=BYyVDpDZOvhvrbtkexnTrJguHZQ=; b=dD3eeNf1hA29zFmQ6ozt r47IC9IQr01oeOhllb8YSTNuwXdn6vTtQHdh9Lvy7ZT1LbMO7cWmo2KHdkOCz6kV RvHo4GuWQOmUuxXQkHWIgXVMgSX+UduZ8U0cR+zHT+95VHvOrGIkcTqVJQTlPhCz FuEXzj49wNYetDTtUdS798k= Received: (qmail 74794 invoked by alias); 23 May 2015 10:47:36 -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 74776 invoked by uid 89); 23 May 2015 10:47:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.3 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f171.google.com Received: from mail-wi0-f171.google.com (HELO mail-wi0-f171.google.com) (209.85.212.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sat, 23 May 2015 10:47:24 +0000 Received: by wicmc15 with SMTP id mc15so8960848wic.1 for ; Sat, 23 May 2015 03:47:21 -0700 (PDT) X-Received: by 10.194.192.166 with SMTP id hh6mr22364562wjc.127.1432378041869; Sat, 23 May 2015 03:47:21 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.180.133 with HTTP; Sat, 23 May 2015 03:46:41 -0700 (PDT) From: =?UTF-8?B?TWFudWVsIEzDs3Blei1JYsOhw7Fleg==?= Date: Sat, 23 May 2015 12:46:41 +0200 Message-ID: Subject: add names for constants in line-map.c To: Gcc Patch List , Dodji Seketeli This patch adds descriptive names to various constants in line-map.c. There were some differences between the constants used a various places, but my understanding is that these differences are arbitrary and it is easier to understand the code if they are harmonized. Bootstrapped and regression tested on x86-linux-gnu. OK? libcpp/ChangeLog: 2015-05-23 Manuel López-Ibáñez * line-map.c (LINE_MAP_MAX_COLUMN_NUMBER LINE_MAP_MAX_LOCATION_WITH_COLS,LINE_MAP_MAX_SOURCE_LOCATION): New constants. (linemap_line_start): Use them. (linemap_position_for_column): Use them. Index: libcpp/line-map.c =================================================================== --- libcpp/line-map.c (revision 223596) +++ libcpp/line-map.c (working copy) @@ -24,10 +24,22 @@ along with this program; see the file CO #include "line-map.h" #include "cpplib.h" #include "internal.h" #include "hashtab.h" +/* Do not track column numbers higher than this one. As a result, the + range of column_bits is [7, 18] (or 0 if column numbers are + disabled). */ +const unsigned int LINE_MAP_MAX_COLUMN_NUMBER = (1U << 17); + +/* Do not track column numbers if locations get higher than this. */ +const source_location LINE_MAP_MAX_LOCATION_WITH_COLS = 0x60000000; + +/* Highest possible source location encoded within an ordinary or + macro map. */ +const source_location LINE_MAP_MAX_SOURCE_LOCATION = 0x70000000; + static void trace_include (const struct line_maps *, const line_map_ordinary *); static const line_map_ordinary * linemap_ordinary_map_lookup (struct line_maps *, source_location); static const line_map_macro* linemap_macro_map_lookup (struct line_maps *, source_location); @@ -542,26 +554,27 @@ linemap_line_start (struct line_maps *se || (line_delta > 10 && line_delta * ORDINARY_MAP_NUMBER_OF_COLUMN_BITS (map) > 1000) || (max_column_hint >= (1U << ORDINARY_MAP_NUMBER_OF_COLUMN_BITS (map))) || (max_column_hint <= 80 && ORDINARY_MAP_NUMBER_OF_COLUMN_BITS (map) >= 10) - || (highest > 0x60000000 - && (set->max_column_hint || highest > 0x70000000))) + || (highest > LINE_MAP_MAX_LOCATION_WITH_COLS + && (set->max_column_hint || highest >= LINE_MAP_MAX_SOURCE_LOCATION))) add_map = true; else max_column_hint = set->max_column_hint; if (add_map) { int column_bits; - if (max_column_hint > 100000 || highest > 0x60000000) + if (max_column_hint > LINE_MAP_MAX_COLUMN_NUMBER + || highest > LINE_MAP_MAX_LOCATION_WITH_COLS) { /* If the column number is ridiculous or we've allocated a huge number of source_locations, give up on column numbers. */ max_column_hint = 0; - if (highest > 0x70000000) - return 0; column_bits = 0; + if (highest > LINE_MAP_MAX_SOURCE_LOCATION) + return 0; } else { column_bits = 7; while (max_column_hint >= (1U << column_bits)) @@ -613,11 +626,12 @@ linemap_position_for_column (struct line linemap_assert (!linemap_macro_expansion_map_p (LINEMAPS_LAST_ORDINARY_MAP (set))); if (to_column >= set->max_column_hint) { - if (r >= 0xC000000 || to_column > 100000) + if (r > LINE_MAP_MAX_LOCATION_WITH_COLS + || to_column > LINE_MAP_MAX_COLUMN_NUMBER) { /* Running low on source_locations - disable column numbers. */ return r; } else