ref: bec28515232214bce97bf4bfe22de7c6a60835d9
parent: 0e62be95d920c3be8216823162e9d7c925d5e518
author: Quentin Rameau <quinq@fifth.space>
date: Thu Jul 21 13:14:20 EDT 2016
[cpp] distinguish macro definition sources It can either be a built-in, from command-line, or input source.
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -420,7 +420,7 @@
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);
/*
--- a/cc1/cpp.c
+++ b/cc1/cpp.c
@@ -23,7 +23,7 @@
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 @@
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 @@
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;
}
--- a/cc1/main.c
+++ b/cc1/main.c
@@ -38,7 +38,7 @@
else
p = "1";
- defdefine(macro, p);
+ defdefine(macro, p, "command-line");
}
static void