@@ -35,6 +35,13 @@ const char*[] varDeclNames = {
3535
3636static_assert(elemsof(VarDeclKind), elemsof(varDeclNames));
3737
38+ type AutoAttr enum u32 {
39+ None,
40+ File,
41+ Line,
42+ Func,
43+ }
44+
3845type VarDeclBits struct {
3946 u32 : NumDeclBits;
4047 u32 kind : 3;
@@ -43,8 +50,7 @@ type VarDeclBits struct {
4350 u32 has_init_call : 1; // local variables only
4451 u32 attr_weak : 1; // globals only
4552 u32 addr_used : 1;
46- u32 auto_file : 1; // for parameters only
47- u32 auto_line : 1; // for parameters only
53+ u32 auto_attr : 2; // AutoAttr, for parameters only
4854 u32 printf_format : 1; // for parameters only
4955}
5056
@@ -247,23 +253,31 @@ public fn bool VarDecl.hasAttrWeak(const VarDecl* d) {
247253}
248254
249255public fn void VarDecl.setAttrAutoFile(VarDecl* d) {
250- d.base.varDeclBits.auto_file = 1 ;
256+ d.base.varDeclBits.auto_attr = AutoAttr.File ;
251257}
252258
253259public fn bool VarDecl.hasAttrAutoFile(const VarDecl* d) {
254- return d.base.varDeclBits.auto_file ;
260+ return d.base.varDeclBits.auto_attr == AutoAttr.File ;
255261}
256262
257263public fn void VarDecl.setAttrAutoLine(VarDecl* d) {
258- d.base.varDeclBits.auto_line = 1 ;
264+ d.base.varDeclBits.auto_attr = AutoAttr.Line ;
259265}
260266
261267public fn bool VarDecl.hasAttrAutoLine(const VarDecl* d) {
262- return d.base.varDeclBits.auto_line;
268+ return d.base.varDeclBits.auto_attr == AutoAttr.Line;
269+ }
270+
271+ public fn void VarDecl.setAttrAutoFunc(VarDecl* d) {
272+ d.base.varDeclBits.auto_attr = AutoAttr.Func;
273+ }
274+
275+ public fn bool VarDecl.hasAttrAutoFunc(const VarDecl* d) {
276+ return d.base.varDeclBits.auto_attr == AutoAttr.Func;
263277}
264278
265279public fn bool VarDecl.hasAutoAttr(const VarDecl* d) {
266- return d.base.varDeclBits.auto_file || d.base.varDeclBits.auto_line ;
280+ return d.base.varDeclBits.auto_attr != AutoAttr.None ;
267281}
268282
269283public fn void VarDecl.setPrintfFormat(VarDecl* d) {
@@ -289,8 +303,12 @@ fn void VarDecl.print(const VarDecl* d, string_buffer.Buf* out, u32 indent) {
289303 if (d.hasLocalQualifier()) out.add(" (local)");
290304 if (d.base.varDeclBits.attr_weak) out.add(" weak");
291305 if (d.base.varDeclBits.addr_used) out.add(" addr_used");
292- if (d.base.varDeclBits.auto_file) out.add(" auto_file");
293- if (d.base.varDeclBits.auto_line) out.add(" auto_line");
306+ switch ((AutoAttr)d.base.varDeclBits.auto_attr) {
307+ case None: break;
308+ case File: out.add(" auto_file"); break;
309+ case Line: out.add(" auto_line"); break;
310+ case Func: out.add(" auto_func"); break;
311+ }
294312 if (d.base.varDeclBits.printf_format) out.add(" printf_format");
295313 if (d.base.varDeclBits.has_init_call) out.add(" init_call");
296314 d.base.printBits(out);
0 commit comments