xref: /aosp_15_r20/external/clang/test/Modules/merge-vtable-codegen.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: rm -rf %t
2*67e74705SXin Li 
3*67e74705SXin Li // First, build two modules that both re-export the same header.
4*67e74705SXin Li // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodule-name=b -o %t/b.pcm \
5*67e74705SXin Li // RUN:     -emit-module %S/Inputs/merge-vtable-codegen/merge-vtable-codegen.modulemap \
6*67e74705SXin Li // RUN:     -I %S/Inputs/merge-vtable-codegen
7*67e74705SXin Li // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodule-name=c -o %t/c.pcm \
8*67e74705SXin Li // RUN:     -emit-module %S/Inputs/merge-vtable-codegen/merge-vtable-codegen.modulemap \
9*67e74705SXin Li // RUN:     -I %S/Inputs/merge-vtable-codegen
10*67e74705SXin Li 
11*67e74705SXin Li // Use the two modules in a single compile.
12*67e74705SXin Li // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodule-file=%t/b.pcm -fmodule-file=%t/c.pcm \
13*67e74705SXin Li // RUN:     -fmodule-map-file=%S/Inputs/merge-vtable-codegen/merge-vtable-codegen.modulemap \
14*67e74705SXin Li // RUN:     -emit-llvm -o %t/test.o %s
15*67e74705SXin Li 
16*67e74705SXin Li // Note that order is important:
17*67e74705SXin Li // Module 'c' just reexports A, while module 'b' defines a method that uses a
18*67e74705SXin Li // virtual method of A.
19*67e74705SXin Li #include "Inputs/merge-vtable-codegen/c.h"
20*67e74705SXin Li #include "Inputs/merge-vtable-codegen/b.h"
21*67e74705SXin Li 
t()22*67e74705SXin Li void t() {
23*67e74705SXin Li   b(nullptr);
24*67e74705SXin Li }
25