From patchwork Tue Apr 4 21:49:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 9662623 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8C1B7602B9 for ; Tue, 4 Apr 2017 21:50:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E62F28583 for ; Tue, 4 Apr 2017 21:50:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72B5B285A0; Tue, 4 Apr 2017 21:50:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DDFA28583 for ; Tue, 4 Apr 2017 21:50:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754617AbdDDVuQ (ORCPT ); Tue, 4 Apr 2017 17:50:16 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:33732 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753855AbdDDVuO (ORCPT ); Tue, 4 Apr 2017 17:50:14 -0400 Received: by mail-wm0-f68.google.com with SMTP id o81so7985367wmb.0 for ; Tue, 04 Apr 2017 14:50:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ToixUETMinhTEs2j6TupBaTBksaClpxRCy210eg3iLk=; b=Vm9Wy4vvhEiGBPih/OAg/ymolQOy4ubSb5Zg0MBz1caTD9lMnpHC0qcK75xmM79bBb FbI24Uz9cyHoB77Lonh1l+CGSU4dGroBXCWN/PeLsNQc+rRp97ix48CTI0SGEp1rhqA3 PwsylOVHYpa6llPCbTXczwyBcLipUFDacDcvSkF0rHQMVC9mn2TfMCR7c9+sie3sOa8n W9Y/WtM1wC0LEvgoHiWAXz4cT+J329dNvmJbVZLNul4mgtyzcop6C9E3dgMx68vBNJU4 03aXFa8bIr/RPXglVEiGtXhDtQ+gn4buUUHrp8J3zRaQfbEeA8pZZT6epcwL5gMYBrX8 3ztg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ToixUETMinhTEs2j6TupBaTBksaClpxRCy210eg3iLk=; b=ovetuCpIFzisOWytsGxhYyN1LnxYt0PcNqjhHzs5CheKQVuoybmWCV0c/XY/wZN1rs WwdHw+OK8h28H8TOCjEy8IgIPgNfs6SK6uVIVhmrvMsSQAt3jjgiBaEywagUWbWJvbrF G2tmDXVkow5rpGwqRSJ6I8X2I4NKv1dWzMMoDfpVQSdeB82G9UvEqCuQuH3ZXbpFDboG qcVbyu6PjfTZznWDLZ0Rg0YAccs5eT3VpTycSsbOm3ZEypOxmFsncqAWitZOeGuHckFi et/DboI319GS/3MMWfe9p71QaCcub7jfH6Q/6V4g+PeX32LrkXWyJwcyJkZNAD1tHb3+ 1jhQ== X-Gm-Message-State: AFeK/H1S7UWXZyU8c4NL+lNUE+agCzu6svPeFKeHZ9FrESGrB93muCHO A0qgk0r2ZZzNRdnaym8= X-Received: by 10.28.138.140 with SMTP id m134mr16555165wmd.134.1491342612896; Tue, 04 Apr 2017 14:50:12 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:88d:1900:706c:6cb1:d133:7ca3]) by smtp.gmail.com with ESMTPSA id 51sm23827153wrx.38.2017.04.04.14.50.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Apr 2017 14:50:12 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Christopher Li , Luc Van Oostenryck Subject: [PATCH 4/6] let -dD report macro defintions Date: Tue, 4 Apr 2017 23:49:53 +0200 Message-Id: <20170404214955.47926-5-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170404214955.47926-1-luc.vanoostenryck@gmail.com> References: <20170404214955.47926-1-luc.vanoostenryck@gmail.com> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Luc Van Oostenryck --- lib.c | 5 +++++ validation/empty-file | 0 validation/preprocessor/dump-macros-empty.c | 7 +++++++ validation/preprocessor/dump-macros-multi.c | 7 +++++++ validation/preprocessor/dump-macros.c | 18 ++++++++++++++++++ 5 files changed, 37 insertions(+) create mode 100644 validation/empty-file create mode 100644 validation/preprocessor/dump-macros-empty.c create mode 100644 validation/preprocessor/dump-macros-multi.c create mode 100644 validation/preprocessor/dump-macros.c diff --git a/lib.c b/lib.c index 991ead9bd..700681c01 100644 --- a/lib.c +++ b/lib.c @@ -1075,9 +1075,14 @@ void create_builtin_stream(void) static struct symbol_list *sparse_tokenstream(struct token *token) { + int builtin = token && !token->pos.stream; + // Preprocess the stream token = preprocess(token); + if (dump_macro_defs && !builtin) + dump_macro_definitions(); + if (preprocess_only) { while (!eof_token(token)) { int prec = 1; diff --git a/validation/empty-file b/validation/empty-file new file mode 100644 index 000000000..e69de29bb diff --git a/validation/preprocessor/dump-macros-empty.c b/validation/preprocessor/dump-macros-empty.c new file mode 100644 index 000000000..672c66c71 --- /dev/null +++ b/validation/preprocessor/dump-macros-empty.c @@ -0,0 +1,7 @@ +/* + * check-name: dump-macros with empty file + * check-command: sparse -E -dD empty-file + * + * check-output-ignore +check-output-pattern-1-times: #define __CHECKER__ 1 + */ diff --git a/validation/preprocessor/dump-macros-multi.c b/validation/preprocessor/dump-macros-multi.c new file mode 100644 index 000000000..2f6e8d04f --- /dev/null +++ b/validation/preprocessor/dump-macros-multi.c @@ -0,0 +1,7 @@ +/* + * check-name: dump-macros with multiple files + * check-command: sparse -E -dD empty-file $file + * + * check-output-ignore +check-output-pattern-2-times: #define __CHECKER__ 1 + */ diff --git a/validation/preprocessor/dump-macros.c b/validation/preprocessor/dump-macros.c new file mode 100644 index 000000000..79f3de6a2 --- /dev/null +++ b/validation/preprocessor/dump-macros.c @@ -0,0 +1,18 @@ +#define ABC abc +#undef ABC + +#define DEF def +#undef DEF +#define DEF xyz + +#define NYDEF ydef +/* + * check-name: dump-macros + * check-command: sparse -E -dD -DIJK=ijk -UNDEF -UNYDEF $file + * + * check-output-ignore +check-output-pattern-1-times: #define __CHECKER__ 1 +check-output-contains: #define IJK ijk +check-output-contains: #define DEF xyz +check-output-contains: #define NYDEF ydef + */