commit 767a4eea6cde918505b76da9bde57641e0e0aa34
parent 084f7cad65f54bf44837f6a00524ddc58241348e
Author: Quentin Rameau <quinq@fifth.space>
Date: Thu, 21 Jul 2016 17:14:20 +0200
[cpp] distinguish macro definition sources
It can either be a built-in, from command-line, or input source.
Diffstat:
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/cc1/cc1.h b/cc1/cc1.h
@@ -420,7 +420,7 @@ extern int cpp(void);
extern int expand(char *begin, Symbol *sym);
extern void incdir(char *dir);
extern void outcpp(void);
-extern void defdefine(char *macro, char *val);
+extern void defdefine(char *macro, char *val, char *source);
extern void undefmacro(char *s);
/*
diff --git a/cc1/cpp.c b/cc1/cpp.c
@@ -23,7 +23,7 @@ unsigned cppctx;
int disexpand;
void
-defdefine(char *macro, char *val)
+defdefine(char *macro, char *val, char *source)
{
char *def, *fmt = "#define %s %s";
@@ -32,7 +32,7 @@ defdefine(char *macro, char *val)
def = xmalloc(strlen(fmt) + strlen(macro) + strlen(val));
sprintf(def, fmt, macro, val);
- allocinput("command-line", NULL, def);
+ allocinput(source, NULL, def);
input->nline = ++ncmdlines;
cpp();
delinput();
@@ -78,17 +78,17 @@ icpp(void)
tm = localtime(&t);
strftime(sdate, sizeof(sdate), "\"%b %d %Y\"", tm);
strftime(stime, sizeof(stime), "\"%H:%M:%S\"", tm);
- defdefine("__DATE__", sdate);
- defdefine("__TIME__", stime);
- defdefine("__STDC_VERSION__", "199409L");
- defdefine("__LINE__", NULL);
- defdefine("__FILE__", NULL);
+ defdefine("__DATE__", sdate, "built-in");
+ defdefine("__TIME__", stime, "built-in");
+ defdefine("__STDC_VERSION__", "199409L", "built-in");
+ defdefine("__LINE__", NULL, "built-in");
+ defdefine("__FILE__", NULL, "built-in");
symline = lookup(NS_CPP, "__LINE__");
symfile = lookup(NS_CPP, "__FILE__");
for (bp = list; *bp; ++bp)
- defdefine(*bp, "1");
+ defdefine(*bp, "1", "built-in");
ncmdlines = 0;
}
diff --git a/cc1/main.c b/cc1/main.c
@@ -38,7 +38,7 @@ defmacro(char *macro)
else
p = "1";
- defdefine(macro, p);
+ defdefine(macro, p, "command-line");
}
static void