mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[cxx-interop] Fix reverse interop crash when using raw modules
Some fields in the AST are cached values that are populated lazily. We should not use those values directly as in case they are not yet computed we get back null pointers. Use ASTContext instead which can call the slow path if the cache is not yet populated. rdar://132746445
This commit is contained in:
@@ -284,11 +284,10 @@ public:
|
||||
if (!isa<clang::TypeDecl>(typeDecl->getClangDecl()))
|
||||
return;
|
||||
// Get the underlying clang type from a type alias decl or record decl.
|
||||
auto clangType =
|
||||
clang::QualType(
|
||||
cast<clang::TypeDecl>(typeDecl->getClangDecl())->getTypeForDecl(),
|
||||
0)
|
||||
.getCanonicalType();
|
||||
auto clangDecl = typeDecl->getClangDecl();
|
||||
auto clangType = clangDecl->getASTContext()
|
||||
.getTypeDeclType(cast<clang::TypeDecl>(clangDecl))
|
||||
.getCanonicalType();
|
||||
if (!isa<clang::RecordType>(clangType.getTypePtr()))
|
||||
return;
|
||||
auto it = seenClangTypes.insert(clangType.getTypePtr());
|
||||
|
||||
Reference in New Issue
Block a user