summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/SourceManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r--clang/lib/Basic/SourceManager.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp
index 712cbb0d0ea..e62cef7ec55 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -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
OpenPOWER on IntegriCloud