commit 767a4eea6cde918505b76da9bde57641e0e0aa34
Author:     Quentin Rameau <[email protected]>
AuthorDate: Thu Jul 21 17:14:20 2016 +0200
Commit:     Quentin Rameau <[email protected]>
CommitDate: Thu Jul 21 17:14:20 2016 +0200

    [cpp] distinguish macro definition sources
    
    It can either be a built-in, from command-line, or input source.

diff --git a/cc1/cc1.h b/cc1/cc1.h
index 1c1d46a..b9cbfb4 100644
--- 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
index 5e74037..53daa3c 100644
--- 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
index 5df4fcb..d2fdf0e 100644
--- 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

Reply via email to