@@ -565,7 +565,7 @@ class DeclUSRsTableWriter {
565
565
return None;
566
566
}
567
567
void emitUSRsRecord (llvm::BitstreamWriter &out) {
568
- sourceinfo_block ::DeclUSRSLayout USRsList (out);
568
+ decl_locs_block ::DeclUSRSLayout USRsList (out);
569
569
SmallVector<uint64_t , 8 > scratch;
570
570
llvm::SmallString<32 > hashTableBlob;
571
571
uint32_t tableOffset;
@@ -593,7 +593,7 @@ class StringWriter {
593
593
}
594
594
595
595
void emitSourceFilesRecord (llvm::BitstreamWriter &Out) {
596
- sourceinfo_block ::TextDataLayout TextBlob (Out);
596
+ decl_locs_block ::TextDataLayout TextBlob (Out);
597
597
SmallVector<uint64_t , 8 > scratch;
598
598
TextBlob.emit (scratch, Buffer);
599
599
}
@@ -625,7 +625,7 @@ writer.write<uint32_t>(data.X.Column);
625
625
#undef WRITE_LINE_COLUMN
626
626
}
627
627
628
- Optional<uint32_t > calculateUSRId (Decl *D) {
628
+ Optional<uint32_t > calculateNewUSRId (Decl *D) {
629
629
llvm::SmallString<512 > Buffer;
630
630
llvm::raw_svector_ostream OS (Buffer);
631
631
if (ide::printDeclUSR (D, OS))
@@ -698,10 +698,15 @@ Result.X.Column = Locs->X.Column;
698
698
return false ;
699
699
if (!shouldSerializeSourceLoc (D))
700
700
return true ;
701
- auto USR = calculateUSRId (D);
701
+ // If we cannot get loc data for D, don't proceed.
702
702
auto LocData = getLocData (D);
703
- if (!USR. hasValue () || ! LocData.hasValue ())
703
+ if (!LocData.hasValue ())
704
704
return true ;
705
+ // If we have handled this USR before, don't proceed.
706
+ auto USR = calculateNewUSRId (D);
707
+ if (!USR.hasValue ())
708
+ return true ;
709
+ // OK, we get a new USR, now append the associated source location data.
705
710
assert (*USR * sizeof (DeclLocationsTableData) == Buffer.size () &&
706
711
" USR id is used as an index to access basic location array" );
707
712
appendToBuffer (*LocData);
@@ -713,7 +718,7 @@ static void emitBasicLocsRecord(llvm::BitstreamWriter &Out,
713
718
ModuleOrSourceFile MSF, DeclUSRsTableWriter &USRWriter,
714
719
StringWriter &FWriter) {
715
720
assert (MSF);
716
- const sourceinfo_block ::BasicDeclLocsLayout DeclLocsList (Out);
721
+ const decl_locs_block ::BasicDeclLocsLayout DeclLocsList (Out);
717
722
BasicDeclLocsTableWriter Writer (USRWriter, FWriter);
718
723
if (auto *SF = MSF.dyn_cast <SourceFile*>()) {
719
724
SF->walk (Writer);
@@ -749,9 +754,9 @@ class SourceInfoSerializer : public SerializerBase {
749
754
BLOCK_RECORD (control_block, TARGET);
750
755
751
756
BLOCK (DECL_LOCS_BLOCK);
752
- BLOCK_RECORD (sourceinfo_block , BASIC_DECL_LOCS);
753
- BLOCK_RECORD (sourceinfo_block , DECL_USRS);
754
- BLOCK_RECORD (sourceinfo_block , TEXT_DATA);
757
+ BLOCK_RECORD (decl_locs_block , BASIC_DECL_LOCS);
758
+ BLOCK_RECORD (decl_locs_block , DECL_USRS);
759
+ BLOCK_RECORD (decl_locs_block , TEXT_DATA);
755
760
756
761
#undef BLOCK
757
762
#undef BLOCK_RECORD
0 commit comments