diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp --- a/clang/lib/Frontend/FrontendActions.cpp +++ b/clang/lib/Frontend/FrontendActions.cpp @@ -202,7 +202,8 @@ /*AllowASTWithErrors=*/ +CI.getFrontendOpts().AllowPCMWithCompilerErrors, /*IncludeTimestamps=*/ - +CI.getFrontendOpts().BuildingImplicitModule, + +CI.getFrontendOpts().BuildingImplicitModule && + +CI.getFrontendOpts().IncludeTimestamps, /*ShouldCacheASTInMemory=*/ +CI.getFrontendOpts().BuildingImplicitModule)); Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator( diff --git a/clang/test/Modules/timestamps.c b/clang/test/Modules/timestamps.c new file mode 100644 --- /dev/null +++ b/clang/test/Modules/timestamps.c @@ -0,0 +1,30 @@ +/// Verify timestamps that gets embedded in the module +#include + +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash \ +// RUN: -fmodules-cache-path=%t -I %S/Inputs %s +// RUN: cp %t/c_library.pcm %t1.pcm +// RUN: llvm-bcanalyzer --dump --disable-histogram %t1.pcm > %t1.dump +// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=TIMESTAMP --input-file %t1.dump +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash \ +// RUN: -fmodules-cache-path=%t -I %S/Inputs -fno-pch-timestamp %s +// RUN: cp %t/c_library.pcm %t2.pcm +// RUN: llvm-bcanalyzer --dump --disable-histogram %t2.pcm > %t2.dump +// RUN: FileCheck %s --check-prefix=CHECK --check-prefix=NOTIMESTAMP --input-file %t2.dump +// RUN: not diff %t1.dump %t2.dump + + +// CHECK: +// CHECK-NEXT: +// CHECK-NEXT: +// CHECK-NEXT: