@@ -1893,7 +1893,6 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
18931893  //  Write out the source location entry table. We skip the first
18941894  //  entry, which is always the same dummy entry.
18951895  std::vector<uint32_t > SLocEntryOffsets;
1896-   uint64_t  SLocEntryOffsetsBase = Stream.GetCurrentBitNo ();
18971896  RecordData PreloadSLocs;
18981897  SLocEntryOffsets.reserve (SourceMgr.local_sloc_entry_size () - 1 );
18991898  for  (unsigned  I = 1 , N = SourceMgr.local_sloc_entry_size ();
@@ -1904,9 +1903,7 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
19041903    assert (&SourceMgr.getSLocEntry (FID) == SLoc);
19051904
19061905    //  Record the offset of this source-location entry.
1907-     uint64_t  Offset = Stream.GetCurrentBitNo () - SLocEntryOffsetsBase;
1908-     assert ((Offset >> 32 ) == 0  && " SLocEntry offset too large" 
1909-     SLocEntryOffsets.push_back (Offset);
1906+     SLocEntryOffsets.push_back (Stream.GetCurrentBitNo ());
19101907
19111908    //  Figure out which record code to use.
19121909    unsigned  Code;
@@ -2014,14 +2011,12 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
20142011  Abbrev->Add (BitCodeAbbrevOp (SOURCE_LOCATION_OFFSETS));
20152012  Abbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 16 )); //  # of slocs
20162013  Abbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 16 )); //  total size
2017-   Abbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 32 )); //  base offset
20182014  Abbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Blob)); //  offsets
20192015  unsigned  SLocOffsetsAbbrev = Stream.EmitAbbrev (std::move (Abbrev));
20202016  {
20212017    RecordData::value_type Record[] = {
20222018        SOURCE_LOCATION_OFFSETS, SLocEntryOffsets.size (),
2023-         SourceMgr.getNextLocalOffset () - 1  /*  skip dummy */ 
2024-         SLocEntryOffsetsBase};
2019+         SourceMgr.getNextLocalOffset () - 1  /*  skip dummy */ 
20252020    Stream.EmitRecordWithBlob (SLocOffsetsAbbrev, Record,
20262021                              bytes (SLocEntryOffsets));
20272022  }
@@ -2098,11 +2093,9 @@ static bool shouldIgnoreMacro(MacroDirective *MD, bool IsModule,
20982093// / Writes the block containing the serialized form of the
20992094// / preprocessor.
21002095void  ASTWriter::WritePreprocessor (const  Preprocessor &PP, bool  IsModule) {
2101-   uint64_t  MacroOffsetsBase = Stream.GetCurrentBitNo ();
2102- 
21032096  PreprocessingRecord *PPRec = PP.getPreprocessingRecord ();
21042097  if  (PPRec)
2105-     WritePreprocessorDetail (*PPRec, MacroOffsetsBase );
2098+     WritePreprocessorDetail (*PPRec);
21062099
21072100  RecordData Record;
21082101  RecordData ModuleMacroRecord;
@@ -2163,8 +2156,7 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
21632156  //  identifier they belong to.
21642157  for  (const  IdentifierInfo *Name : MacroIdentifiers) {
21652158    MacroDirective *MD = PP.getLocalMacroDirectiveHistory (Name);
2166-     uint64_t  StartOffset = Stream.GetCurrentBitNo () - MacroOffsetsBase;
2167-     assert ((StartOffset >> 32 ) == 0  && " Macro identifiers offset too large" 
2159+     auto  StartOffset = Stream.GetCurrentBitNo ();
21682160
21692161    //  Emit the macro directives in reverse source order.
21702162    for  (; MD; MD = MD->getPrevious ()) {
@@ -2237,12 +2229,14 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
22372229
22382230    //  Record the local offset of this macro.
22392231    unsigned  Index = ID - FirstMacroID;
2240-     if  (Index >= MacroOffsets.size ())
2241-       MacroOffsets.resize (Index + 1 );
2232+     if  (Index == MacroOffsets.size ())
2233+       MacroOffsets.push_back (Stream.GetCurrentBitNo ());
2234+     else  {
2235+       if  (Index > MacroOffsets.size ())
2236+         MacroOffsets.resize (Index + 1 );
22422237
2243-     uint64_t  Offset = Stream.GetCurrentBitNo () - MacroOffsetsBase;
2244-     assert ((Offset >> 32 ) == 0  && " Macro offset too large" 
2245-     MacroOffsets[Index] = Offset;
2238+       MacroOffsets[Index] = Stream.GetCurrentBitNo ();
2239+     }
22462240
22472241    AddIdentifierRef (Name, Record);
22482242    AddSourceLocation (MI->getDefinitionLoc (), Record);
@@ -2293,20 +2287,17 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
22932287  Abbrev->Add (BitCodeAbbrevOp (MACRO_OFFSET));
22942288  Abbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, 32 )); //  # of macros
22952289  Abbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed, 32 )); //  first ID
2296-   Abbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 32 ));   //  base offset
22972290  Abbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Blob));
22982291
22992292  unsigned  MacroOffsetAbbrev = Stream.EmitAbbrev (std::move (Abbrev));
23002293  {
23012294    RecordData::value_type Record[] = {MACRO_OFFSET, MacroOffsets.size (),
2302-                                        FirstMacroID - NUM_PREDEF_MACRO_IDS,
2303-                                        MacroOffsetsBase};
2295+                                        FirstMacroID - NUM_PREDEF_MACRO_IDS};
23042296    Stream.EmitRecordWithBlob (MacroOffsetAbbrev, Record, bytes (MacroOffsets));
23052297  }
23062298}
23072299
2308- void  ASTWriter::WritePreprocessorDetail (PreprocessingRecord &PPRec,
2309-                                         uint64_t  MacroOffsetsBase) {
2300+ void  ASTWriter::WritePreprocessorDetail (PreprocessingRecord &PPRec) {
23102301  if  (PPRec.local_begin () == PPRec.local_end ())
23112302    return ;
23122303
@@ -2343,10 +2334,8 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec,
23432334       (void )++E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) {
23442335    Record.clear ();
23452336
2346-     uint64_t  Offset = Stream.GetCurrentBitNo () - MacroOffsetsBase;
2347-     assert ((Offset >> 32 ) == 0  && " Preprocessed entity offset too large" 
23482337    PreprocessedEntityOffsets.push_back (
2349-         PPEntityOffset ((*E)->getSourceRange (), Offset ));
2338+         PPEntityOffset ((*E)->getSourceRange (), Stream. GetCurrentBitNo () ));
23502339
23512340    if  (auto  *MD = dyn_cast<MacroDefinitionRecord>(*E)) {
23522341      //  Record this macro definition's ID.
@@ -5155,7 +5144,7 @@ MacroID ASTWriter::getMacroID(MacroInfo *MI) {
51555144  return  MacroIDs[MI];
51565145}
51575146
5158- uint32_t  ASTWriter::getMacroDirectivesOffset (const  IdentifierInfo *Name) {
5147+ uint64_t  ASTWriter::getMacroDirectivesOffset (const  IdentifierInfo *Name) {
51595148  return  IdentMacroDirectivesOffsetMap.lookup (Name);
51605149}
51615150
0 commit comments