69 lines · cpp
1// Test the output from -module-file-info about C++20 Modules2// can reflect macros definitions correctly.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++-user-header %t/foo.h -o %t/foo.pcm8// RUN: %clang_cc1 -module-file-info %t/foo.pcm | FileCheck %t/foo.h9//10// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/include_foo.h -o %t/include_foo.pcm11// RUN: %clang_cc1 -module-file-info %t/include_foo.pcm | FileCheck %t/include_foo.h12 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.pcm15// RUN: %clang_cc1 -module-file-info %t/import_foo.pcm | FileCheck %t/import_foo.h16//17// RUN: %clang_cc1 -std=c++20 %t/named_module.cppm -emit-module-interface -o %t/M.pcm18// RUN: %clang_cc1 -module-file-info %t/M.pcm | FileCheck %t/named_module.cppm19 20// RUN: %clang_cc1 -std=c++20 %t/named_module.cppm -emit-reduced-module-interface -o %t/M.pcm21// RUN: %clang_cc1 -module-file-info %t/M.pcm | FileCheck %t/named_module.cppm22 23//--- foo.h24#pragma once25#define FOO26#define CONSTANT 4327#define FUNC_Macro(X) (X+1)28#define TO_BE_UNDEF29#undef TO_BE_UNDEF30 31#ifndef FOO32#define CONDITIONAL_DEF33#endif34 35#define REDEFINE36#define REDEFINE37 38// CHECK: Macro Definitions:39// CHECK: CONSTANT40// CHECK: FOO41// CHECK: FUNC_Macro42// CHECK: REDEFINE43// CHECK-NEXT: ===44 45//--- include_foo.h46#include "foo.h"47#undef REDEFINE48// CHECK: Macro Definitions:49// CHECK: CONSTANT50// CHECK: FOO51// CHECK: FUNC_Macro52// CHECK-NEXT: ===53 54//--- import_foo.h55import "foo.h";56#undef REDEFINE57// CHECK: Macro Definitions:58// CHECK: CONSTANT59// CHECK: FOO60// CHECK: FUNC_Macro61// CHECK-NEXT: ===62 63//--- named_module.cppm64module;65#include "foo.h"66export module M;67#define M_Module 4368// CHECK-NOT: Macro Definitions:69