Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/Serialization/ASTWriter.cpp
Show First 20 Lines • Show All 2,041 Lines • ▼ Show 20 Lines | for (unsigned I = 1, N = SourceMgr.local_sloc_entry_size(); | ||||
// Get this source location entry. | // Get this source location entry. | ||||
const SrcMgr::SLocEntry *SLoc = &SourceMgr.getLocalSLocEntry(I); | const SrcMgr::SLocEntry *SLoc = &SourceMgr.getLocalSLocEntry(I); | ||||
FileID FID = FileID::get(I); | FileID FID = FileID::get(I); | ||||
assert(&SourceMgr.getSLocEntry(FID) == SLoc); | assert(&SourceMgr.getSLocEntry(FID) == SLoc); | ||||
// Record the offset of this source-location entry. | // Record the offset of this source-location entry. | ||||
uint64_t Offset = Stream.GetCurrentBitNo() - SLocEntryOffsetsBase; | uint64_t Offset = Stream.GetCurrentBitNo() - SLocEntryOffsetsBase; | ||||
assert((Offset >> 32) == 0 && "SLocEntry offset too large"); | assert((Offset >> 32) == 0 && "SLocEntry offset too large"); | ||||
SLocEntryOffsets.push_back(Offset); | |||||
// Figure out which record code to use. | // Figure out which record code to use. | ||||
unsigned Code; | unsigned Code; | ||||
if (SLoc->isFile()) { | if (SLoc->isFile()) { | ||||
const SrcMgr::ContentCache *Cache = &SLoc->getFile().getContentCache(); | const SrcMgr::ContentCache *Cache = &SLoc->getFile().getContentCache(); | ||||
if (Cache->OrigEntry) { | if (Cache->OrigEntry) { | ||||
Code = SM_SLOC_FILE_ENTRY; | Code = SM_SLOC_FILE_ENTRY; | ||||
} else | } else | ||||
Code = SM_SLOC_BUFFER_ENTRY; | Code = SM_SLOC_BUFFER_ENTRY; | ||||
} else | } else | ||||
Code = SM_SLOC_EXPANSION_ENTRY; | Code = SM_SLOC_EXPANSION_ENTRY; | ||||
Record.clear(); | Record.clear(); | ||||
Record.push_back(Code); | Record.push_back(Code); | ||||
// Starting offset of this entry within this module, so skip the dummy. | |||||
Record.push_back(getAdjustedOffset(SLoc->getOffset()) - 2); | |||||
if (SLoc->isFile()) { | if (SLoc->isFile()) { | ||||
const SrcMgr::FileInfo &File = SLoc->getFile(); | const SrcMgr::FileInfo &File = SLoc->getFile(); | ||||
const SrcMgr::ContentCache *Content = &File.getContentCache(); | const SrcMgr::ContentCache *Content = &File.getContentCache(); | ||||
if (Content->OrigEntry && !SkippedModuleMaps.empty() && | if (Content->OrigEntry && !SkippedModuleMaps.empty() && | ||||
SkippedModuleMaps.find(Content->OrigEntry) != | SkippedModuleMaps.find(Content->OrigEntry) != | ||||
SkippedModuleMaps.end()) { | SkippedModuleMaps.end()) { | ||||
// Do not emit files that were not listed as inputs. | // Do not emit files that were not listed as inputs. | ||||
continue; | continue; | ||||
} | } | ||||
SLocEntryOffsets.push_back(Offset); | |||||
// Starting offset of this entry within this module, so skip the dummy. | |||||
Record.push_back(getAdjustedOffset(SLoc->getOffset()) - 2); | |||||
AddSourceLocation(File.getIncludeLoc(), Record); | AddSourceLocation(File.getIncludeLoc(), Record); | ||||
Record.push_back(File.getFileCharacteristic()); // FIXME: stable encoding | Record.push_back(File.getFileCharacteristic()); // FIXME: stable encoding | ||||
Record.push_back(File.hasLineDirectives()); | Record.push_back(File.hasLineDirectives()); | ||||
bool EmitBlob = false; | bool EmitBlob = false; | ||||
if (Content->OrigEntry) { | if (Content->OrigEntry) { | ||||
assert(Content->OrigEntry == Content->ContentsEntry && | assert(Content->OrigEntry == Content->ContentsEntry && | ||||
"Writing to AST an overridden file is not supported"); | "Writing to AST an overridden file is not supported"); | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | if (SLoc->isFile()) { | ||||
Buffer = llvm::MemoryBufferRef("<<<INVALID BUFFER>>>", ""); | Buffer = llvm::MemoryBufferRef("<<<INVALID BUFFER>>>", ""); | ||||
StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1); | StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1); | ||||
emitBlob(Stream, Blob, SLocBufferBlobCompressedAbbrv, | emitBlob(Stream, Blob, SLocBufferBlobCompressedAbbrv, | ||||
SLocBufferBlobAbbrv); | SLocBufferBlobAbbrv); | ||||
} | } | ||||
} else { | } else { | ||||
// The source location entry is a macro expansion. | // The source location entry is a macro expansion. | ||||
const SrcMgr::ExpansionInfo &Expansion = SLoc->getExpansion(); | const SrcMgr::ExpansionInfo &Expansion = SLoc->getExpansion(); | ||||
SLocEntryOffsets.push_back(Offset); | |||||
// Starting offset of this entry within this module, so skip the dummy. | |||||
Record.push_back(getAdjustedOffset(SLoc->getOffset()) - 2); | |||||
LocSeq::State Seq; | LocSeq::State Seq; | ||||
AddSourceLocation(Expansion.getSpellingLoc(), Record, Seq); | AddSourceLocation(Expansion.getSpellingLoc(), Record, Seq); | ||||
AddSourceLocation(Expansion.getExpansionLocStart(), Record, Seq); | AddSourceLocation(Expansion.getExpansionLocStart(), Record, Seq); | ||||
AddSourceLocation(Expansion.isMacroArgExpansion() | AddSourceLocation(Expansion.isMacroArgExpansion() | ||||
? SourceLocation() | ? SourceLocation() | ||||
: Expansion.getExpansionLocEnd(), | : Expansion.getExpansionLocEnd(), | ||||
Record, Seq); | Record, Seq); | ||||
Record.push_back(Expansion.isExpansionTokenRange()); | Record.push_back(Expansion.isExpansionTokenRange()); | ||||
▲ Show 20 Lines • Show All 4,841 Lines • Show Last 20 Lines |