/// start lexing tokens from it instead of the current buffer. Return true
/// and fill in ErrorStr with the error information on failure.
bool EnterSourceFile(FileID CurFileID, const DirectoryLookup *Dir,
- std::string *ErrorStr = 0);
+ std::string &ErrorStr);
/// EnterMacro - Add a Macro to the top of the include stack and start lexing
/// tokens from it instead of the current buffer. Args specifies the
// Finally, if all is good, enter the new file!
std::string ErrorStr;
- if (EnterSourceFile(FID, CurDir, &ErrorStr))
+ if (EnterSourceFile(FID, CurDir, ErrorStr))
Diag(FilenameTok, diag::err_pp_error_opening_file)
<< std::string(SourceMgr.getFileEntryForID(FID)->getName()) << ErrorStr;
}
/// EnterSourceFile - Add a source file to the top of the include stack and
/// start lexing tokens from it instead of the current buffer.
bool Preprocessor::EnterSourceFile(FileID FID, const DirectoryLookup *CurDir,
- std::string *ErrorStr) {
+ std::string &ErrorStr) {
assert(CurTokenLexer == 0 && "Cannot #include a file inside a macro!");
++NumEnteredSourceFiles;
// Get the MemoryBuffer for this FID, if it fails, we fail.
const llvm::MemoryBuffer *InputFile =
- getSourceManager().getBuffer(FID, ErrorStr);
if (InputFile == 0)
+ getSourceManager().getBuffer(FID, &ErrorStr);
return true;
EnterSourceFileWithLexer(new Lexer(FID, InputFile, *this), CurDir);
FileID MainFileID = SourceMgr.getMainFileID();
// Enter the main file source buffer.
- EnterSourceFile(MainFileID, 0);
+ std::string ErrorStr;
+ bool Res = EnterSourceFile(MainFileID, 0, ErrorStr);
+ assert(!Res && "Entering main file should not fail!");
// Tell the header info that the main file was entered. If the file is later
// #imported, it won't be re-entered.
assert(!FID.isInvalid() && "Could not create FileID for predefines?");
// Start parsing the predefines.
- EnterSourceFile(FID, 0);
+ Res = EnterSourceFile(FID, 0, ErrorStr);
+ assert(!Res && "Entering predefines should not fail!");
}