Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions clang/lib/Frontend/FrontendActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,14 +971,17 @@ void DumpModuleInfoAction::ExecuteAction() {
// Emit the macro definitions in the module file so that we can know how
// much definitions in the module file quickly.
// TODO: Emit the macro definition bodies completely.
if (auto FilteredMacros = llvm::make_filter_range(
R->getPreprocessor().macros(),
[](const auto &Macro) { return Macro.first->isFromAST(); });
!FilteredMacros.empty()) {
Out << " Macro Definitions:\n";
for (/*<IdentifierInfo *, MacroState> pair*/ const auto &Macro :
FilteredMacros)
Out << " " << Macro.first->getName() << "\n";
{
std::vector<StringRef> MacroNames;
for (const auto &M : R->getPreprocessor().macros()) {
if (M.first->isFromAST())
MacroNames.push_back(M.first->getName());
}
llvm::sort(MacroNames);
if (!MacroNames.empty())
Out << " Macro Definitions:\n";
for (StringRef Name : MacroNames)
Out << " " << Name << "\n";
}

// Now let's print out any modules we did not see as part of the Primary.
Expand Down
20 changes: 10 additions & 10 deletions clang/test/Modules/cxx20-module-file-info-macros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,28 @@
#define REDEFINE

// CHECK: Macro Definitions:
// CHECK-DAG: REDEFINE
// CHECK-DAG: FUNC_Macro
// CHECK-DAG: CONSTANT
// CHECK-DAG: FOO
// CHECK: CONSTANT
// CHECK: FOO
// CHECK: FUNC_Macro
// CHECK: REDEFINE
// CHECK-NEXT: ===

//--- include_foo.h
#include "foo.h"
#undef REDEFINE
// CHECK: Macro Definitions:
// CHECK-DAG: CONSTANT
// CHECK-DAG: FUNC_Macro
// CHECK-DAG: FOO
// CHECK: CONSTANT
// CHECK: FOO
// CHECK: FUNC_Macro
// CHECK-NEXT: ===

//--- import_foo.h
import "foo.h";
#undef REDEFINE
// CHECK: Macro Definitions:
// CHECK-DAG: CONSTANT
// CHECK-DAG: FUNC_Macro
// CHECK-DAG: FOO
// CHECK: CONSTANT
// CHECK: FOO
// CHECK: FUNC_Macro
// CHECK-NEXT: ===

//--- named_module.cppm
Expand Down