From patchwork Fri Dec 13 18:11:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 1209350 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-515936-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="sH+Pb3Uq"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="QNqqWH9R"; dkim-atps=neutral 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 47ZJlX3f2Bz9sPh for ; Sat, 14 Dec 2019 05:16:40 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=v5TcpyJDMbaK6Mzu7Pw4lOs+7S+pK96ONiesWxcNBsbx0JUvxxehu Buzmr8lF/NCIKAYJPMX4aJK2j8tFLmnz02Ie7eL0GQpVWFHTquuEGYeVoKJ/LHYw 8wFBQEsusjWAv09x3EeQBK+PoDotypy0rI8b1F80j1ZC2LKZkencCc= 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:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=default; bh=SSlr6lfg8QOQAzQ3xrsY0H0lW8k=; b=sH+Pb3UqHOFLFH8OQiGeJk1v/2Vc R1Kny/sXPBdY+lZR8Lr8D52cyHjMohKZnzr8ILpSeE/cCW6/fhquEQyZqYeuQLPW idAmBgZF4xWZbR94TmkDDvOT4WQRBs9lXHXfu0vjWLAxqtyiT81iUjxqWrCuR5SL v0bmcsnokZZGnAc= Received: (qmail 103299 invoked by alias); 13 Dec 2019 18:12:21 -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 101017 invoked by uid 89); 13 Dec 2019 18:11:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-2.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (207.211.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 13 Dec 2019 18:11:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576260709; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZdofF/SyCmUOtiUIKbFBKd8feUxTAaoUWkIqEwKQqdk=; b=QNqqWH9RHmDgD/73WsVshW8VGEta5M/7TabLrqnqEGc7WQjLc0b6wq0ome1zKVFCj6y+kN y4pxn6v0BQy+tzTRwMBKPIobQ+0XRRjBAC8L9qr1IMvAJgMQ814vyf8pgjq8V811kyKeeC UXOSFONEogagGo5TA86SVI/xLZpfqWM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-425-55y7N-4FPCSE8MmIzwS6hQ-1; Fri, 13 Dec 2019 13:11:47 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 602D08017DF for ; Fri, 13 Dec 2019 18:11:46 +0000 (UTC) Received: from t470.redhat.com (ovpn-117-164.phx2.redhat.com [10.3.117.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0A5C5C541; Fri, 13 Dec 2019 18:11:45 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH 15/45] analyzer: new files: analyzer-selftests.{cc|h} Date: Fri, 13 Dec 2019 13:11:04 -0500 Message-Id: <20191213181134.1830-16-dmalcolm@redhat.com> In-Reply-To: <20191213181134.1830-1-dmalcolm@redhat.com> References: <20191213181134.1830-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-IsSubscribed: yes Changed in v4: - Remove include of gcc-plugin.h - call run_analyzer_selftests directly, rather than via plugin registration; wrap the analyzer selftests in #if ENABLE_ANALYZER - fixup for moves of digraph.cc and tristate.cc from gcc/analyzer to gcc gcc/ChangeLog: * analyzer/analyzer-selftests.cc: New file. * analyzer/analyzer-selftests.h: New file. --- gcc/analyzer/analyzer-selftests.cc | 60 ++++++++++++++++++++++++++++++ gcc/analyzer/analyzer-selftests.h | 44 ++++++++++++++++++++++ gcc/selftest-run-tests.c | 6 +++ gcc/selftest.h | 2 + 4 files changed, 112 insertions(+) create mode 100644 gcc/analyzer/analyzer-selftests.cc create mode 100644 gcc/analyzer/analyzer-selftests.h diff --git a/gcc/analyzer/analyzer-selftests.cc b/gcc/analyzer/analyzer-selftests.cc new file mode 100644 index 000000000000..3a1f5ada3776 --- /dev/null +++ b/gcc/analyzer/analyzer-selftests.cc @@ -0,0 +1,60 @@ +/* Selftest support for the analyzer. + Copyright (C) 2019 Free Software Foundation, Inc. + Contributed by David Malcolm . + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tree.h" +#include "stringpool.h" +#include "analyzer/analyzer.h" +#include "analyzer/analyzer-selftests.h" + +#if CHECKING_P + +namespace selftest { + +/* Build a VAR_DECL named NAME of type TYPE, simulating a file-level + static variable. */ + +tree +build_global_decl (const char *name, tree type) +{ + tree decl = build_decl (UNKNOWN_LOCATION, VAR_DECL, + get_identifier (name), type); + TREE_STATIC (decl) = 1; + return decl; +} + +/* Run all analyzer-specific selftests. */ + +void +run_analyzer_selftests () +{ +#if ENABLE_ANALYZER + analyzer_constraint_manager_cc_tests (); + analyzer_program_point_cc_tests (); + analyzer_program_state_cc_tests (); + analyzer_region_model_cc_tests (); +#endif /* #if ENABLE_ANALYZER */ +} + +} /* end of namespace selftest. */ + +#endif /* #if CHECKING_P */ diff --git a/gcc/analyzer/analyzer-selftests.h b/gcc/analyzer/analyzer-selftests.h new file mode 100644 index 000000000000..513df3702385 --- /dev/null +++ b/gcc/analyzer/analyzer-selftests.h @@ -0,0 +1,44 @@ +/* Selftests for the analyzer. + Copyright (C) 2019 Free Software Foundation, Inc. + Contributed by David Malcolm . + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#ifndef GCC_ANALYZER_SELFTESTS_H +#define GCC_ANALYZER_SELFTESTS_H + +#if CHECKING_P + +namespace selftest { + +extern tree build_global_decl (const char *name, tree type); + +extern void run_analyzer_selftests (); + +/* Declarations for specific families of tests (by source file), in + alphabetical order. */ +extern void analyzer_checker_script_cc_tests (); +extern void analyzer_constraint_manager_cc_tests (); +extern void analyzer_program_point_cc_tests (); +extern void analyzer_program_state_cc_tests (); +extern void analyzer_region_model_cc_tests (); + +} /* end of namespace selftest. */ + +#endif /* #if CHECKING_P */ + +#endif /* GCC_ANALYZER_SELFTESTS_H */ diff --git a/gcc/selftest-run-tests.c b/gcc/selftest-run-tests.c index 156575a6695c..17452e8a9f3b 100644 --- a/gcc/selftest-run-tests.c +++ b/gcc/selftest-run-tests.c @@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see #include "options.h" #include "stringpool.h" #include "attribs.h" +#include "analyzer/analyzer-selftests.h" /* This function needed to be split out from selftest.c as it references tests from the whole source tree, and so is within @@ -86,6 +87,8 @@ selftest::run_tests () gimple_c_tests (); rtl_tests_c_tests (); read_rtl_function_c_tests (); + digraph_cc_tests (); + tristate_cc_tests (); /* Higher-level tests, or for components that other selftests don't rely on. */ @@ -115,6 +118,9 @@ selftest::run_tests () /* Run any lang-specific selftests. */ lang_hooks.run_lang_selftests (); + /* Run the analyzer selftests (if enabled). */ + run_analyzer_selftests (); + /* Force a GC at the end of the selftests, to shake out GC-related issues. For example, if any GC-managed items have buggy (or missing) finalizers, this last collection will ensure that things that were diff --git a/gcc/selftest.h b/gcc/selftest.h index 81ee3046b927..1e8ce41f48e6 100644 --- a/gcc/selftest.h +++ b/gcc/selftest.h @@ -228,6 +228,7 @@ extern void convert_c_tests (); extern void diagnostic_c_tests (); extern void diagnostic_format_json_cc_tests (); extern void diagnostic_show_locus_c_tests (); +extern void digraph_cc_tests (); extern void dumpfile_c_tests (); extern void edit_context_c_tests (); extern void et_forest_c_tests (); @@ -258,6 +259,7 @@ extern void store_merging_c_tests (); extern void tree_c_tests (); extern void tree_cfg_c_tests (); extern void tree_diagnostic_path_cc_tests (); +extern void tristate_cc_tests (); extern void typed_splay_tree_c_tests (); extern void unique_ptr_tests_cc_tests (); extern void vec_c_tests ();