void SourceManager::Emit(llvm::Serializer& S) const {
S.EnterBlock();
S.EmitPtr(this);
+ S.EmitInt(MainFileID);
// Emit: FileInfos. Just emit the file name.
S.EnterBlock();
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.
std::vector<char> PredefineBuffer;
unsigned MainFileID = InitializePreprocessor(PP, InFile, PredefineBuffer);
- if (!MainFileID) continue;
+ if (!MainFileID)
+ continue;
+
+ SourceMgr.setMainFileID(MainFileID);
ProcessInputFile(PP, MainFileID, InFile, *DiagClient);
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() {
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.