[cfe-commits] r140610 - in /cfe/trunk: include/clang/Basic/SourceManager.h lib/Basic/SourceManager.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Tue Sep 27 10:22:25 PDT 2011
Author: akirtzidis
Date: Tue Sep 27 12:22:25 2011
New Revision: 140610
URL: http://llvm.org/viewvc/llvm-project?rev=140610&view=rev
Log:
Break SourceManager::translateFileLineCol into translateFile, no functionality change.
Modified:
cfe/trunk/include/clang/Basic/SourceManager.h
cfe/trunk/lib/Basic/SourceManager.cpp
Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=140610&r1=140609&r2=140610&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Tue Sep 27 12:22:25 2011
@@ -1110,6 +1110,12 @@
SourceLocation translateFileLineCol(const FileEntry *SourceFile,
unsigned Line, unsigned Col) const;
+ /// \brief Get the FileID for the given file.
+ ///
+ /// If the source file is included multiple times, the FileID will be the
+ /// first inclusion.
+ FileID translateFile(const FileEntry *SourceFile) const;
+
/// \brief Get the source location in \arg FID for the given line:col.
/// Returns null location if \arg FID is not a file SLocEntry.
SourceLocation translateLineCol(FileID FID,
Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=140610&r1=140609&r2=140610&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Tue Sep 27 12:22:25 2011
@@ -1333,6 +1333,17 @@
assert(SourceFile && "Null source file!");
assert(Line && Col && "Line and column should start from 1!");
+ FileID FirstFID = translateFile(SourceFile);
+ return translateLineCol(FirstFID, Line, Col);
+}
+
+/// \brief Get the FileID for the given file.
+///
+/// If the source file is included multiple times, the FileID will be the
+/// first inclusion.
+FileID SourceManager::translateFile(const FileEntry *SourceFile) const {
+ assert(SourceFile && "Null source file!");
+
// Find the first file ID that corresponds to the given file.
FileID FirstFID;
@@ -1344,7 +1355,7 @@
bool Invalid = false;
const SLocEntry &MainSLoc = getSLocEntry(MainFileID, &Invalid);
if (Invalid)
- return SourceLocation();
+ return FileID();
if (MainSLoc.isFile()) {
const ContentCache *MainContentCache
@@ -1381,7 +1392,7 @@
bool Invalid = false;
const SLocEntry &SLoc = getLocalSLocEntry(I, &Invalid);
if (Invalid)
- return SourceLocation();
+ return FileID();
if (SLoc.isFile() &&
SLoc.getFile().getContentCache() &&
@@ -1418,7 +1429,7 @@
IFileID.ID = I;
const SLocEntry &SLoc = getSLocEntry(IFileID, &Invalid);
if (Invalid)
- return SourceLocation();
+ return FileID();
if (SLoc.isFile()) {
const ContentCache *FileContentCache
@@ -1437,8 +1448,8 @@
}
}
}
-
- return translateLineCol(FirstFID, Line, Col);
+
+ return FirstFID;
}
/// \brief Get the source location in \arg FID for the given line:col.
More information about the cfe-commits
mailing list