[master] 00df3c9e3 vcc: record if any SUB references have been encountered
Nils Goroll
nils.goroll at uplex.de
Mon Feb 8 17:52:03 UTC 2021
commit 00df3c9e380773f97d512ef2472e1bce5f69c944
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Sat Feb 6 14:25:12 2021 +0100
vcc: record if any SUB references have been encountered
For follow up commits, we will need to know if a VCL contains any
references to the SUB type, that is, if the SUB type was used as a vmod
function or method argument.
diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c
index d4dfa0601..78457763d 100644
--- a/lib/libvcc/vcc_compile.c
+++ b/lib/libvcc/vcc_compile.c
@@ -538,7 +538,7 @@ EmitStruct(const struct vcc *tl)
Fc(tl, 0, "\t.ref = VGC_ref,\n");
Fc(tl, 0, "\t.nref = VGC_NREFS,\n");
Fc(tl, 0, "\t.nsrc = VGC_NSRCS,\n");
- Fc(tl, 0, "\t.nsub = %d,\n", tl->nsub);
+ Fc(tl, 0, "\t.nsub = %d,\n", tl->subref > 0 ? tl->nsub : 0);
Fc(tl, 0, "\t.srcname = srcname,\n");
Fc(tl, 0, "\t.srcbody = srcbody,\n");
Fc(tl, 0, "\t.nvmod = %u,\n", tl->vmod_count);
diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h
index 814414c66..2dff6dfa5 100644
--- a/lib/libvcc/vcc_compile.h
+++ b/lib/libvcc/vcc_compile.h
@@ -267,6 +267,7 @@ struct vcc {
struct vsb *sb;
int err;
unsigned nsub;
+ unsigned subref; // SUB arguments present
struct proc *curproc;
VTAILQ_HEAD(, proc) procs;
diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c
index 06d2c7d75..f44a868ab 100644
--- a/lib/libvcc/vcc_expr.c
+++ b/lib/libvcc/vcc_expr.c
@@ -446,6 +446,8 @@ vcc_do_arg(struct vcc *tl, struct func_arg *fa)
vcc_do_enum(tl, fa, PF(tl->t));
SkipToken(tl, ID);
} else {
+ if (fa->type == SUB)
+ tl->subref++;
vcc_expr0(tl, &e2, fa->type);
ERRCHK(tl);
assert(e2->fmt == fa->type);
More information about the varnish-commit
mailing list