|
11 | 11 | //===----------------------------------------------------------------------===//
|
12 | 12 |
|
13 | 13 | #include "IRGenModule.h"
|
| 14 | +#include "swift/AST/IRGenOptions.h" |
14 | 15 | #include "clang/AST/Decl.h"
|
15 | 16 | #include "clang/AST/DeclCXX.h"
|
16 | 17 | #include "clang/AST/DeclGroup.h"
|
@@ -145,14 +146,20 @@ IRGenModule::getAddrOfClangGlobalDecl(clang::GlobalDecl global,
|
145 | 146 | }
|
146 | 147 |
|
147 | 148 | void IRGenModule::finalizeClangCodeGen() {
|
148 |
| - // Ensure that code is emitted for any `PragmaCommentDecl`s. (These are |
149 |
| - // always guaranteed to be directly below the TranslationUnitDecl.) |
150 |
| - // In Clang, this happens automatically during the Sema phase, but here we |
151 |
| - // need to take care of it manually because our Clang CodeGenerator is not |
152 |
| - // attached to Clang Sema as an ASTConsumer. |
153 |
| - for (const auto *D : ClangASTContext->getTranslationUnitDecl()->decls()) { |
154 |
| - if (const auto *PCD = dyn_cast<clang::PragmaCommentDecl>(D)) { |
155 |
| - emitClangDecl(PCD); |
| 149 | + // FIXME: We try to avoid looking for PragmaCommentDecls unless we need to, |
| 150 | + // since clang::DeclContext::decls_begin() can trigger expensive |
| 151 | + // de-serialization. |
| 152 | + if (Triple.isWindowsMSVCEnvironment() || Triple.isWindowsItaniumEnvironment() || |
| 153 | + IRGen.Opts.LLVMLTOKind != IRGenLLVMLTOKind::None) { |
| 154 | + // Ensure that code is emitted for any `PragmaCommentDecl`s. (These are |
| 155 | + // always guaranteed to be directly below the TranslationUnitDecl.) |
| 156 | + // In Clang, this happens automatically during the Sema phase, but here we |
| 157 | + // need to take care of it manually because our Clang CodeGenerator is not |
| 158 | + // attached to Clang Sema as an ASTConsumer. |
| 159 | + for (const auto *D : ClangASTContext->getTranslationUnitDecl()->decls()) { |
| 160 | + if (const auto *PCD = dyn_cast<clang::PragmaCommentDecl>(D)) { |
| 161 | + emitClangDecl(PCD); |
| 162 | + } |
156 | 163 | }
|
157 | 164 | }
|
158 | 165 |
|
|
0 commit comments