]> granicus.if.org Git - clang/commitdiff
Replace an unreachable error path with an assert
authorPeter Collingbourne <peter@pcc.me.uk>
Thu, 30 Jun 2011 16:41:03 +0000 (16:41 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Thu, 30 Jun 2011 16:41:03 +0000 (16:41 +0000)
(SourceManager::createFileID cannot return an invalid file ID).
Also update a comment to reflect this.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134168 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/SourceManager.h
lib/Lex/PPDirectives.cpp

index 4227add5673fc6ab5ff0f84b0fe97178d3f0b302..f2a8bf351551a85dc34c5d33525e85c25bf9fb42 100644 (file)
@@ -500,8 +500,8 @@ public:
   //===--------------------------------------------------------------------===//
 
   /// 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,
index b6925b70b70d909cc27cea92184963355a1a4616..f74aad3c8164c7b4faa4e10e2b429c768289c9b4 100644 (file)
@@ -1208,10 +1208,7 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,
   // 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());