brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.0 KiB · 022c49f Raw
105 lines · cpp
1// Test generation and import of simple C++20 Header Units.2 3// RUN: rm -rf %t4// RUN: mkdir -p %t5// RUN: split-file %s %t6 7// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-header %t/hu-01.h \8// RUN:  -o %t/hu-01.pcm9 10// RUN: %clang_cc1 -std=c++20 -module-file-info %t/hu-01.pcm | \11// RUN: FileCheck --check-prefix=CHECK-HU %s -DTDIR=%t12 13// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/imp-hu-01.cpp \14// RUN:  -fmodule-file=%t/hu-01.pcm -o %t/B.pcm -Rmodule-import 2>&1  | \15// RUN: FileCheck --check-prefix=CHECK-IMP %s -DTDIR=%t16 17// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/imp-hu-02.cpp \18// RUN:  -fmodule-file=%t/hu-01.pcm -o %t/C.pcm -Rmodule-import 2>&1  | \19// RUN: FileCheck --check-prefix=CHECK-GMF-IMP %s -DTDIR=%t20 21// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-header %t/hu-02.h \22// RUN:  -o %t/hu-02.pcm23 24// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/imp-hu-03.cpp \25// RUN:  -fmodule-file=%t/hu-01.pcm -fmodule-file=%t/hu-02.pcm -o %t/D.pcm \26// RUN: -Rmodule-import 2>&1 | \27// RUN: FileCheck --check-prefix=CHECK-BOTH %s -DTDIR=%t28 29// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-header %t/hu-03.h \30// RUN: -fmodule-file=%t/hu-01.pcm  -o %t/hu-03.pcm31 32// RUN: %clang_cc1 -std=c++20 -module-file-info %t/hu-03.pcm | \33// RUN: FileCheck --check-prefix=CHECK-HU-HU %s -DTDIR=%t34 35// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/imp-hu-04.cpp \36// RUN:  -fmodule-file=%t/hu-03.pcm -o %t/E.pcm -Rmodule-import 2>&1 | \37// RUN: FileCheck --check-prefix=CHECK-NESTED %s -DTDIR=%t38 39//--- hu-01.h40int foo(int);41 42// CHECK-HU:  ====== C++20 Module structure ======43// CHECK-HU-NEXT:  Header Unit '[[TDIR]]/hu-01.h' is the Primary Module at index #144 45//--- imp-hu-01.cpp46export module B;47import "hu-01.h";48 49int bar(int x) {50  return foo(x);51}52// CHECK-IMP: remark: importing module '[[TDIR]]/hu-01.h' from '[[TDIR]]/hu-01.pcm'53// expected-no-diagnostics54 55//--- imp-hu-02.cpp56module;57import "hu-01.h";58 59export module C;60 61int bar(int x) {62  return foo(x);63}64// CHECK-GMF-IMP: remark: importing module '[[TDIR]]/hu-01.h' from '[[TDIR]]/hu-01.pcm'65// expected-no-diagnostics66 67//--- hu-02.h68int baz(int);69 70//--- imp-hu-03.cpp71module;72export import "hu-01.h";73 74export module D;75import "hu-02.h";76 77int bar(int x) {78  return foo(x) + baz(x);79}80// CHECK-BOTH: remark: importing module '[[TDIR]]/hu-01.h' from '[[TDIR]]/hu-01.pcm'81// CHECK-BOTH: remark: importing module '[[TDIR]]/hu-02.h' from '[[TDIR]]/hu-02.pcm'82// expected-no-diagnostics83 84//--- hu-03.h85export import "hu-01.h";86int baz(int);87// CHECK-HU-HU:  ====== C++20 Module structure ======88// CHECK-HU-HU-NEXT:  Header Unit '[[TDIR]]/hu-03.h' is the Primary Module at index #289// CHECK-HU-HU-NEXT:   Exports:90// CHECK-HU-HU-NEXT:    Header Unit '[[TDIR]]/hu-01.h' is at index #191 92// expected-no-diagnostics93 94//--- imp-hu-04.cpp95module;96import "hu-03.h";97 98export module E;99 100int bar(int x) {101  return foo(x) + baz(x);102}103// CHECK-NESTED: remark: importing module '[[TDIR]]/hu-03.h' from '[[TDIR]]/hu-03.pcm'104// expected-no-diagnostics105