Skip to content

Commit 8c58a77

Browse files
committed
[cxx-interop] Fix AST serialization error
Do not attempt to serialize C++ builtin decls. This caused an assertion failure in `clang::ASTWriter::getDeclID` when building SwiftCompilerSources: ``` Assertion failed: (DeclIDs.find(D) != DeclIDs.end() && "Declaration not emitted!"), function getDeclID, file ASTWriter.cpp, line 5272. Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. <eof> parser at end of file Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): 0 swift-frontend 0x00000001123e21c7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39 1 swift-frontend 0x00000001123e10e8 llvm::sys::RunSignalHandlers() + 248 2 swift-frontend 0x00000001123e2810 SignalHandler(int) + 288 3 libsystem_platform.dylib 0x00007fff204a0d7d _sigtramp + 29 4 libsystem_platform.dylib 0x0000000000000008 _sigtramp + 18446603339974439592 5 libsystem_c.dylib 0x00007fff203b0406 abort + 125 6 libsystem_c.dylib 0x00007fff203af7d8 err + 0 7 swift-frontend 0x000000011345b983 clang::ASTWriter::getDeclID(clang::Decl const*) (.cold.1) + 35 8 swift-frontend 0x0000000110a584b2 clang::ASTWriter::getDeclID(clang::Decl const*) + 322 9 swift-frontend 0x000000010e36649c llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::BaseNameToEntitiesTableWriterInfo>::Emit(llvm::raw_ostream&, (anonymous namespace)::BaseNameToEntitiesTableWriterInfo&) + 1244 10 swift-frontend 0x000000010e364927 swift::SwiftLookupTableWriter::writeExtensionContents(clang::Sema&, llvm::BitstreamWriter&) + 1351 11 swift-frontend 0x0000000110a59b62 clang::ASTWriter::WriteModuleFileExtension(clang::Sema&, clang::ModuleFileExtensionWriter&) + 946 ```
1 parent 2472dfc commit 8c58a77

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2629,6 +2629,10 @@ bool importer::shouldSuppressDeclImport(const clang::Decl *decl) {
26292629
return false;
26302630
}
26312631

2632+
if (isa<clang::BuiltinTemplateDecl>(decl)) {
2633+
return true;
2634+
}
2635+
26322636
return false;
26332637
}
26342638

0 commit comments

Comments
 (0)