[clang][cli] Specify correct integer width for -fbuild-session-timestamp
authorJan Svoboda <jan_svoboda@apple.com>
Tue, 5 Jan 2021 18:45:31 +0000 (19:45 +0100)
committerJan Svoboda <jan_svoboda@apple.com>
Tue, 5 Jan 2021 19:10:07 +0000 (20:10 +0100)
This fixes an issue where large integer values were rejected as invalid.

Reviewed By: arphaman

Differential Revision: https://reviews.llvm.org/D94101

clang/include/clang/Driver/Options.td
clang/unittests/Frontend/CompilerInvocationTest.cpp

index 9a851f6..c7da888 100644 (file)
@@ -1767,7 +1767,7 @@ def fmodules_search_all : Flag <["-"], "fmodules-search-all">, Group<f_Group>,
 def fbuild_session_timestamp : Joined<["-"], "fbuild-session-timestamp=">,
   Group<i_Group>, Flags<[CC1Option]>, MetaVarName<"<time since Epoch in seconds>">,
   HelpText<"Time when the current build session started">,
-  MarshallingInfoStringInt<"HeaderSearchOpts->BuildSessionTimestamp">;
+  MarshallingInfoStringInt<"HeaderSearchOpts->BuildSessionTimestamp", "0", "uint64_t">;
 def fbuild_session_file : Joined<["-"], "fbuild-session-file=">,
   Group<i_Group>, MetaVarName<"<file>">,
   HelpText<"Use the last modification time of <file> as the build session timestamp">;
index 51b7ba8..83ae169 100644 (file)
@@ -368,6 +368,18 @@ TEST_F(CommandLineTest, CanGenerateCC1COmmandLineSeparateEnumDefault) {
   ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("pic"))));
 }
 
+// Wide integer option.
+
+TEST_F(CommandLineTest, WideIntegerHighValue) {
+  const char *Args[] = {"-fbuild-session-timestamp=1609827494445723662"};
+
+  CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
+
+  ASSERT_FALSE(Diags->hasErrorOccurred());
+  ASSERT_EQ(Invocation.getHeaderSearchOpts().BuildSessionTimestamp,
+            1609827494445723662ull);
+}
+
 // Tree of boolean options that can be (directly or transitively) implied by
 // their parent:
 //