diff options
author | Chuanqi Xu <yedeng.yd@linux.alibaba.com> | 2022-11-11 16:39:12 +0800 |
---|---|---|
committer | Chuanqi Xu <yedeng.yd@linux.alibaba.com> | 2022-11-14 13:28:26 +0800 |
commit | 360c5fe54c0758c73bf85453fd2913f371adc7d5 (patch) | |
tree | 41afe001f141722af4c3d93b660c3d14f0f5adde /clang/lib/Frontend/FrontendActions.cpp | |
parent | f7f917a7645833822fa623f97e330a1b74951197 (diff) | |
download | llvm-360c5fe54c0758c73bf85453fd2913f371adc7d5.zip llvm-360c5fe54c0758c73bf85453fd2913f371adc7d5.tar.gz llvm-360c5fe54c0758c73bf85453fd2913f371adc7d5.tar.bz2 |
[C++20] [Modules] Emit Macro Definition in -module-file-info action
It is helpful to know whih macro definition is emitted in the module
file without openning it directly. And this is not easy to be tested
with the lit test. So this patch add the facility to emit macro
definitions in `-module-file-info` action. And this should be innnocent
for every other cases.
Diffstat (limited to 'clang/lib/Frontend/FrontendActions.cpp')
-rw-r--r-- | clang/lib/Frontend/FrontendActions.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp index be3c42e..b4ec389 100644 --- a/clang/lib/Frontend/FrontendActions.cpp +++ b/clang/lib/Frontend/FrontendActions.cpp @@ -938,6 +938,20 @@ 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"; + } + // Now let's print out any modules we did not see as part of the Primary. for (auto SM : SubModMap) { if (!SM.second.Seen && SM.second.Mod) { |