[cfe-commits] r134168 - in /cfe/trunk: include/clang/Basic/SourceManager.h lib/Lex/PPDirectives.cpp

Peter Collingbourne peter at pcc.me.uk
Thu Jun 30 09:41:04 PDT 2011


Author: pcc
Date: Thu Jun 30 11:41:03 2011
New Revision: 134168

URL: http://llvm.org/viewvc/llvm-project?rev=134168&view=rev
Log:
Replace an unreachable error path with an assert
(SourceManager::createFileID cannot return an invalid file ID).
Also update a comment to reflect this.

Modified:
    cfe/trunk/include/clang/Basic/SourceManager.h
    cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=134168&r1=134167&r2=134168&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Thu Jun 30 11:41:03 2011
@@ -500,8 +500,8 @@
   //===--------------------------------------------------------------------===//
 
   /// 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.
+  /// being #included from the specified IncludePosition.  This translates NULL
+  /// into standard input.
   /// PreallocateID should be non-zero to specify which pre-allocated,
   /// lazily computed source location is being filled in by this operation.
   FileID createFileID(const FileEntry *SourceFile, SourceLocation IncludePos,

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=134168&r1=134167&r2=134168&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Thu Jun 30 11:41:03 2011
@@ -1208,10 +1208,7 @@
   // Look up the file, create a File ID for it.
   FileID FID = SourceMgr.createFileID(File, FilenameTok.getLocation(),
                                       FileCharacter);
-  if (FID.isInvalid()) {
-    Diag(FilenameTok, diag::err_pp_file_not_found) << Filename;
-    return;
-  }
+  assert(!FID.isInvalid() && "Expected valid file ID");
 
   // Finally, if all is good, enter the new file!
   EnterSourceFile(FID, CurDir, FilenameTok.getLocation());





More information about the cfe-commits mailing list