xref: /aosp_15_r20/external/clang/test/Modules/no-stale-modtime.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// Ensure that when rebuilding a module we don't save its old modtime when
2*67e74705SXin Li// building modules that depend on it.
3*67e74705SXin Li
4*67e74705SXin Li// RUN: rm -rf %t
5*67e74705SXin Li// RUN: mkdir -p %t
6*67e74705SXin Li// This could be replaced by diamond_*, except we want to modify the top header
7*67e74705SXin Li// RUN: echo '@import l; @import r;' > %t/b.h
8*67e74705SXin Li// RUN: echo '@import t; // fromt l' > %t/l.h
9*67e74705SXin Li// RUN: echo '@import t; // fromt r' > %t/r.h
10*67e74705SXin Li// RUN: echo '// top' > %t/t.h
11*67e74705SXin Li// RUN: echo 'module b { header "b.h" } module l { header "l.h" }' > %t/module.map
12*67e74705SXin Li// RUN: echo 'module r { header "r.h" } module t { header "t.h" }' >> %t/module.map
13*67e74705SXin Li
14*67e74705SXin Li// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
15*67e74705SXin Li// RUN:     -I %t -fsyntax-only %s -Rmodule-build 2>&1 \
16*67e74705SXin Li// RUN: | FileCheck -check-prefix=REBUILD-ALL %s
17*67e74705SXin Li// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
18*67e74705SXin Li// RUN:     -I %t -fsyntax-only %s -Rmodule-build -verify
19*67e74705SXin Li
20*67e74705SXin Li// Add an identifier to ensure everything depending on t is out of date
21*67e74705SXin Li// RUN: echo 'extern int a;' >> %t/t.h
22*67e74705SXin Li// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
23*67e74705SXin Li// RUN:     -I %t -fsyntax-only %s -Rmodule-build 2>&1 \
24*67e74705SXin Li// RUN: | FileCheck -check-prefix=REBUILD-ALL %s
25*67e74705SXin Li// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
26*67e74705SXin Li// RUN:     -I %t -fsyntax-only %s -Rmodule-build -verify
27*67e74705SXin Li
28*67e74705SXin Li// REBUILD-ALL: building module 'b'
29*67e74705SXin Li// REBUILD-ALL: building module 'l'
30*67e74705SXin Li// REBUILD-ALL: building module 't'
31*67e74705SXin Li// REBUILD-ALL: building module 'r'
32*67e74705SXin Li
33*67e74705SXin Li// Use -verify when expecting no modules to be rebuilt.
34*67e74705SXin Li// expected-no-diagnostics
35*67e74705SXin Li
36*67e74705SXin Li@import b;
37