@@ -3612,10 +3612,12 @@ class DeclGroupNameContext {
3612
3612
class GroupNameCollectorFromJson : public GroupNameCollector {
3613
3613
StringRef RecordPath;
3614
3614
FileNameToGroupNameMap* pMap = nullptr ;
3615
+ ASTContext &Ctx;
3615
3616
3616
3617
public:
3617
- GroupNameCollectorFromJson (StringRef RecordPath) :
3618
- GroupNameCollector (!RecordPath.empty()), RecordPath(RecordPath) {}
3618
+ GroupNameCollectorFromJson (StringRef RecordPath, ASTContext &Ctx) :
3619
+ GroupNameCollector (!RecordPath.empty()), RecordPath(RecordPath),
3620
+ Ctx (Ctx) {}
3619
3621
StringRef getGroupNameInternal (const ValueDecl *VD) override {
3620
3622
// We need the file path, so there has to be a location.
3621
3623
if (VD->getLoc ().isInvalid ())
@@ -3637,7 +3639,11 @@ class DeclGroupNameContext {
3637
3639
return NullGroupName;
3638
3640
StringRef FileName = llvm::sys::path::filename (FullPath);
3639
3641
auto Found = pMap->find (FileName);
3640
- return Found == pMap->end () ? NullGroupName : Found->second ;
3642
+ if (Found == pMap->end ()) {
3643
+ Ctx.Diags .diagnose (SourceLoc (), diag::error_no_group_info, FileName);
3644
+ return NullGroupName;
3645
+ }
3646
+ return Found->second ;
3641
3647
}
3642
3648
};
3643
3649
@@ -3646,8 +3652,8 @@ class DeclGroupNameContext {
3646
3652
std::unique_ptr<GroupNameCollector> pNameCollector;
3647
3653
3648
3654
public:
3649
- DeclGroupNameContext (StringRef RecordPath) :
3650
- pNameCollector (new GroupNameCollectorFromJson(RecordPath)) {}
3655
+ DeclGroupNameContext (StringRef RecordPath, ASTContext &Ctx ) :
3656
+ pNameCollector (new GroupNameCollectorFromJson(RecordPath, Ctx )) {}
3651
3657
uint32_t getGroupSequence (const ValueDecl *VD) {
3652
3658
return Map.insert (std::make_pair (pNameCollector->getGroupName (VD),
3653
3659
Map.size ())).first ->second ;
@@ -4040,7 +4046,7 @@ void Serializer::writeToStream(raw_ostream &os, ModuleOrSourceFile DC,
4040
4046
}
4041
4047
4042
4048
void Serializer::writeDocToStream (raw_ostream &os, ModuleOrSourceFile DC,
4043
- StringRef GroupInfoPath) {
4049
+ StringRef GroupInfoPath, ASTContext &Ctx ) {
4044
4050
Serializer S{MODULE_DOC_SIGNATURE, DC};
4045
4051
// FIXME: This is only really needed for debugging. We don't actually use it.
4046
4052
S.writeDocBlockInfoBlock ();
@@ -4050,7 +4056,7 @@ void Serializer::writeDocToStream(raw_ostream &os, ModuleOrSourceFile DC,
4050
4056
S.writeDocHeader ();
4051
4057
{
4052
4058
BCBlockRAII restoreBlock (S.Out , COMMENT_BLOCK_ID, 4 );
4053
- DeclGroupNameContext GroupContext (GroupInfoPath);
4059
+ DeclGroupNameContext GroupContext (GroupInfoPath, Ctx );
4054
4060
comment_block::DeclCommentListLayout DeclCommentList (S.Out );
4055
4061
writeDeclCommentTable (DeclCommentList, S.SF , S.M , GroupContext);
4056
4062
comment_block::GroupNamesLayout GroupNames (S.Out );
@@ -4130,7 +4136,8 @@ void swift::serialize(ModuleOrSourceFile DC,
4130
4136
(void )withOutputFile (getContext (DC), options.DocOutputPath ,
4131
4137
[&](raw_ostream &out) {
4132
4138
SharedTimer timer (" Serialization (swiftdoc)" );
4133
- Serializer::writeDocToStream (out, DC, options.GroupInfoPath );
4139
+ Serializer::writeDocToStream (out, DC, options.GroupInfoPath ,
4140
+ getContext (DC));
4134
4141
});
4135
4142
}
4136
4143
}
0 commit comments