1 // Test the output from -module-file-info about C++20 Modules 2 // can reflect macros definitions correctly. 3 // RUN: rm -rf %t 4 // RUN: mkdir -p %t 5 // RUN: split-file %s %t 6 // 7 // RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/foo.h -o %t/foo.pcm 8 // RUN: %clang_cc1 -module-file-info %t/foo.pcm | FileCheck %t/foo.h 9 // 10 // RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/include_foo.h -o %t/include_foo.pcm 11 // RUN: %clang_cc1 -module-file-info %t/include_foo.pcm | FileCheck %t/include_foo.h 12 13 // RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header -fmodule-file=%t/foo.pcm \ 14 // RUN: %t/import_foo.h -o %t/import_foo.pcm 15 // RUN: %clang_cc1 -module-file-info %t/import_foo.pcm | FileCheck %t/import_foo.h 16 // 17 // RUN: %clang_cc1 -std=c++20 %t/named_module.cppm -emit-module-interface -o %t/M.pcm 18 // RUN: %clang_cc1 -module-file-info %t/M.pcm | FileCheck %t/named_module.cppm 19 20 // RUN: %clang_cc1 -std=c++20 %t/named_module.cppm -emit-reduced-module-interface -o %t/M.pcm 21 // RUN: %clang_cc1 -module-file-info %t/M.pcm | FileCheck %t/named_module.cppm 22 23 //--- foo.h 24 #pragma once 25 #define FOO 26 #define CONSTANT 43 27 #define FUNC_Macro(X) (X+1) 28 #define TO_BE_UNDEF 29 #undef TO_BE_UNDEF 30 31 #ifndef FOO 32 #define CONDITIONAL_DEF 33 #endif 34 35 #define REDEFINE 36 #define REDEFINE 37 38 // CHECK: Macro Definitions: 39 // CHECK-DAG: REDEFINE 40 // CHECK-DAG: FUNC_Macro 41 // CHECK-DAG: CONSTANT 42 // CHECK-DAG: FOO 43 // CHECK-NEXT: === 44 45 //--- include_foo.h 46 #include "foo.h" 47 #undef REDEFINE 48 // CHECK: Macro Definitions: 49 // CHECK-DAG: CONSTANT 50 // CHECK-DAG: FUNC_Macro 51 // CHECK-DAG: FOO 52 // CHECK-NEXT: === 53 54 //--- import_foo.h 55 import "foo.h"; 56 #undef REDEFINE 57 // CHECK: Macro Definitions: 58 // CHECK-DAG: CONSTANT 59 // CHECK-DAG: FUNC_Macro 60 // CHECK-DAG: FOO 61 // CHECK-NEXT: === 62 63 //--- named_module.cppm 64 module; 65 #include "foo.h" 66 export module M; 67 #define M_Module 43 68 // CHECK-NOT: Macro Definitions: 69