From patchwork Mon Aug 15 18:52:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 532 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp1533946pxh; Mon, 15 Aug 2022 11:53:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR4OtvhFLjL0y2Oxg6MByYWOjSa2Y0HwyHpxpaDmdd/U0fvcIt5LG0sAXK86ft5eiSoxQjeH X-Received: by 2002:a17:907:86ac:b0:731:5180:8aa0 with SMTP id qa44-20020a17090786ac00b0073151808aa0mr11285880ejc.366.1660589615505; Mon, 15 Aug 2022 11:53:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660589615; cv=none; d=google.com; s=arc-20160816; b=QicBj6g7GG2GUoIl8eDTeTH95v5hBEOrWKcc/1gEdlHJeHloX8DvBgEZ/X9tm/QqoF N0xJgLlLQXEynVdECvJfKumiJ2TssHlNhyZ5IgKTyLQ6+dtrzrTS/gPflLV14iQ6avOl 9cDL1Gu1+ngKPhUOCUBxJkbk5EBwJaE3PiZX2igR+01r/Qc/witSyRYSc4DBUxdmwbtd eUF0uVeB7mhaeXM/NuIjusjdBuLYrRToPbmRGneY4gTFd6ueWLkMpaRMBdLBamf9XhIF WZWACebsKRcSe22poD1RVJYiKsTjjmX1qJsMhaCrRPcQg/qJNsJ9KLcfT3vF5g6cy8/P LTqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=fVTAyA7UO2CKP43EQUIicOJxup6QqNkqAU1xeElxj/g=; b=B2MntmxXF57lG8m/mCswovVB48C2TW/0udLMrz4UMzTYzjp4dk2NWxUjTy8VhLf0W1 ky6K3jQ+sRwAub3KcHBMti3JvYahc3OAyf9Ctru717Bj8zO85IrjNibYCoI9WDeZHjSa P1okcm8hOnB80npVM9apHf0GzQBEypP2UFXZg9xtpBuO20VDdfjEdgzZUSPk/dUp459R GWPHt0EgLFvUut1VDVeDIZaxPf+B4vo+meAWiBZUWPUi3IS3cMCBGpVgItHXAwigHQqh CkBj8fgWeMwZs0IfuYSOYPCSKeY19J2MONgBwQyb9vmdA5rLkPj8qE9kdhTGQwCG8o4o FNOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=G7ITxPBd; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id sh38-20020a1709076ea600b0072b9b9c2a74si10137746ejc.251.2022.08.15.11.53.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Aug 2022 11:53:35 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=G7ITxPBd; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2F5B93858404 for ; Mon, 15 Aug 2022 18:53:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F5B93858404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660589614; bh=fVTAyA7UO2CKP43EQUIicOJxup6QqNkqAU1xeElxj/g=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=G7ITxPBdoOSy60zW3Q2E8DWUFzik6bwt1zj/7iW4Yt616sBVLGf+knqjYflDD6XGY gdPs770/5k+h8u9WQxtGpPpjQta3pq3QSK9mc8cHb7IJ5dwupfmvj+48DrDwOjjJwp KzfDmMJzQuzlFmIE1a429wvC+c72NyDGZJvABmnU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id D04A03858404 for ; Mon, 15 Aug 2022 18:52:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D04A03858404 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-167-gS4IDmxpO52tg6CVCxsbFg-1; Mon, 15 Aug 2022 14:52:47 -0400 X-MC-Unique: gS4IDmxpO52tg6CVCxsbFg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A312F1C00ACC for ; Mon, 15 Aug 2022 18:52:47 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.2.16.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E3A92026D4C; Mon, 15 Aug 2022 18:52:47 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [committed] analyzer: better fix for -Wanalyzer-use-of-uninitialized-value [PR106573] Date: Mon, 15 Aug 2022 14:52:45 -0400 Message-Id: <20220815185245.140719-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: David Malcolm via Gcc-patches From: David Malcolm Reply-To: David Malcolm Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1741254416583924676?= X-GMAIL-MSGID: =?utf-8?q?1741254416583924676?= Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-2053-gca123e019bb92f. gcc/analyzer/ChangeLog: PR analyzer/106573 * region-model.cc (region_model::on_call_pre): Use check_call_args when ensuring that we call get_arg_svalue on all args. Remove redundant call from handling for stdio builtins. Signed-off-by: David Malcolm --- gcc/analyzer/region-model.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index 7e7077696f7..a58904c06a8 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -1768,8 +1768,7 @@ region_model::on_call_pre (const gcall *call, region_model_context *ctxt, duplicates if any of the handling below also looks up the svalues, but the deduplication code should deal with that. */ if (ctxt) - for (unsigned arg_idx = 0; arg_idx < cd.num_args (); arg_idx++) - cd.get_arg_svalue (arg_idx); + check_call_args (cd); /* Some of the cases below update the lhs of the call based on the return value, but not all. Provide a default value, which may @@ -1889,7 +1888,6 @@ region_model::on_call_pre (const gcall *call, region_model_context *ctxt, /* These stdio builtins have external effects that are out of scope for the analyzer: we only want to model the effects on the return value. */ - check_call_args (cd); break; case BUILT_IN_VA_START: