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,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 DFE70C433DF for ; Fri, 5 Jun 2020 13:44:14 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (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 B34B8206E6 for ; Fri, 5 Jun 2020 13:44:14 +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="YS9BPeoW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B34B8206E6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-kernel-mentees-bounces@lists.linuxfoundation.org Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 87821203AE; Fri, 5 Jun 2020 13:44:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LYIPHJlANn1x; Fri, 5 Jun 2020 13:44:13 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 9FFE92038B; Fri, 5 Jun 2020 13:44:13 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9C836C0888; Fri, 5 Jun 2020 13:44:13 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4DE26C016E for ; Fri, 5 Jun 2020 13:44:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 4AF4686EA7 for ; Fri, 5 Jun 2020 13:44:12 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wNPm9VdSBHFz for ; Fri, 5 Jun 2020 13:44:11 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by whitealder.osuosl.org (Postfix) with ESMTPS id DE74D876EB for ; Fri, 5 Jun 2020 13:44:11 +0000 (UTC) Received: by mail-pj1-f68.google.com with SMTP id ga6so2608245pjb.1 for ; Fri, 05 Jun 2020 06:44:11 -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 :mime-version:content-transfer-encoding; bh=p7rZYxRe2Sz/SF1CBsPRfrtZT5FjMYD5co3xZ8oxX9U=; b=YS9BPeoWVT3NAE1MgqyMIR06Eh4I3EvYtq3EtdvgFiFrhX1M+EQvKLR/LuqrWCKIDD I0WN9FEvhRp/DYIjxfBjd/OmzAsfK70Vp0GN8vWQg48sgUojc82S6GYDFETcHMgsinAU ZYMrBbX00HUu4YhlOcYvdIUZ2Fin17qNpavgOBRNiiSIXXZxXklsCESSZ28s6RJ6U/NQ /yRe3TSpH6vwUln4PiFYqIIFKovt3Pb0lVNQ3riORaN8pQx13wlBwGGzIoDEvAxDFpwO 0uIMlQKAayxpbP+zCQabK1lwt4ERl2QUZ0L/+RtMY2uMVKEaN4VpPpBwSD64EH53Xxwu oUxg== 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=p7rZYxRe2Sz/SF1CBsPRfrtZT5FjMYD5co3xZ8oxX9U=; b=dBvIjZjidLOW7ob3elgG6nqpJc/KHvfnLDgUauHartoKP9nEzA/n2ys5NisxDxA6Kd sBOVQyWH7ebPgxUnOTD7ky0okzbAUyknlrZW6pntCh3Vbpbr7t3PDjudLyFN8enielk5 oMIQFcnvaVxQIntQwtc2gDx8HHPLCcN7r8XVAGPiuhv6pEY2tM4n7RPddf9iRgcG2ZFO 9HuziAHJQVAGbw0rRNJviGb5iNmM8dULufdVaEuEyjZZQFJxAjCNZaiafxYhWvMmZ9YE N/it2zssSF2TPx5izVIPxMhEH23kY37hv+0/4lP5F0AMdlFKskW5vvi8EaO18Cdcn8cN Eb2g== X-Gm-Message-State: AOAM533i5FVNak+MC5A8XNJCCrLglsaiZ6YlpkAjfFQko1vdN647+f/3 FxAZwwOFG0AISYCG/WQFpYopyjVaSaY= X-Google-Smtp-Source: ABdhPJzGheh4AVb8ZYVfQkI/pD4GHqiLUqaM63mhwwGFci3WdxFylQeOD5JkNhtNfKoSo+ABM+84ng== X-Received: by 2002:a17:902:b18b:: with SMTP id s11mr9672263plr.160.1591364651467; Fri, 05 Jun 2020 06:44:11 -0700 (PDT) Received: from localhost.localdomain ([1.38.221.125]) by smtp.gmail.com with ESMTPSA id w186sm7861353pff.83.2020.06.05.06.44.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 06:44:10 -0700 (PDT) From: Jaskaran Singh To: cocci@systeme.lip6.fr Date: Fri, 5 Jun 2020 19:13:11 +0530 Message-Id: <20200605134322.15307-4-jaskaransingh7654321@gmail.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200605134322.15307-1-jaskaransingh7654321@gmail.com> References: <20200605134322.15307-1-jaskaransingh7654321@gmail.com> MIME-Version: 1.0 Cc: julia.lawall@inria.fr, jaskaransingh7654321@gmail.com, linux-kernel-mentees@lists.linuxfoundation.org Subject: [Linux-kernel-mentees] [PATCH v4 03/14] parsing_c: parsing_hacks: Commentize attributes before qualif/type X-BeenThere: linux-kernel-mentees@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 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 Errors-To: linux-kernel-mentees-bounces@lists.linuxfoundation.org Sender: "Linux-kernel-mentees" For the following example from fs/btrfs/ctree.h in Linux v5.6-rc7: __cold __noreturn static inline void assertfail(const char *expr, const char *file, int line) { pr_err("assertion failed: %s, in %s:%d\n", expr, file, line); BUG(); } __cold and __noreturn are not labeled correctly, leading to C parsing errors. Add a case to commentize attributes before a storage qualifier/type qualifier/type correctly. Signed-off-by: Jaskaran Singh --- parsing_c/parsing_hacks.ml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/parsing_c/parsing_hacks.ml b/parsing_c/parsing_hacks.ml index 74c3ba60..0254fc7f 100644 --- a/parsing_c/parsing_hacks.ml +++ b/parsing_c/parsing_hacks.ml @@ -1952,6 +1952,29 @@ let is_type = function | Tshort _ -> true | _ -> false +let is_type_qualif = function + | Tconst _ + | Tvolatile _ -> true + | _ -> false + +let is_storage_spec = function + | Tstatic _ + | Tregister _ + | Textern _ + | Tauto _ -> true + | _ -> false + +let rec is_idents ?(followed_by=fun _ -> true) ts = + let rec loop l = + match l with + | x::xs when ident x -> loop xs + | x::xs -> followed_by x + | [] -> failwith "unexpected end of token stream" in + match ts with + | x::xs when ident x -> loop xs + | x::xs -> followed_by x + | _ -> false + let is_cparen = function (TCPar _) -> true | _ -> false let is_oparen = function (TOPar _) -> true | _ -> false @@ -2134,6 +2157,16 @@ let lookahead2 ~pass next before = else TCommentCpp (Token_c.CppDirective, i1) + (* tt xx yy *) + | (TIdent (s, i1)::rest, _) + when not_struct_enum before + && is_idents + ~followed_by: + (function x -> + is_type x || is_storage_spec x || is_type_qualif x) rest + && s ==~ regexp_annot -> + TCommentCpp (Token_c.CppMacro, i1) + | (TIdent (s2, i2)::_ , TIdent (s, i1)::seen::_) when not_struct_enum before && is_macro s2 && is_type seen -> -- 2.21.1 _______________________________________________ Linux-kernel-mentees mailing list Linux-kernel-mentees@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees