diff options
author | Alp Toker <alp@nuanti.com> | 2014-06-10 06:08:51 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2014-06-10 06:08:51 +0000 |
commit | 4f43e554081ecac149fe360bee6eef2ed7dab8ea (patch) | |
tree | 46e5fdd3b3b27021b25babfd7807fe3ccddf86d4 /clang/lib/Lex | |
parent | f9fc2dcb8775d9df9090d3d450171a6a2f847259 (diff) | |
download | bcm5719-llvm-4f43e554081ecac149fe360bee6eef2ed7dab8ea.tar.gz bcm5719-llvm-4f43e554081ecac149fe360bee6eef2ed7dab8ea.zip |
Implement -Wdate-time preprocessor warning
This GCC warning is useful for validating reproducible builds
and might help when tracking down issues with modules too.
llvm-svn: 210511
Diffstat (limited to 'clang/lib/Lex')
-rw-r--r-- | clang/lib/Lex/PPMacroExpansion.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp index 57bc9468049..b22d9d45904 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -1294,6 +1294,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { } Tok.setKind(tok::string_literal); } else if (II == Ident__DATE__) { + Diag(Tok.getLocation(), diag::warn_pp_date_time); if (!DATELoc.isValid()) ComputeDATE_TIME(DATELoc, TIMELoc, *this); Tok.setKind(tok::string_literal); @@ -1303,6 +1304,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { Tok.getLength())); return; } else if (II == Ident__TIME__) { + Diag(Tok.getLocation(), diag::warn_pp_date_time); if (!TIMELoc.isValid()) ComputeDATE_TIME(DATELoc, TIMELoc, *this); Tok.setKind(tok::string_literal); @@ -1327,6 +1329,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { OS << Depth; Tok.setKind(tok::numeric_constant); } else if (II == Ident__TIMESTAMP__) { + Diag(Tok.getLocation(), diag::warn_pp_date_time); // MSVC, ICC, GCC, VisualAge C++ extension. The generated string should be // of the form "Ddd Mmm dd hh::mm::ss yyyy", which is returned by asctime. @@ -1347,7 +1350,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { Result = "??? ??? ?? ??:??:?? ????\n"; } // Surround the string with " and strip the trailing newline. - OS << '"' << StringRef(Result, strlen(Result)-1) << '"'; + OS << '"' << StringRef(Result).drop_back() << '"'; Tok.setKind(tok::string_literal); } else if (II == Ident__COUNTER__) { // __COUNTER__ expands to a simple numeric value. |