@@ -1893,7 +1893,6 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
1893
1893
// Write out the source location entry table. We skip the first
1894
1894
// entry, which is always the same dummy entry.
1895
1895
std::vector<uint32_t > SLocEntryOffsets;
1896
- uint64_t SLocEntryOffsetsBase = Stream.GetCurrentBitNo ();
1897
1896
RecordData PreloadSLocs;
1898
1897
SLocEntryOffsets.reserve (SourceMgr.local_sloc_entry_size () - 1 );
1899
1898
for (unsigned I = 1 , N = SourceMgr.local_sloc_entry_size ();
@@ -1904,9 +1903,7 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
1904
1903
assert (&SourceMgr.getSLocEntry (FID) == SLoc);
1905
1904
1906
1905
// 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 ());
1910
1907
1911
1908
// Figure out which record code to use.
1912
1909
unsigned Code;
@@ -2014,14 +2011,12 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
2014
2011
Abbrev->Add (BitCodeAbbrevOp (SOURCE_LOCATION_OFFSETS));
2015
2012
Abbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 16 )); // # of slocs
2016
2013
Abbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 16 )); // total size
2017
- Abbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 32 )); // base offset
2018
2014
Abbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Blob)); // offsets
2019
2015
unsigned SLocOffsetsAbbrev = Stream.EmitAbbrev (std::move (Abbrev));
2020
2016
{
2021
2017
RecordData::value_type Record[] = {
2022
2018
SOURCE_LOCATION_OFFSETS, SLocEntryOffsets.size (),
2023
- SourceMgr.getNextLocalOffset () - 1 /* skip dummy */ ,
2024
- SLocEntryOffsetsBase};
2019
+ SourceMgr.getNextLocalOffset () - 1 /* skip dummy */ };
2025
2020
Stream.EmitRecordWithBlob (SLocOffsetsAbbrev, Record,
2026
2021
bytes (SLocEntryOffsets));
2027
2022
}
@@ -2098,11 +2093,9 @@ static bool shouldIgnoreMacro(MacroDirective *MD, bool IsModule,
2098
2093
// / Writes the block containing the serialized form of the
2099
2094
// / preprocessor.
2100
2095
void ASTWriter::WritePreprocessor (const Preprocessor &PP, bool IsModule) {
2101
- uint64_t MacroOffsetsBase = Stream.GetCurrentBitNo ();
2102
-
2103
2096
PreprocessingRecord *PPRec = PP.getPreprocessingRecord ();
2104
2097
if (PPRec)
2105
- WritePreprocessorDetail (*PPRec, MacroOffsetsBase );
2098
+ WritePreprocessorDetail (*PPRec);
2106
2099
2107
2100
RecordData Record;
2108
2101
RecordData ModuleMacroRecord;
@@ -2163,8 +2156,7 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
2163
2156
// identifier they belong to.
2164
2157
for (const IdentifierInfo *Name : MacroIdentifiers) {
2165
2158
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 ();
2168
2160
2169
2161
// Emit the macro directives in reverse source order.
2170
2162
for (; MD; MD = MD->getPrevious ()) {
@@ -2237,12 +2229,14 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
2237
2229
2238
2230
// Record the local offset of this macro.
2239
2231
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 );
2242
2237
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
+ }
2246
2240
2247
2241
AddIdentifierRef (Name, Record);
2248
2242
AddSourceLocation (MI->getDefinitionLoc (), Record);
@@ -2293,20 +2287,17 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
2293
2287
Abbrev->Add (BitCodeAbbrevOp (MACRO_OFFSET));
2294
2288
Abbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed , 32 )); // # of macros
2295
2289
Abbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Fixed , 32 )); // first ID
2296
- Abbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 32 )); // base offset
2297
2290
Abbrev->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::Blob));
2298
2291
2299
2292
unsigned MacroOffsetAbbrev = Stream.EmitAbbrev (std::move (Abbrev));
2300
2293
{
2301
2294
RecordData::value_type Record[] = {MACRO_OFFSET, MacroOffsets.size (),
2302
- FirstMacroID - NUM_PREDEF_MACRO_IDS,
2303
- MacroOffsetsBase};
2295
+ FirstMacroID - NUM_PREDEF_MACRO_IDS};
2304
2296
Stream.EmitRecordWithBlob (MacroOffsetAbbrev, Record, bytes (MacroOffsets));
2305
2297
}
2306
2298
}
2307
2299
2308
- void ASTWriter::WritePreprocessorDetail (PreprocessingRecord &PPRec,
2309
- uint64_t MacroOffsetsBase) {
2300
+ void ASTWriter::WritePreprocessorDetail (PreprocessingRecord &PPRec) {
2310
2301
if (PPRec.local_begin () == PPRec.local_end ())
2311
2302
return ;
2312
2303
@@ -2343,10 +2334,8 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec,
2343
2334
(void )++E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) {
2344
2335
Record.clear ();
2345
2336
2346
- uint64_t Offset = Stream.GetCurrentBitNo () - MacroOffsetsBase;
2347
- assert ((Offset >> 32 ) == 0 && " Preprocessed entity offset too large" );
2348
2337
PreprocessedEntityOffsets.push_back (
2349
- PPEntityOffset ((*E)->getSourceRange (), Offset ));
2338
+ PPEntityOffset ((*E)->getSourceRange (), Stream. GetCurrentBitNo () ));
2350
2339
2351
2340
if (auto *MD = dyn_cast<MacroDefinitionRecord>(*E)) {
2352
2341
// Record this macro definition's ID.
@@ -5155,7 +5144,7 @@ MacroID ASTWriter::getMacroID(MacroInfo *MI) {
5155
5144
return MacroIDs[MI];
5156
5145
}
5157
5146
5158
- uint32_t ASTWriter::getMacroDirectivesOffset (const IdentifierInfo *Name) {
5147
+ uint64_t ASTWriter::getMacroDirectivesOffset (const IdentifierInfo *Name) {
5159
5148
return IdentMacroDirectivesOffsetMap.lookup (Name);
5160
5149
}
5161
5150
0 commit comments