Great thing to add. I agree it is nice to have this in Clang.
Reproducible builds are a goal in Debian.
About the patch itself, it would be nice to have test for it but besides
that, it looks good.
Rather than the warning, it would be nice to have some analogue of -frandom-seed= that would allow explicitly setting the timestamp to be used. When you want reproduceable builds, you should set this, just as you set -frandom-seed=.
What would this warning gain us over simply using grep? The use of the macro is purely a textual property, there's no real parsing required.
If we do accept such a warning, having a more general category for reproducibility problems might be a better approach. Time and Date are one example, but there may be others.
> Mostly to play devil's advocate...
>
> What would this warning gain us over simply using grep? The use of the
> macro is purely a textual property, there's no real parsing required.
Although not realistic, the warning won't be issued if __DATE__/__TIME__,
gets undefined or redefined.
Devil's advocate again: '-D__DATE__=_Pragma("GCC warning(\"foo\")")' or
just '-U__DATE__' ?
> If we do accept such a warning, having a more general category for
> reproducibility problems might be a better approach. Time and Date are
one
> example, but there may be others.
I don't see that this is an either/or choice. We can add -Wdate-time now
(or whatever we want to call it) and add it to a -Wreproducibility group
later, when we have other things to put in that group.
Totally missed this thread and ended up implementing -Wdate-time earlier today as a means to validate our new system header warning suppression semantics.
Please see r210511 + r210512 for the approach taken. Apologies to Prathamesh whose original patch appears to have been on the right track (modulo IdentifierInfo comparisons and missing __TIMESTAMP__ case).