|
@@ -1430,6 +1430,7 @@ PresumedLoc SourceManager::getPresumedLoc(SourceLocation Loc,
|
|
|
// To get the source name, first consult the FileEntry (if one exists)
|
|
|
// before the MemBuffer as this will avoid unnecessarily paging in the
|
|
|
// MemBuffer.
|
|
|
+ FileID FID = LocInfo.first;
|
|
|
StringRef Filename;
|
|
|
if (C->OrigEntry)
|
|
|
Filename = C->OrigEntry->getName();
|
|
@@ -1453,8 +1454,12 @@ PresumedLoc SourceManager::getPresumedLoc(SourceLocation Loc,
|
|
|
if (const LineEntry *Entry =
|
|
|
LineTable->FindNearestLineEntry(LocInfo.first, LocInfo.second)) {
|
|
|
// If the LineEntry indicates a filename, use it.
|
|
|
- if (Entry->FilenameID != -1)
|
|
|
+ if (Entry->FilenameID != -1) {
|
|
|
Filename = LineTable->getFilename(Entry->FilenameID);
|
|
|
+ // The contents of files referenced by #line are not in the
|
|
|
+ // SourceManager
|
|
|
+ FID = FileID::get(0);
|
|
|
+ }
|
|
|
|
|
|
// Use the line number specified by the LineEntry. This line number may
|
|
|
// be multiple lines down from the line entry. Add the difference in
|
|
@@ -1473,7 +1478,7 @@ PresumedLoc SourceManager::getPresumedLoc(SourceLocation Loc,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return PresumedLoc(Filename.data(), LineNo, ColNo, IncludeLoc);
|
|
|
+ return PresumedLoc(Filename.data(), FID, LineNo, ColNo, IncludeLoc);
|
|
|
}
|
|
|
|
|
|
/// Returns whether the PresumedLoc for a given SourceLocation is
|