[cfe-commits] r90700 - in /cfe/trunk: include/clang/Lex/Preprocessor.h lib/Lex/PPDirectives.cpp lib/Lex/PPLexerChange.cpp lib/Lex/Preprocessor.cpp

Daniel Dunbar daniel at zuster.org
Sun Dec 6 01:19:13 PST 2009


Author: ddunbar
Date: Sun Dec  6 03:19:12 2009
New Revision: 90700

URL: http://llvm.org/viewvc/llvm-project?rev=90700&view=rev
Log:
Change Preprocessor::EnterSourceFile to make ErrorStr non-optional, clients should be forced to deal with error conditions.

Modified:
    cfe/trunk/include/clang/Lex/Preprocessor.h
    cfe/trunk/lib/Lex/PPDirectives.cpp
    cfe/trunk/lib/Lex/PPLexerChange.cpp
    cfe/trunk/lib/Lex/Preprocessor.cpp

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=90700&r1=90699&r2=90700&view=diff

==============================================================================
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Sun Dec  6 03:19:12 2009
@@ -335,7 +335,7 @@
   /// 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

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=90700&r1=90699&r2=90700&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Sun Dec  6 03:19:12 2009
@@ -1113,7 +1113,7 @@
 
   // 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;
 }

Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=90700&r1=90699&r2=90700&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
+++ cfe/trunk/lib/Lex/PPLexerChange.cpp Sun Dec  6 03:19:12 2009
@@ -65,7 +65,7 @@
 /// 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 @@
   
   // 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);

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=90700&r1=90699&r2=90700&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Sun Dec  6 03:19:12 2009
@@ -438,7 +438,9 @@
   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 @@
   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!");
 }
 
 





More information about the cfe-commits mailing list