From patchwork Sat Nov 16 01:23:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 1196009 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-513733-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="WL9oNf7j"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="R1p4K1se"; 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 47FHVW442nz9s7T for ; Sat, 16 Nov 2019 12:21:23 +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 :content-type:content-transfer-encoding; q=dns; s=default; b=d1L 1NKWpIzyjOBbKnOlE2Ekv3y9BBOAXEnVPy8TNxIqkU2DUcfO4upa9EvGdjC69gXV 4Kf6+ug9LI7RA7Fdohtxb1Zpc6V8QfALkz6ibJ7pryTjkNA5eBfyvfeiwogCq4UN pOeQCateS5xoRwcFrBeGyXiwt0BI1uMHRtUuCExQ= 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 :content-type:content-transfer-encoding; s=default; bh=UcM0HcYY5 1cABTIVeK1jBIkADPs=; b=WL9oNf7jRm7xcYZ6ig44cUcbkxagFWyyOVFS2L0ry E6JLwA+4J+uUGMQaFency/KvJ9X2WMJVOy0sCOpOTtEy2UXQyxS18AiioqbFwobP pyLwimR4zzejCoZo6xhQhHGvu/Q5bImXrVUPl1zf6w+WtvUakmDIukh/HjfFYhau /c= Received: (qmail 60518 invoked by alias); 16 Nov 2019 01:18:01 -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 57557 invoked by uid 89); 16 Nov 2019 01:17:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.9 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; Sat, 16 Nov 2019 01:17:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573867048; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SCTH9pF4i6EhDyKSj5AudnuCyHODWO4ossyu2HoWp14=; b=R1p4K1sesBc7BfsXuvdT5Udt8M6bzohP9ET6ghqY2orxWmeHRAAMIxpIdgjbgmD0hybTCH rHoOa3upJ/ZlZmqbEO1Mv0Bdzi7kmZDI78Ga87+bwu3n1KfCAWNda3K1VDKGQenzMu+0ts xpxTr3okYRQyTErtwZrqNKz628Zl/wI= 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-267-8bj9BMjdNFSlcLkD0WR7Qw-1; Fri, 15 Nov 2019 20:17:26 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 21F42800686 for ; Sat, 16 Nov 2019 01:17:25 +0000 (UTC) Received: from c64.redhat.com (ovpn-112-32.phx2.redhat.com [10.3.112.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 375DE10246FB; Sat, 16 Nov 2019 01:17:24 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH 19/49] analyzer: new files: analyzer-selftests.{cc|h} Date: Fri, 15 Nov 2019 20:23:06 -0500 Message-Id: <1573867416-55618-20-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1573867416-55618-1-git-send-email-dmalcolm@redhat.com> References: <1573867416-55618-1-git-send-email-dmalcolm@redhat.com> X-Mimecast-Spam-Score: 0 X-IsSubscribed: yes gcc/ChangeLog: * analyzer/analyzer-selftests.cc: New file. * analyzer/analyzer-selftests.h: New file. --- gcc/analyzer/analyzer-selftests.cc | 61 ++++++++++++++++++++++++++++++++++++++ gcc/analyzer/analyzer-selftests.h | 46 ++++++++++++++++++++++++++++ 2 files changed, 107 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 0000000..5696af5 --- /dev/null +++ b/gcc/analyzer/analyzer-selftests.cc @@ -0,0 +1,61 @@ +/* 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 "gcc-plugin.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 () +{ + analyzer_constraint_manager_cc_tests (); + analyzer_digraph_cc_tests (); + analyzer_program_point_cc_tests (); + analyzer_program_state_cc_tests (); + analyzer_region_model_cc_tests (); + analyzer_tristate_cc_tests (); +} + +} /* 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 0000000..1c26f25 --- /dev/null +++ b/gcc/analyzer/analyzer-selftests.h @@ -0,0 +1,46 @@ +/* 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, for the checker plugin. */ +extern void analyzer_checker_script_cc_tests (); +extern void analyzer_constraint_manager_cc_tests (); +extern void analyzer_digraph_cc_tests (); +extern void analyzer_program_point_cc_tests (); +extern void analyzer_program_state_cc_tests (); +extern void analyzer_region_model_cc_tests (); +extern void analyzer_tristate_cc_tests (); + +} /* end of namespace selftest. */ + +#endif /* #if CHECKING_P */ + +#endif /* GCC_ANALYZER_SELFTESTS_H */