[cfe-commits] r158211 - in /cfe/trunk: include/clang/Basic/SourceManagerInternals.h lib/Basic/SourceManager.cpp lib/Serialization/ASTReader.cpp lib/Serialization/ASTWriter.cpp
Douglas Gregor
dgregor at apple.com
Fri Jun 8 09:40:28 PDT 2012
Author: dgregor
Date: Fri Jun 8 11:40:28 2012
New Revision: 158211
URL: http://llvm.org/viewvc/llvm-project?rev=158211&view=rev
Log:
Switch LineTableInfo to use FileID instead of int for file references,
from Tom Honermann!
Modified:
cfe/trunk/include/clang/Basic/SourceManagerInternals.h
cfe/trunk/lib/Basic/SourceManager.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
Modified: cfe/trunk/include/clang/Basic/SourceManagerInternals.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManagerInternals.h?rev=158211&r1=158210&r2=158211&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManagerInternals.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManagerInternals.h Fri Jun 8 11:40:28 2012
@@ -15,6 +15,7 @@
#ifndef LLVM_CLANG_SOURCEMANAGER_INTERNALS_H
#define LLVM_CLANG_SOURCEMANAGER_INTERNALS_H
+#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "llvm/ADT/StringMap.h"
#include <map>
@@ -84,7 +85,7 @@
/// LineEntries - This is a map from FileIDs to a list of line entries (sorted
/// by the offset they occur in the file.
- std::map<int, std::vector<LineEntry> > LineEntries;
+ std::map<FileID, std::vector<LineEntry> > LineEntries;
public:
LineTableInfo() {
}
@@ -104,25 +105,25 @@
}
unsigned getNumFilenames() const { return FilenamesByID.size(); }
- void AddLineNote(int FID, unsigned Offset,
+ void AddLineNote(FileID FID, unsigned Offset,
unsigned LineNo, int FilenameID);
- void AddLineNote(int FID, unsigned Offset,
+ void AddLineNote(FileID FID, unsigned Offset,
unsigned LineNo, int FilenameID,
unsigned EntryExit, SrcMgr::CharacteristicKind FileKind);
/// FindNearestLineEntry - Find the line entry nearest to FID that is before
/// it. If there is no line entry before Offset in FID, return null.
- const LineEntry *FindNearestLineEntry(int FID, unsigned Offset);
+ const LineEntry *FindNearestLineEntry(FileID FID, unsigned Offset);
// Low-level access
- typedef std::map<int, std::vector<LineEntry> >::iterator iterator;
+ typedef std::map<FileID, std::vector<LineEntry> >::iterator iterator;
iterator begin() { return LineEntries.begin(); }
iterator end() { return LineEntries.end(); }
/// \brief Add a new line entry that has already been encoded into
/// the internal representation of the line table.
- void AddEntry(int FID, const std::vector<LineEntry> &Entries);
+ void AddEntry(FileID FID, const std::vector<LineEntry> &Entries);
};
} // end namespace clang
Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=158211&r1=158210&r2=158211&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Fri Jun 8 11:40:28 2012
@@ -191,7 +191,7 @@
/// AddLineNote - Add a line note to the line table that indicates that there
/// is a #line at the specified FID/Offset location which changes the presumed
/// location to LineNo/FilenameID.
-void LineTableInfo::AddLineNote(int FID, unsigned Offset,
+void LineTableInfo::AddLineNote(FileID FID, unsigned Offset,
unsigned LineNo, int FilenameID) {
std::vector<LineEntry> &Entries = LineEntries[FID];
@@ -222,7 +222,7 @@
/// presumed #include stack. If it is 1, this is a file entry, if it is 2 then
/// this is a file exit. FileKind specifies whether this is a system header or
/// extern C system header.
-void LineTableInfo::AddLineNote(int FID, unsigned Offset,
+void LineTableInfo::AddLineNote(FileID FID, unsigned Offset,
unsigned LineNo, int FilenameID,
unsigned EntryExit,
SrcMgr::CharacteristicKind FileKind) {
@@ -256,7 +256,7 @@
/// FindNearestLineEntry - Find the line entry nearest to FID that is before
/// it. If there is no line entry before Offset in FID, return null.
-const LineEntry *LineTableInfo::FindNearestLineEntry(int FID,
+const LineEntry *LineTableInfo::FindNearestLineEntry(FileID FID,
unsigned Offset) {
const std::vector<LineEntry> &Entries = LineEntries[FID];
assert(!Entries.empty() && "No #line entries for this FID after all!");
@@ -275,7 +275,7 @@
/// \brief Add a new line entry that has already been encoded into
/// the internal representation of the line table.
-void LineTableInfo::AddEntry(int FID,
+void LineTableInfo::AddEntry(FileID FID,
const std::vector<LineEntry> &Entries) {
LineEntries[FID] = Entries;
}
@@ -308,7 +308,7 @@
if (LineTable == 0)
LineTable = new LineTableInfo();
- LineTable->AddLineNote(LocInfo.first.ID, LocInfo.second, LineNo, FilenameID);
+ LineTable->AddLineNote(LocInfo.first, LocInfo.second, LineNo, FilenameID);
}
/// AddLineNote - Add a GNU line marker to the line table.
@@ -353,7 +353,7 @@
else if (IsFileExit)
EntryExit = 2;
- LineTable->AddLineNote(LocInfo.first.ID, LocInfo.second, LineNo, FilenameID,
+ LineTable->AddLineNote(LocInfo.first, LocInfo.second, LineNo, FilenameID,
EntryExit, FileKind);
}
@@ -1315,7 +1315,7 @@
assert(LineTable && "Can't have linetable entries without a LineTable!");
// See if there is a #line directive before the location.
const LineEntry *Entry =
- LineTable->FindNearestLineEntry(LocInfo.first.ID, LocInfo.second);
+ LineTable->FindNearestLineEntry(LocInfo.first, LocInfo.second);
// If this is before the first line marker, use the file characteristic.
if (!Entry)
@@ -1380,7 +1380,7 @@
assert(LineTable && "Can't have linetable entries without a LineTable!");
// See if there is a #line directive before this. If so, get it.
if (const LineEntry *Entry =
- LineTable->FindNearestLineEntry(LocInfo.first.ID, LocInfo.second)) {
+ LineTable->FindNearestLineEntry(LocInfo.first, LocInfo.second)) {
// If the LineEntry indicates a filename, use it.
if (Entry->FilenameID != -1)
Filename = LineTable->getFilename(Entry->FilenameID);
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=158211&r1=158210&r2=158211&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Jun 8 11:40:28 2012
@@ -829,7 +829,7 @@
Entries.push_back(LineEntry::get(FileOffset, LineNo, FilenameID,
FileKind, IncludeOffset));
}
- LineTable.AddEntry(FID, Entries);
+ LineTable.AddEntry(FileID::get(FID), Entries);
}
return false;
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=158211&r1=158210&r2=158211&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Fri Jun 8 11:40:28 2012
@@ -1604,11 +1604,11 @@
for (LineTableInfo::iterator L = LineTable.begin(), LEnd = LineTable.end();
L != LEnd; ++L) {
// Only emit entries for local files.
- if (L->first < 0)
+ if (L->first.ID < 0)
continue;
// Emit the file ID
- Record.push_back(L->first);
+ Record.push_back(L->first.ID);
// Emit the line entries
Record.push_back(L->second.size());
More information about the cfe-commits
mailing list