[cfe-commits] r45225 - in /cfe/trunk: Basic/SourceManager.cpp Driver/clang.cpp include/clang/Basic/SourceManager.h
Ted Kremenek
kremenek at apple.com
Wed Dec 19 14:29:55 PST 2007
Author: kremenek
Date: Wed Dec 19 16:29:55 2007
New Revision: 45225
URL: http://llvm.org/viewvc/llvm-project?rev=45225&view=rev
Log:
Added storage of the FileID of the the main source file of a translation unit
in SourceManager.
Modified:
cfe/trunk/Basic/SourceManager.cpp
cfe/trunk/Driver/clang.cpp
cfe/trunk/include/clang/Basic/SourceManager.h
Modified: cfe/trunk/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Basic/SourceManager.cpp?rev=45225&r1=45224&r2=45225&view=diff
==============================================================================
--- cfe/trunk/Basic/SourceManager.cpp (original)
+++ cfe/trunk/Basic/SourceManager.cpp Wed Dec 19 16:29:55 2007
@@ -508,6 +508,7 @@
void SourceManager::Emit(llvm::Serializer& S) const {
S.EnterBlock();
S.EmitPtr(this);
+ S.EmitInt(MainFileID);
// Emit: FileInfos. Just emit the file name.
S.EnterBlock();
@@ -541,6 +542,9 @@
SourceManager *M = new SourceManager();
D.RegisterPtr(M);
+ // Read: the FileID of the main source file of the translation unit.
+ M->MainFileID = D.ReadInt();
+
std::vector<char> Buf;
{ // Read: FileInfos.
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=45225&r1=45224&r2=45225&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Wed Dec 19 16:29:55 2007
@@ -1175,7 +1175,10 @@
std::vector<char> PredefineBuffer;
unsigned MainFileID = InitializePreprocessor(PP, InFile, PredefineBuffer);
- if (!MainFileID) continue;
+ if (!MainFileID)
+ continue;
+
+ SourceMgr.setMainFileID(MainFileID);
ProcessInputFile(PP, MainFileID, InFile, *DiagClient);
Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=45225&r1=45224&r2=45225&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Wed Dec 19 16:29:55 2007
@@ -220,8 +220,11 @@
unsigned LastLineNoFilePos;
unsigned LastLineNoResult;
+ /// MainFileID - The file ID for the main source file of the translation unit.
+ unsigned MainFileID;
+
public:
- SourceManager() : LastLineNoFileIDQuery(~0U) {}
+ SourceManager() : LastLineNoFileIDQuery(~0U), MainFileID(0) {}
~SourceManager() {}
void clearIDTables() {
@@ -231,6 +234,12 @@
LastLineNoContentCache = 0;
}
+ /// getMainFileID - Returns the FileID of the main source file.
+ unsigned getMainFileID() const { return MainFileID; }
+
+ /// setMainFileID - Set the FileID of the main source file.
+ void setMainFileID(unsigned ID) { MainFileID = ID; }
+
/// createFileID - Create a new FileID that represents the specified file
/// being #included from the specified IncludePosition. This returns 0 on
/// error and translates NULL into standard input.
More information about the cfe-commits
mailing list