Skip to content

Commit

Permalink
12166 resync smatch to 0.6.1-rc1-il-3
Browse files Browse the repository at this point in the history
Reviewed by: Toomas Soome <tsoome@me.com>
Approved by: Robert Mustacchi <rm@fingolfin.org>
  • Loading branch information
John Levon committed Jan 10, 2020
1 parent ccbce73 commit 5a0e240
Show file tree
Hide file tree
Showing 38 changed files with 2,208 additions and 1,152 deletions.
8 changes: 5 additions & 3 deletions usr/src/tools/smatch/Makefile
Expand Up @@ -8,7 +8,7 @@
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
# Copyright 2019 Joyent, Inc.
# Copyright 2020 Joyent, Inc.
#

#
Expand All @@ -20,7 +20,7 @@
#

PROG = smatch
SPARSE_VERSION = 0.6.1-rc1-il-2
SPARSE_VERSION = 0.6.1-rc1-il-3

include ../Makefile.tools

Expand All @@ -31,7 +31,8 @@ sparc_CC = $(GNUC_ROOT)/bin/gcc
i386_SMATCHFLAGS = -msave-args
sparc_SMATCHFLAGS =

CFLAGS = -O -m64 $($(MACH)_SMATCHFLAGS) -D__sun -Wall -Wno-unknown-pragmas -std=gnu99 -nodefaultlibs
CFLAGS = -O -m64 -std=gnu99 -nodefaultlibs -D__sun $($(MACH)_SMATCHFLAGS)
CFLAGS += -Wall -Wno-unknown-pragmas -Wno-psabi

SMATCHDATADIR = $(ROOTONBLDSHARE)/smatch

Expand Down Expand Up @@ -176,6 +177,7 @@ SMATCH_OBJS += smatch_type_val.o
SMATCH_OBJS += smatch_unknown_value.o
SMATCH_OBJS += smatch_untracked_param.o
SMATCH_OBJS += smatch_var_sym.o
SMATCH_OBJS += smatch_parsed_conditions.o

SMATCH_CHECK_OBJS:sh=ls src/check_*.c | sed -e 's+\.c+.o+;s+src/++;'

Expand Down
5 changes: 3 additions & 2 deletions usr/src/tools/smatch/src/Makefile
@@ -1,4 +1,4 @@
VERSION=0.6.1-rc1-il-2
VERSION=0.6.1-rc1-il-3

########################################################################
# The following variables can be overwritten from the command line
Expand Down Expand Up @@ -95,7 +95,7 @@ all:
# common flags/options/...

cflags = -fno-strict-aliasing
cflags += -Wall -Wwrite-strings -Wno-switch
cflags += -Wall -Wwrite-strings -Wno-switch -Wno-psabi

GCC_BASE := $(shell $(CC) --print-file-name=)
cflags += -DGCC_BASE=\"$(GCC_BASE)\"
Expand Down Expand Up @@ -254,6 +254,7 @@ SMATCH_OBJS += smatch_param_set.o
SMATCH_OBJS += smatch_param_to_mtag_data.o
SMATCH_OBJS += smatch_param_used.o
SMATCH_OBJS += smatch_parse_call_math.o
SMATCH_OBJS += smatch_parsed_conditions.o
SMATCH_OBJS += smatch_passes_array_size.o
SMATCH_OBJS += smatch_project.o
SMATCH_OBJS += smatch_ranges.o
Expand Down
16 changes: 15 additions & 1 deletion usr/src/tools/smatch/src/check_debug.c
Expand Up @@ -15,6 +15,8 @@
* along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
*/

#include <string.h>

#include "smatch.h"
#include "smatch_slist.h"
#include "smatch_extra.h"
Expand Down Expand Up @@ -86,7 +88,7 @@ static void match_states(const char *fn, struct expression *expr, void *info)
}

FOR_EACH_SM(__get_cur_stree(), sm) {
if (strcmp(check_name(sm->owner), check_arg->string->data) != 0)
if (!strstr(check_name(sm->owner), check_arg->string->data))
continue;
sm_msg("%s", show_sm(sm));
found = 1;
Expand Down Expand Up @@ -514,6 +516,16 @@ static void match_local_debug_off(const char *fn, struct expression *expr, void
local_debug = 0;
}

static void match_debug_db_on(const char *fn, struct expression *expr, void *info)
{
debug_db = 1;
}

static void match_debug_db_off(const char *fn, struct expression *expr, void *info)
{
debug_db = 0;
}

static void match_about(const char *fn, struct expression *expr, void *info)
{
struct expression *arg;
Expand Down Expand Up @@ -773,6 +785,8 @@ void check_debug(int id)
add_function_hook("__smatch_debug_off", &match_debug_off, NULL);
add_function_hook("__smatch_local_debug_on", &match_local_debug_on, NULL);
add_function_hook("__smatch_local_debug_off", &match_local_debug_off, NULL);
add_function_hook("__smatch_debug_db_on", &match_debug_db_on, NULL);
add_function_hook("__smatch_debug_db_off", &match_debug_db_off, NULL);
add_function_hook("__smatch_intersection", &match_intersection, NULL);
add_function_hook("__smatch_type", &match_type, NULL);
add_implied_return_hook("__smatch_type_rl_helper", &match_type_rl_return, NULL);
Expand Down
3 changes: 3 additions & 0 deletions usr/src/tools/smatch/src/check_debug.h
Expand Up @@ -46,6 +46,9 @@ static inline void __smatch_debug_off(void){}
static inline void __smatch_local_debug_on(void){}
static inline void __smatch_local_debug_off(void){}

static inline void __smatch_debug_db_on(void){}
static inline void __smatch_debug_db_off(void){}

static inline void __smatch_debug_implied_on(void){}
static inline void __smatch_debug_implied_off(void){}

Expand Down
17 changes: 0 additions & 17 deletions usr/src/tools/smatch/src/check_frees_param.c
Expand Up @@ -29,27 +29,12 @@ static int my_id;

STATE(freed);
STATE(ignore);
STATE(param);

static void set_ignore(struct sm_state *sm, struct expression *mod_expr)
{
set_state(my_id, sm->name, sm->sym, &ignore);
}

static void match_function_def(struct symbol *sym)
{
struct symbol *arg;
int i;

i = -1;
FOR_EACH_PTR(sym->ctype.base_type->arguments, arg) {
i++;
if (!arg->ident)
continue;
set_state(my_id, arg->ident->name, arg, &param);
} END_FOR_EACH_PTR(arg);
}

static void freed_variable(struct expression *expr)
{
struct sm_state *sm;
Expand Down Expand Up @@ -111,8 +96,6 @@ void check_frees_param(int id)
return;
}

add_hook(&match_function_def, FUNC_DEF_HOOK);

add_function_hook("free", &match_free, INT_PTR(0));

select_return_implies_hook(PARAM_FREED, &set_param_freed);
Expand Down
8 changes: 5 additions & 3 deletions usr/src/tools/smatch/src/check_list.h
Expand Up @@ -25,16 +25,16 @@ CK(register_param_compare_limit)
CK(register_param_compare_limit_links)
CK(register_returns_early)

CK(register_param_cleared) /* param_set relies on param_cleared */
CK(register_param_set)

CK(register_smatch_ignore)
CK(register_buf_size)
CK(register_strlen)
CK(register_strlen_equiv)
CK(register_capped)
CK(register_parse_call_math)
CK(register_param_limit)
CK(register_param_filter)
CK(register_param_set)
CK(register_param_cleared)
CK(register_struct_assignment)
CK(register_comparison)
CK(register_comparison_links)
Expand All @@ -58,6 +58,7 @@ CK(register_imaginary_absolute)
CK(register_bits)
CK(register_fn_arg_link)
CK(register_parameter_names)
CK(register_param_limit)
CK(register_return_to_param)
CK(register_return_to_param_links)
CK(register_constraints)
Expand Down Expand Up @@ -207,6 +208,7 @@ CK(check_cmn_err)
CK(register_scope)
CK(register_stored_conditions)
CK(register_stored_conditions_links)
CK(register_parsed_conditions)
CK(register_sval)
CK(register_buf_size_late)
CK(register_smatch_extra_late)
Expand Down

0 comments on commit 5a0e240

Please sign in to comment.