]> granicus.if.org Git - clang/commitdiff
simplify the return of InitializePreprocessor to be bool instead of a fileid
authorChris Lattner <sabre@nondot.org>
Sat, 19 Apr 2008 23:25:44 +0000 (23:25 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 19 Apr 2008 23:25:44 +0000 (23:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49974 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/clang.cpp

index 5ff30a4c5ba7c80231e451e6beba9ddf0ea2acd9..144ab4e65ac8982af7b69c6420cdb97f6355c0cf 100644 (file)
@@ -583,12 +583,11 @@ static void AddImplicitInclude(std::vector<char> &Buf, const std::string &File){
 
 
 /// InitializePreprocessor - Initialize the preprocessor getting it and the
-/// environment ready to process a single file. This returns the file ID for the
-/// input file. If a failure happens, it returns 0.
+/// environment ready to process a single file. This returns true on error.
 ///
-static unsigned InitializePreprocessor(Preprocessor &PP,
-                                       bool InitializeSourceMgr, 
-                                       const std::string &InFile) {
+static bool InitializePreprocessor(Preprocessor &PP,
+                                   bool InitializeSourceMgr, 
+                                   const std::string &InFile) {
   FileManager &FileMgr = PP.getFileManager();
   
   // Figure out where to get and map in the main file.
@@ -600,14 +599,14 @@ static unsigned InitializePreprocessor(Preprocessor &PP,
       if (File) SourceMgr.createMainFileID(File, SourceLocation());
       if (SourceMgr.getMainFileID() == 0) {
         fprintf(stderr, "Error reading '%s'!\n",InFile.c_str());
-        return 0;
+        return true;
       }
     } else {
       llvm::MemoryBuffer *SB = llvm::MemoryBuffer::getSTDIN();
       if (SB) SourceMgr.createMainFileIDForMemBuffer(SB);
       if (SourceMgr.getMainFileID() == 0) {
         fprintf(stderr, "Error reading standard input!  Empty?\n");
-        return 0;
+        return true;
       }
     }
   }
@@ -635,7 +634,7 @@ static unsigned InitializePreprocessor(Preprocessor &PP,
   PP.setPredefines(&PredefineBuffer[0]);
   
   // Once we've read this, we're done.
-  return SourceMgr.getMainFileID();
+  return false;
 }
 
 //===----------------------------------------------------------------------===//
@@ -1043,7 +1042,7 @@ public:
     Preprocessor* PP = new Preprocessor(Diags, LangInfo, Target,
                                         SourceMgr, HeaderInfo);
     
-    if (!InitializePreprocessor(*PP, InitializeSourceMgr, InFile)) {
+    if (InitializePreprocessor(*PP, InitializeSourceMgr, InFile)) {
       delete PP;
       return NULL;
     }
@@ -1058,7 +1057,7 @@ public:
 // Basic Parser driver
 //===----------------------------------------------------------------------===//
 
-static void ParseFile(Preprocessor &PP, MinimalAction *PA){
+static void ParseFile(Preprocessor &PP, MinimalAction *PA) {
   Parser P(PP, *PA);
   PP.EnterMainSourceFile();