Skip to content

Commit 5977b98

Browse files
committed
Improved comments and add nullptr check
1 parent 7c1f46d commit 5977b98

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

clang/include/clang/Serialization/ASTReader.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,13 @@ class ASTReader
544544
/// to ensure that the definition for related decls comes from the same module
545545
/// as the enclosing main decl. Without this, due to lazy deserialization,
546546
/// the definition for the main decl and related decls may come from different
547-
/// modules.
547+
/// modules. It is used for the following cases:
548+
/// - Lambda inside a template function definition: The main declaration is
549+
/// the enclosing function, and the related declarations are the lambda
550+
/// declarations.
551+
/// - Friend function defined inside a template CXXRecord declaration: The
552+
/// main declaration is the enclosing record, and the related declarations
553+
/// are the friend functions.
548554
llvm::DenseMap<GlobalDeclID, SmallVector<GlobalDeclID, 4>> RelatedDeclsMap;
549555

550556
struct PendingUpdateRecord {

clang/lib/Serialization/ASTWriterDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
817817
// force the definition to be the one inside the definition of the template
818818
// class. Remember this relation to deserialize them together.
819819
if (auto *RD = dyn_cast<CXXRecordDecl>(D->getLexicalParent());
820-
isDefinitionInDependentContext(RD)) {
820+
RD && isDefinitionInDependentContext(RD)) {
821821
Writer.RelatedDeclsMap[Writer.GetDeclRef(RD)].push_back(
822822
Writer.GetDeclRef(D));
823823
}

0 commit comments

Comments
 (0)