Print this page
10063 basic support for smatch
10153 checkpaths shouldn't check packaging exceptions
*** 24,33 ****
--- 24,35 ----
* Copyright 2018, Richard Lowe.
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright 2018 Joyent, Inc.
*/
/*
* Wrapper for the GNU C compiler to make it accept the Sun C compiler
* arguments where possible.
*** 289,299 ****
int ael_argc;
};
typedef enum {
GNU,
! SUN
} compiler_style_t;
typedef struct {
char *c_name;
char *c_path;
--- 291,302 ----
int ael_argc;
};
typedef enum {
GNU,
! SUN,
! SMATCH
} compiler_style_t;
typedef struct {
char *c_name;
char *c_path;
*** 1269,1278 ****
--- 1272,1307 ----
newae(ctx->i_ae, ctx->i_discard);
}
}
static void
+ do_smatch(cw_ictx_t *ctx)
+ {
+ if (ctx->i_flags & CW_F_PROG) {
+ newae(ctx->i_ae, "--version");
+ return;
+ }
+
+ /*
+ * Some sources shouldn't run smatch at all.
+ */
+ for (int i = 0; i < ctx->i_oldargc; i++) {
+ char *arg = ctx->i_oldargv[i];
+
+ if (strcmp(arg, "-_smatch=off") == 0) {
+ ctx->i_flags &= ~ (CW_F_EXEC | CW_F_ECHO);
+ return;
+ }
+ }
+
+ /*
+ * smatch can handle gcc's options.
+ */
+ do_gcc(ctx);
+ }
+
+ static void
do_cc(cw_ictx_t *ctx)
{
int in_output = 0, seen_o = 0;
cw_op_t op = CW_O_LINK;
char *nameflag;
*** 1374,1383 ****
--- 1403,1415 ----
do_cc(ctx);
break;
case GNU:
do_gcc(ctx);
break;
+ case SMATCH:
+ do_smatch(ctx);
+ break;
}
}
static int
invoke(cw_ictx_t *ctx)
*** 1558,1574 ****
if ((token = strsep(&tspec, ",")) == NULL)
errx(1, "Compiler is missing a style: %s", spec);
if ((strcasecmp(token, "gnu") == 0) ||
! (strcasecmp(token, "gcc") == 0))
compiler->c_style = GNU;
! else if ((strcasecmp(token, "sun") == 0) ||
! (strcasecmp(token, "cc") == 0))
compiler->c_style = SUN;
! else
errx(1, "unknown compiler style: %s", token);
if (tspec != NULL)
errx(1, "Excess tokens in compiler: %s", spec);
}
--- 1590,1609 ----
if ((token = strsep(&tspec, ",")) == NULL)
errx(1, "Compiler is missing a style: %s", spec);
if ((strcasecmp(token, "gnu") == 0) ||
! (strcasecmp(token, "gcc") == 0)) {
compiler->c_style = GNU;
! } else if ((strcasecmp(token, "sun") == 0) ||
! (strcasecmp(token, "cc") == 0)) {
compiler->c_style = SUN;
! } else if ((strcasecmp(token, "smatch") == 0)) {
! compiler->c_style = SMATCH;
! } else {
errx(1, "unknown compiler style: %s", token);
+ }
if (tspec != NULL)
errx(1, "Excess tokens in compiler: %s", spec);
}