|
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/DeclGroup.h"
|
16 | 17 | #include "clang/AST/GlobalDecl.h"
|
@@ -118,14 +119,20 @@ IRGenModule::getAddrOfClangGlobalDecl(clang::GlobalDecl global,
|
118 | 119 | }
|
119 | 120 |
|
120 | 121 | void IRGenModule::finalizeClangCodeGen() {
|
121 |
| - // Ensure that code is emitted for any `PragmaCommentDecl`s. (These are |
122 |
| - // always guaranteed to be directly below the TranslationUnitDecl.) |
123 |
| - // In Clang, this happens automatically during the Sema phase, but here we |
124 |
| - // need to take care of it manually because our Clang CodeGenerator is not |
125 |
| - // attached to Clang Sema as an ASTConsumer. |
126 |
| - for (const auto *D : ClangASTContext->getTranslationUnitDecl()->decls()) { |
127 |
| - if (const auto *PCD = dyn_cast<clang::PragmaCommentDecl>(D)) { |
128 |
| - emitClangDecl(PCD); |
| 122 | + // FIXME: We try to avoid looking for PragmaCommentDecls unless we need to, |
| 123 | + // since clang::DeclContext::decls_begin() can trigger expensive |
| 124 | + // de-serialization. |
| 125 | + if (Triple.isWindowsMSVCEnvironment() || Triple.isWindowsItaniumEnvironment() || |
| 126 | + IRGen.Opts.LLVMLTOKind != IRGenLLVMLTOKind::None) { |
| 127 | + // Ensure that code is emitted for any `PragmaCommentDecl`s. (These are |
| 128 | + // always guaranteed to be directly below the TranslationUnitDecl.) |
| 129 | + // In Clang, this happens automatically during the Sema phase, but here we |
| 130 | + // need to take care of it manually because our Clang CodeGenerator is not |
| 131 | + // attached to Clang Sema as an ASTConsumer. |
| 132 | + for (const auto *D : ClangASTContext->getTranslationUnitDecl()->decls()) { |
| 133 | + if (const auto *PCD = dyn_cast<clang::PragmaCommentDecl>(D)) { |
| 134 | + emitClangDecl(PCD); |
| 135 | + } |
129 | 136 | }
|
130 | 137 | }
|
131 | 138 |
|
|
0 commit comments