]> granicus.if.org Git - clang/commitdiff
Change Preprocessor::EnterSourceFile to make ErrorStr non-optional, clients should...
authorDaniel Dunbar <daniel@zuster.org>
Sun, 6 Dec 2009 09:19:12 +0000 (09:19 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sun, 6 Dec 2009 09:19:12 +0000 (09:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90700 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Lex/Preprocessor.h
lib/Lex/PPDirectives.cpp
lib/Lex/PPLexerChange.cpp
lib/Lex/Preprocessor.cpp

index cd202e58998bf2c754e7bd467127b5c91bc2bb05..50d1540741751fb7710470f055063e16a6eafe16 100644 (file)
@@ -335,7 +335,7 @@ public:
   /// 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
index 028593f39c7309f3dc84261d55a1051e15d04269..f734edfe23860c746dec66a5562b8d20db5d56cd 100644 (file)
@@ -1113,7 +1113,7 @@ void Preprocessor::HandleIncludeDirective(Token &IncludeTok,
 
   // 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;
 }
index 1580b87dac6afb989e4add78dcd856ec90419ef2..5cdfeafa33cbd735c4aae44e11972ee663843ce8 100644 (file)
@@ -65,7 +65,7 @@ PreprocessorLexer *Preprocessor::getCurrentFileLexer() const {
 /// 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;
 
@@ -81,8 +81,8 @@ bool Preprocessor::EnterSourceFile(FileID FID, const DirectoryLookup *CurDir,
   
   // 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);
index 229826af5dd819d9b119b7cf21f7467f1f6a986a..49a25f25746918b689e506bb531e5bc3adb26be6 100644 (file)
@@ -438,7 +438,9 @@ void Preprocessor::EnterMainSourceFile() {
   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.
@@ -464,7 +466,8 @@ void Preprocessor::EnterMainSourceFile() {
   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!");
 }