[cfe-commits] r84287 - in /cfe/trunk: include/clang/Basic/SourceManager.h lib/AST/StmtPrinter.cpp lib/Frontend/PCHWriter.cpp
Douglas Gregor
dgregor at apple.com
Fri Oct 16 15:46:29 PDT 2009
Author: dgregor
Date: Fri Oct 16 17:46:09 2009
New Revision: 84287
URL: http://llvm.org/viewvc/llvm-project?rev=84287&view=rev
Log:
While writing source-location entries to a PCH file, go through an
interface that can load those source-location entries on demand (from
another PCH file).
Modified:
cfe/trunk/include/clang/Basic/SourceManager.h
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/Frontend/PCHWriter.cpp
Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=84287&r1=84286&r2=84287&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Fri Oct 16 17:46:09 2009
@@ -685,26 +685,19 @@
///
void PrintStats() const;
- // Iteration over the source location entry table.
- typedef std::vector<SrcMgr::SLocEntry>::const_iterator sloc_entry_iterator;
-
- sloc_entry_iterator sloc_entry_begin() const {
- return SLocEntryTable.begin();
- }
-
- sloc_entry_iterator sloc_entry_end() const {
- return SLocEntryTable.end();
- }
-
unsigned sloc_entry_size() const { return SLocEntryTable.size(); }
- const SrcMgr::SLocEntry &getSLocEntry(FileID FID) const {
- assert(FID.ID < SLocEntryTable.size() && "Invalid id");
+ const SrcMgr::SLocEntry &getSLocEntry(unsigned ID) const {
+ assert(ID < SLocEntryTable.size() && "Invalid id");
if (ExternalSLocEntries &&
- FID.ID < SLocEntryLoaded.size() &&
- !SLocEntryLoaded[FID.ID])
- ExternalSLocEntries->ReadSLocEntry(FID.ID);
- return SLocEntryTable[FID.ID];
+ ID < SLocEntryLoaded.size() &&
+ !SLocEntryLoaded[ID])
+ ExternalSLocEntries->ReadSLocEntry(ID);
+ return SLocEntryTable[ID];
+ }
+
+ const SrcMgr::SLocEntry &getSLocEntry(FileID FID) const {
+ return getSLocEntry(FID.ID);
}
unsigned getNextOffset() const { return NextOffset; }
Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=84287&r1=84286&r2=84287&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Fri Oct 16 17:46:09 2009
@@ -1289,7 +1289,7 @@
return;
}
- if (Policy.Dump) {
+ if (Policy.Dump && &Context) {
dump(Context.getSourceManager());
return;
}
Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=84287&r1=84286&r2=84287&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Fri Oct 16 17:46:09 2009
@@ -928,10 +928,10 @@
std::vector<uint32_t> SLocEntryOffsets;
RecordData PreloadSLocs;
SLocEntryOffsets.reserve(SourceMgr.sloc_entry_size() - 1);
- for (SourceManager::sloc_entry_iterator
- SLoc = SourceMgr.sloc_entry_begin() + 1,
- SLocEnd = SourceMgr.sloc_entry_end();
- SLoc != SLocEnd; ++SLoc) {
+ for (unsigned I = 1, N = SourceMgr.sloc_entry_size(); I != N; ++I) {
+ // Get this source location entry.
+ const SrcMgr::SLocEntry *SLoc = &SourceMgr.getSLocEntry(I);
+
// Record the offset of this source-location entry.
SLocEntryOffsets.push_back(Stream.GetCurrentBitNo());
@@ -1006,9 +1006,8 @@
// Compute the token length for this macro expansion.
unsigned NextOffset = SourceMgr.getNextOffset();
- SourceManager::sloc_entry_iterator NextSLoc = SLoc;
- if (++NextSLoc != SLocEnd)
- NextOffset = NextSLoc->getOffset();
+ if (I + 1 != N)
+ NextOffset = SourceMgr.getSLocEntry(I + 1).getOffset();
Record.push_back(NextOffset - SLoc->getOffset() - 1);
Stream.EmitRecordWithAbbrev(SLocInstantiationAbbrv, Record);
}
More information about the cfe-commits
mailing list