From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.3 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 803C1C2D0DB for ; Tue, 21 Jan 2020 08:05:51 +0000 (UTC) Received: from isis.lip6.fr (isis.lip6.fr [132.227.60.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F289422522 for ; Tue, 21 Jan 2020 08:05:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OW0W8uqb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F289422522 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=cocci-bounces@systeme.lip6.fr Received: from systeme.lip6.fr (systeme.lip6.fr [132.227.104.7]) by isis.lip6.fr (8.15.2/8.15.2) with ESMTP id 00L85UKp028670; Tue, 21 Jan 2020 09:05:30 +0100 (CET) Received: from systeme.lip6.fr (systeme.lip6.fr [127.0.0.1]) by systeme.lip6.fr (Postfix) with ESMTP id 5564977E1; Tue, 21 Jan 2020 09:05:30 +0100 (CET) Received: from isis.lip6.fr (isis.lip6.fr [132.227.60.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by systeme.lip6.fr (Postfix) with ESMTPS id 2817E77DB for ; Tue, 21 Jan 2020 09:05:29 +0100 (CET) Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20:0:0:0:1043]) by isis.lip6.fr (8.15.2/8.15.2) with ESMTP id 00L85NtR016526 for ; Tue, 21 Jan 2020 09:05:23 +0100 (CET) Received: by mail-pj1-x1043.google.com with SMTP id d5so979436pjz.5 for ; Tue, 21 Jan 2020 00:05:23 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=jdQS21ydiqH5O7l4ooG/TbyIarLFdZNwCcRFXTzEwfQ=; b=OW0W8uqbHgyJzGmxlxl+NAeXcoztjqnFUChO+ZQbRKmYbTkaRzUy5fnNEg3Tk35m05 QVHl4qvauktkQ2yyq7j7hQTro9Al23YybZHIo4FDkpvIYCabyWGr4MSYyB/wBwlMJdwB C0KnS5UaI0xTnzLKZnUEBcRjzEw+GmXhOho9cdlHFMfGuKsRmO/TiRTZdc25hOPe962r bLFnKm2BcQBJlbbuu/h3jA0pxb8tcQqnkvXQYRiZIWQdUtkEpP0SLw0FaLjgbisTbyG0 VgLcWdL/ScJe41LDOz5shUal+3M2hmEdivL47eUvJqwdSW/9iVVjZAGopFm8SmNL8waT nRbw== 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:mime-version:content-transfer-encoding; bh=jdQS21ydiqH5O7l4ooG/TbyIarLFdZNwCcRFXTzEwfQ=; b=XW18LwvCBeHrqwz4aTAhYvefa426SiAypkh25y9Hp5hIMPVO+ywYYPjq8HqNfalmkf 1MQKkOPFcyq34QDcniu+Z6U384bNtS70HR3gKX6cgWqMwgzajCAz2HTPFZIXgokUkQHN 06OkJEK3DCdoftccP9vwFmBzhHQlrIuqnGtgslRtEr4tRiCHcaCqfz3LvUlT4QLM50zb mugKQDBU/YbcGjRZrGQvpr6K4BJCy8YwsZBzGIK2md4FAJR67yigjaAZskl405VVcjpq rCFKwa5j9BZGAKBEpgyqfHfdaYV0qRp1fbYvyQiQilEqUo//5GE8grO34Fo/bw2OkSt1 rkag== X-Gm-Message-State: APjAAAVv/+UK5EuLgi+zc7mR0q6uHydqsrJmd/5TfHz2mIDIAT0sAdkv qtECx+/sUxTloniafwKkjLa6RL7qzCo= X-Google-Smtp-Source: APXvYqw1rnvTylQT/5z5sYlNe65+4JnHPFjWaGwKKFtC9s0oUYXeMsG79n8MJwsxS3Dr9oIKelKpSw== X-Received: by 2002:a17:902:6507:: with SMTP id b7mr4142142plk.308.1579593923041; Tue, 21 Jan 2020 00:05:23 -0800 (PST) Received: from localhost.localdomain ([2402:3a80:167e:da7:fcf8:ab67:c0bb:e29]) by smtp.gmail.com with ESMTPSA id k23sm39229604pgg.7.2020.01.21.00.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 00:05:22 -0800 (PST) From: Jaskaran Singh To: cocci@systeme.lip6.fr Date: Tue, 21 Jan 2020 13:34:53 +0530 Message-Id: <20200121080455.24748-2-jaskaransingh7654321@gmail.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200121080455.24748-1-jaskaransingh7654321@gmail.com> References: <20200121080455.24748-1-jaskaransingh7654321@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, Sender e-mail whitelisted, not delayed by milter-greylist-4.4.3 (isis.lip6.fr [132.227.60.2]); Tue, 21 Jan 2020 09:05:30 +0100 (CET) X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.4.3 (isis.lip6.fr [IPv6:2001:660:3302:283c:0:0:0:2]); Tue, 21 Jan 2020 09:05:24 +0100 (CET) X-Scanned-By: MIMEDefang 2.78 on 132.227.60.2 X-Scanned-By: MIMEDefang 2.78 Cc: linux-kernel-mentees@lists.linuxfoundation.org Subject: [Cocci] [PATCH v2 1/3] parsing_c: Handle case of macro before typedef X-BeenThere: cocci@systeme.lip6.fr X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: cocci-bounces@systeme.lip6.fr Errors-To: cocci-bounces@systeme.lip6.fr For the following case: A case in parsing_hacks.ml sometimes mislabels as a typedef ident. If typedef is a known typedef (such as u8 or *_t), then label as a CppMacro. Subsequent cases will then label correctly. Following are results of --parse-c on the Linux Kernel v5.5-rc4: Before: nb good = 18956150, nb passed = 134061 =========> 0.70% passed After: nb good = 18956150, nb passed = 134062 =========> 0.70% passed Signed-off-by: Jaskaran Singh --- parsing_c/parsing_hacks.ml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/parsing_c/parsing_hacks.ml b/parsing_c/parsing_hacks.ml index 8374731b..23d675cf 100644 --- a/parsing_c/parsing_hacks.ml +++ b/parsing_c/parsing_hacks.ml @@ -2184,6 +2184,41 @@ let lookahead2 ~pass next before = && ok_typedef s && is_macro s2 && is_type type_ -> TIdent (s, i1) + + (* xx yy zz : xx is a macro *) + | (TIdent (s, i1)::TIdent (s2, i2)::TIdent(_,_)::_ , _) + when not_struct_enum before + && ok_typedef s2 + && is_known_typdef s2 + -> + TCommentCpp(Token_c.CppMacro, i1) + + (* xx yy zz : xx is a typedef ident *) + | (TIdent (s, i1)::TIdent (s2, i2)::TIdent(_,_)::_ , _) + when not_struct_enum before + && ok_typedef s + -> + msg_typedef s i1 2; LP.add_typedef_root s i1; + TypedefIdent (s, i1) + + (* xx yy * zz : xx is a macro *) + | (TIdent (s, i1)::TIdent (s2, i2)::ptr , _) + when pointer ~followed_by:(function TIdent _ -> true | _ -> false) ptr + && not_struct_enum before + && ok_typedef s2 + && is_known_typdef s2 + -> + TCommentCpp(Token_c.CppMacro, i1) + + (* xx yy * zz : xx is a typedef ident *) + | (TIdent (s, i1)::TIdent (s2, i2)::ptr , _) + when pointer ~followed_by:(function TIdent _ -> true | _ -> false) ptr + && not_struct_enum before + && ok_typedef s + -> + msg_typedef s i1 2; LP.add_typedef_root s i1; + TypedefIdent (s, i1) + (* xx yy *) | (TIdent (s, i1)::TIdent (s2, i2)::rest , _) when not_struct_enum before && ok_typedef s && not (is_macro_paren s2 rest) -- 2.21.1 _______________________________________________ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci