[cfe-commits] r39012 - in /cfe/cfe/trunk: Driver/clang.cpp Lex/HeaderSearch.cpp Lex/Pragma.cpp Lex/Preprocessor.cpp clang.xcodeproj/project.pbxproj include/clang/Lex/HeaderSearch.h include/clang/Lex/Preprocessor.h

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:26:49 PDT 2007


Author: sabre
Date: Wed Jul 11 11:26:48 2007
New Revision: 39012

URL: http://llvm.org/viewvc/llvm-project?rev=39012&view=rev
Log:
refactor header searching stuff out of the main Preprocessor object into
it's own HeaderSearch object.  This makes Preprocessor simpler and easier
to understand.

Added:
    cfe/cfe/trunk/Lex/HeaderSearch.cpp   (with props)
    cfe/cfe/trunk/include/clang/Lex/HeaderSearch.h   (with props)
Modified:
    cfe/cfe/trunk/Driver/clang.cpp
    cfe/cfe/trunk/Lex/Pragma.cpp
    cfe/cfe/trunk/Lex/Preprocessor.cpp
    cfe/cfe/trunk/clang.xcodeproj/project.pbxproj
    cfe/cfe/trunk/include/clang/Lex/Preprocessor.h

Modified: cfe/cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Driver/clang.cpp?rev=39012&r1=39011&r2=39012&view=diff

==============================================================================
--- cfe/cfe/trunk/Driver/clang.cpp (original)
+++ cfe/cfe/trunk/Driver/clang.cpp Wed Jul 11 11:26:48 2007
@@ -634,16 +634,15 @@
   }
 }
 
-// Process the -I options and set them in the preprocessor.
-static void InitializeIncludePaths(Preprocessor &PP) {
-  FileManager &FM = PP.getFileManager();
-
+/// InitializeIncludePaths - Process the -I options and set them in the
+/// HeaderSearch object.
+static void InitializeIncludePaths(HeaderSearch &Headers, FileManager &FM,
+                                   Diagnostic &Diags) {
   // Handle -I... options.
   for (unsigned i = 0, e = I_dirs.size(); i != e; ++i) {
     if (I_dirs[i] == "-") {
       // -I- is a deprecated GCC feature.
-      PP.getDiagnostics().Report(SourceLocation(),
-                                 diag::err_pp_I_dash_not_supported);
+      Diags.Report(SourceLocation(), diag::err_pp_I_dash_not_supported);
     } else {
       AddPath(I_dirs[i], Angled, false, true, false, FM);
     }
@@ -737,8 +736,8 @@
   
 
   bool DontSearchCurDir = false;  // TODO: set to true if -I- is set?
-  PP.SetSearchPaths(SearchList, IncludeGroup[Quoted].size(),
-                    DontSearchCurDir);
+  Headers.SetSearchPaths(SearchList, IncludeGroup[Quoted].size(),
+                         DontSearchCurDir);
 
   // If verbose, print the list of directories that will be searched.
   if (Verbose) {
@@ -828,16 +827,19 @@
   // Create a file manager object to provide access to and cache the filesystem.
   FileManager FileMgr;
   
+  // Process the -I options and set them in the HeaderInfo.
+  HeaderSearch HeaderInfo(FileMgr);
+  InitializeIncludePaths(HeaderInfo, FileMgr, OurDiagnostics);
+  
+  
   // Set up the preprocessor with these options.
-  Preprocessor PP(OurDiagnostics, Options, *Target, FileMgr, SourceMgr);
+  Preprocessor PP(OurDiagnostics, Options, *Target, FileMgr, SourceMgr,
+                  HeaderInfo);
   
   // Install things like __POWERPC__, __GNUC__, etc into the macro table.
   std::vector<char> PrologMacros;
   InitializePredefinedMacros(PP, PrologMacros);
   
-  // Process the -I options and set them in the preprocessor.
-  InitializeIncludePaths(PP);
-
   // Read any files specified by -imacros or -include.
   ReadPrologFiles(PP, PrologMacros);
   
@@ -932,6 +934,7 @@
   if (Stats) {
     // Printed from low-to-high level.
     PP.getFileManager().PrintStats();
+    PP.getHeaderSearchInfo().PrintStats();
     PP.getSourceManager().PrintStats();
     PP.getIdentifierTable().PrintStats();
     PP.PrintStats();

Added: cfe/cfe/trunk/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/HeaderSearch.cpp?rev=39012&view=auto

==============================================================================
--- cfe/cfe/trunk/Lex/HeaderSearch.cpp (added)
+++ cfe/cfe/trunk/Lex/HeaderSearch.cpp Wed Jul 11 11:26:48 2007
@@ -0,0 +1,205 @@
+//===--- HeaderSearch.cpp - Resolve Header File Locations ---===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by Chris Lattner and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+//  This file implements the DirectoryLookup and HeaderSearch interfaces.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Basic/FileManager.h"
+#include "clang/Lex/HeaderSearch.h"
+#include "clang/Lex/IdentifierTable.h"
+#include "llvm/System/Path.h"
+#include <iostream>
+using namespace llvm;
+using namespace clang;
+
+void HeaderSearch::PrintStats() {
+  std::cerr << "\n*** HeaderSearch Stats:\n";
+  std::cerr << FileInfo.size() << " files tracked.\n";
+  unsigned NumOnceOnlyFiles = 0, MaxNumIncludes = 0, NumSingleIncludedFiles = 0;
+  for (unsigned i = 0, e = FileInfo.size(); i != e; ++i) {
+    NumOnceOnlyFiles += FileInfo[i].isImport;
+    if (MaxNumIncludes < FileInfo[i].NumIncludes)
+      MaxNumIncludes = FileInfo[i].NumIncludes;
+    NumSingleIncludedFiles += FileInfo[i].NumIncludes == 1;
+  }
+  std::cerr << "  " << NumOnceOnlyFiles << " #import/#pragma once files.\n";
+  std::cerr << "  " << NumSingleIncludedFiles << " included exactly once.\n";
+  std::cerr << "  " << MaxNumIncludes << " max times a file is included.\n";
+  
+  std::cerr << "  " << NumIncluded << " #include/#include_next/#import.\n";
+  std::cerr << "    " << NumMultiIncludeFileOptzn << " #includes skipped due to"
+    << " the multi-include optimization.\n";
+
+}
+
+//===----------------------------------------------------------------------===//
+// Header File Location.
+//===----------------------------------------------------------------------===//
+
+static std::string DoFrameworkLookup(const DirectoryEntry *Dir,
+                                     const std::string &Filename) {
+  // TODO: caching.
+  
+  // Framework names must have a '/' in the filename.
+  std::string::size_type SlashPos = Filename.find('/');
+  if (SlashPos == std::string::npos) return "";
+  
+  // FrameworkName = "/System/Library/Frameworks/"
+  std::string FrameworkName = Dir->getName();
+  if (FrameworkName.empty() || FrameworkName[FrameworkName.size()-1] != '/')
+    FrameworkName += '/';
+  
+  // FrameworkName = "/System/Library/Frameworks/Cocoa"
+  FrameworkName += std::string(Filename.begin(), Filename.begin()+SlashPos);
+  
+  // FrameworkName = "/System/Library/Frameworks/Cocoa.framework/"
+  FrameworkName += ".framework/";
+  
+  // If the dir doesn't exist, give up.
+  if (!sys::Path(FrameworkName).exists()) return "";
+  
+  // Check "/System/Library/Frameworks/Cocoa.framework/Headers/file.h"
+  std::string HeadersFilename = FrameworkName + "Headers/" +
+    std::string(Filename.begin()+SlashPos+1, Filename.end());
+  if (sys::Path(HeadersFilename).exists()) return HeadersFilename;
+  
+  // Check "/System/Library/Frameworks/Cocoa.framework/PrivateHeaders/file.h"
+  std::string PrivateHeadersFilename = FrameworkName + "PrivateHeaders/" +
+    std::string(Filename.begin()+SlashPos+1, Filename.end());
+  if (sys::Path(PrivateHeadersFilename).exists()) return HeadersFilename;
+  
+  return "";
+}
+
+/// LookupFile - Given a "foo" or <foo> reference, look up the indicated file,
+/// return null on failure.  isAngled indicates whether the file reference is
+/// for system #include's or not (i.e. using <> instead of "").  CurFileEnt, if
+/// non-null, indicates where the #including file is, in case a relative search
+/// is needed.
+const FileEntry *HeaderSearch::LookupFile(const std::string &Filename, 
+                                          bool isAngled,
+                                          const DirectoryLookup *FromDir,
+                                          const DirectoryLookup *&CurDir,
+                                          const FileEntry *CurFileEnt) {
+  // If 'Filename' is absolute, check to see if it exists and no searching.
+  // FIXME: Portability.  This should be a sys::Path interface, this doesn't
+  // handle things like C:\foo.txt right, nor win32 \\network\device\blah.
+  if (Filename[0] == '/') {
+    CurDir = 0;
+
+    // If this was an #include_next "/absolute/file", fail.
+    if (FromDir) return 0;
+    
+    // Otherwise, just return the file.
+    return FileMgr.getFile(Filename);
+  }
+  
+  // Step #0, unless disabled, check to see if the file is in the #includer's
+  // directory.  This search is not done for <> headers.
+  if (CurFileEnt && !NoCurDirSearch) {
+    // Concatenate the requested file onto the directory.
+    // FIXME: Portability.  Filename concatenation should be in sys::Path.
+    if (const FileEntry *FE = 
+          FileMgr.getFile(CurFileEnt->getDir()->getName()+"/"+Filename)) {
+      // Leave CurDir unset.
+      
+      // This file is a system header or C++ unfriendly if the old file is.
+      getFileInfo(CurFileEnt).DirInfo = getFileInfo(CurFileEnt).DirInfo;
+      return FE;
+    }
+  }
+  
+  CurDir = 0;
+
+  // If this is a system #include, ignore the user #include locs.
+  unsigned i = isAngled ? SystemDirIdx : 0;
+  
+  // If this is a #include_next request, start searching after the directory the
+  // file was found in.
+  if (FromDir)
+    i = FromDir-&SearchDirs[0];
+  
+  // Check each directory in sequence to see if it contains this file.
+  for (; i != SearchDirs.size(); ++i) {
+    // Concatenate the requested file onto the directory.
+    std::string SearchDir;
+    
+    if (!SearchDirs[i].isFramework()) {
+      // FIXME: Portability.  Adding file to dir should be in sys::Path.
+      SearchDir = SearchDirs[i].getDir()->getName()+"/"+Filename;
+    } else {
+      SearchDir = DoFrameworkLookup(SearchDirs[i].getDir(), Filename);
+      if (SearchDir.empty()) continue;
+    }
+    
+    if (const FileEntry *FE = FileMgr.getFile(SearchDir)) {
+      CurDir = &SearchDirs[i];
+      
+      // This file is a system header or C++ unfriendly if the dir is.
+      getFileInfo(FE).DirInfo = CurDir->getDirCharacteristic();
+      return FE;
+    }
+  }
+  
+  // Otherwise, didn't find it.
+  return 0;
+}
+
+//===----------------------------------------------------------------------===//
+// File Info Management.
+//===----------------------------------------------------------------------===//
+
+
+/// getFileInfo - Return the PerFileInfo structure for the specified
+/// FileEntry.
+HeaderSearch::PerFileInfo &HeaderSearch::getFileInfo(const FileEntry *FE) {
+  if (FE->getUID() >= FileInfo.size())
+    FileInfo.resize(FE->getUID()+1);
+  return FileInfo[FE->getUID()];
+}  
+
+/// ShouldEnterIncludeFile - Mark the specified file as a target of of a
+/// #include, #include_next, or #import directive.  Return false if #including
+/// the file will have no effect or true if we should include it.
+bool HeaderSearch::ShouldEnterIncludeFile(const FileEntry *File, bool isImport){
+  ++NumIncluded; // Count # of attempted #includes.
+
+  // Get information about this file.
+  PerFileInfo &FileInfo = getFileInfo(File);
+  
+  // If this is a #import directive, check that we have not already imported
+  // this header.
+  if (isImport) {
+    // If this has already been imported, don't import it again.
+    FileInfo.isImport = true;
+    
+    // Has this already been #import'ed or #include'd?
+    if (FileInfo.NumIncludes) return false;
+  } else {
+    // Otherwise, if this is a #include of a file that was previously #import'd
+    // or if this is the second #include of a #pragma once file, ignore it.
+    if (FileInfo.isImport)
+      return false;
+  }
+  
+  // Next, check to see if the file is wrapped with #ifndef guards.  If so, and
+  // if the macro that guards it is defined, we know the #include has no effect.
+  if (FileInfo.ControllingMacro && FileInfo.ControllingMacro->getMacroInfo()) {
+    ++NumMultiIncludeFileOptzn;
+    return false;
+  }
+  
+  // Increment the number of times this file has been included.
+  ++FileInfo.NumIncludes;
+  
+  return true;
+}
+
+

Propchange: cfe/cfe/trunk/Lex/HeaderSearch.cpp

------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cfe/cfe/trunk/Lex/HeaderSearch.cpp

------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: cfe/cfe/trunk/Lex/Pragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/Pragma.cpp?rev=39012&r1=39011&r2=39012&view=diff

==============================================================================
--- cfe/cfe/trunk/Lex/Pragma.cpp (original)
+++ cfe/cfe/trunk/Lex/Pragma.cpp Wed Jul 11 11:26:48 2007
@@ -176,7 +176,7 @@
   unsigned FileID = getCurrentFileLexer()->getCurFileID();
   
   // Mark the file as a once-only file now.
-  getFileInfo(SourceMgr.getFileEntryForFileID(FileID)).isImport = true;
+  HeaderInfo.MarkFileIncludeOnce(SourceMgr.getFileEntryForFileID(FileID));
 }
 
 /// HandlePragmaPoison - Handle #pragma GCC poison.  PoisonTok is the 'poison'.
@@ -233,7 +233,7 @@
   // Mark the file as a system header.
   const FileEntry *File = 
     SourceMgr.getFileEntryForFileID(TheLexer->getCurFileID());
-  getFileInfo(File).DirInfo = DirectoryLookup::SystemHeaderDir;
+  HeaderInfo.MarkFileSystemHeader(File);
   
   // Notify the client, if desired, that we are in a new source file.
   if (FileChangeHandler)
@@ -257,7 +257,7 @@
   // Remove the quotes.
   Filename = std::string(Filename.begin()+1, Filename.end()-1);
   
-  // Search include directories.
+  // Search include directories for this file.
   const DirectoryLookup *CurDir;
   const FileEntry *File = LookupFile(Filename, isAngled, 0, CurDir);
   if (File == 0)

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

==============================================================================
--- cfe/cfe/trunk/Lex/Preprocessor.cpp (original)
+++ cfe/cfe/trunk/Lex/Preprocessor.cpp Wed Jul 11 11:26:48 2007
@@ -42,19 +42,20 @@
 
 Preprocessor::Preprocessor(Diagnostic &diags, const LangOptions &opts,
                            TargetInfo &target,
-                           FileManager &FM, SourceManager &SM) 
+                           FileManager &FM, SourceManager &SM, 
+                           HeaderSearch &Headers) 
   : Diags(diags), Features(opts), Target(target), FileMgr(FM), SourceMgr(SM),
-    SystemDirIdx(0), NoCurDirSearch(false),
+    HeaderInfo(Headers), 
     CurLexer(0), CurDirLookup(0), CurMacroExpander(0) {
   ScratchBuf = new ScratchBuffer(SourceMgr);
       
   // Clear stats.
-  NumDirectives = NumIncluded = NumDefined = NumUndefined = NumPragma = 0;
+  NumDirectives = NumDefined = NumUndefined = NumPragma = 0;
   NumIf = NumElse = NumEndif = 0;
   NumEnteredSourceFiles = 0;
   NumMacroExpanded = NumFnMacroExpanded = NumBuiltinMacroExpanded = 0;
   NumFastMacroExpanded = NumTokenPaste = NumFastTokenPaste = 0;
-  MaxIncludeStackDepth = 0; NumMultiIncludeFileOptzn = 0;
+  MaxIncludeStackDepth = 0; 
   NumSkipped = 0;
     
   // Macro expansion is enabled.
@@ -94,14 +95,6 @@
   delete ScratchBuf;
 }
 
-/// getFileInfo - Return the PerFileInfo structure for the specified
-/// FileEntry.
-Preprocessor::PerFileInfo &Preprocessor::getFileInfo(const FileEntry *FE) {
-  if (FE->getUID() >= FileInfo.size())
-    FileInfo.resize(FE->getUID()+1);
-  return FileInfo[FE->getUID()];
-}  
-
 /// AddPPKeyword - Register a preprocessor keyword like "define" "undef" or 
 /// "elif".
 static void AddPPKeyword(tok::PPKeywordKind PPID, 
@@ -213,24 +206,10 @@
 
 void Preprocessor::PrintStats() {
   std::cerr << "\n*** Preprocessor Stats:\n";
-  std::cerr << FileInfo.size() << " files tracked.\n";
-  unsigned NumOnceOnlyFiles = 0, MaxNumIncludes = 0, NumSingleIncludedFiles = 0;
-  for (unsigned i = 0, e = FileInfo.size(); i != e; ++i) {
-    NumOnceOnlyFiles += FileInfo[i].isImport;
-    if (MaxNumIncludes < FileInfo[i].NumIncludes)
-      MaxNumIncludes = FileInfo[i].NumIncludes;
-    NumSingleIncludedFiles += FileInfo[i].NumIncludes == 1;
-  }
-  std::cerr << "  " << NumOnceOnlyFiles << " #import/#pragma once files.\n";
-  std::cerr << "  " << NumSingleIncludedFiles << " included exactly once.\n";
-  std::cerr << "  " << MaxNumIncludes << " max times a file is included.\n";
-  
   std::cerr << NumDirectives << " directives found:\n";
   std::cerr << "  " << NumDefined << " #define.\n";
   std::cerr << "  " << NumUndefined << " #undef.\n";
-  std::cerr << "  " << NumIncluded << " #include/#include_next/#import.\n";
-  std::cerr << "    " << NumMultiIncludeFileOptzn << " #includes skipped due to"
-                      << " the multi-include optimization.\n";
+  std::cerr << "  #include/#include_next/#import:\n";
   std::cerr << "    " << NumEnteredSourceFiles << " source files entered.\n";
   std::cerr << "    " << MaxIncludeStackDepth << " max include stack depth\n";
   std::cerr << "  " << NumIf << " #if/#ifndef/#ifdef.\n";
@@ -339,118 +318,24 @@
 // Source File Location Methods.
 //===----------------------------------------------------------------------===//
 
-#include "llvm/System/Path.h"
-
-static std::string DoFrameworkLookup(const DirectoryEntry *Dir,
-                                     const std::string &Filename) {
-  // TODO: caching.
-  
-  // Framework names must have a '/' in the filename.
-  std::string::size_type SlashPos = Filename.find('/');
-  if (SlashPos == std::string::npos) return "";
-
-  // FrameworkName = "/System/Library/Frameworks/"
-  std::string FrameworkName = Dir->getName();
-  if (FrameworkName.empty() || FrameworkName[FrameworkName.size()-1] != '/')
-    FrameworkName += '/';
-  
-  // FrameworkName = "/System/Library/Frameworks/Cocoa"
-  FrameworkName += std::string(Filename.begin(), Filename.begin()+SlashPos);
-
-  // FrameworkName = "/System/Library/Frameworks/Cocoa.framework/"
-  FrameworkName += ".framework/";
-  
-  // If the dir doesn't exist, give up.
-  if (!sys::Path(FrameworkName).exists()) return "";
-
-  // Check "/System/Library/Frameworks/Cocoa.framework/Headers/file.h"
-  std::string HeadersFilename = FrameworkName + "Headers/" +
-    std::string(Filename.begin()+SlashPos+1, Filename.end());
-  if (sys::Path(HeadersFilename).exists()) return HeadersFilename;
-
-  // Check "/System/Library/Frameworks/Cocoa.framework/PrivateHeaders/file.h"
-  std::string PrivateHeadersFilename = FrameworkName + "PrivateHeaders/" +
-    std::string(Filename.begin()+SlashPos+1, Filename.end());
-  if (sys::Path(PrivateHeadersFilename).exists()) return HeadersFilename;
-  
-  return "";
-}
 
 /// LookupFile - Given a "foo" or <foo> reference, look up the indicated file,
 /// return null on failure.  isAngled indicates whether the file reference is
 /// for system #include's or not (i.e. using <> instead of "").
-const FileEntry *Preprocessor::LookupFile(const std::string &Filename, 
+const FileEntry *Preprocessor::LookupFile(const std::string &Filename,
                                           bool isAngled,
                                           const DirectoryLookup *FromDir,
                                           const DirectoryLookup *&CurDir) {
-  assert(CurLexer && "Cannot enter a #include inside a macro expansion!");
-  CurDir = 0;
-  
-  // If 'Filename' is absolute, check to see if it exists and no searching.
-  // FIXME: Portability.  This should be a sys::Path interface, this doesn't
-  // handle things like C:\foo.txt right, nor win32 \\network\device\blah.
-  if (Filename[0] == '/') {
-    // If this was an #include_next "/absolute/file", fail.
-    if (FromDir) return 0;
-
-    // Otherwise, just return the file.
-    return FileMgr.getFile(Filename);
-  }
-  
-  // Step #0, unless disabled, check to see if the file is in the #includer's
-  // directory.  This search is not done for <> headers.
-  if (!isAngled && !FromDir && !NoCurDirSearch) {
+  // If the header lookup mechanism may be relative to the current file, pass in
+  // info about where the current file is.
+  const FileEntry *CurFileEnt = 0;
+  if (!isAngled && !FromDir) {
     unsigned TheFileID = getCurrentFileLexer()->getCurFileID();
-    const FileEntry *CurFE = SourceMgr.getFileEntryForFileID(TheFileID);
-    if (CurFE) {
-      // Concatenate the requested file onto the directory.
-      // FIXME: Portability.  Should be in sys::Path.
-      if (const FileEntry *FE = 
-            FileMgr.getFile(CurFE->getDir()->getName()+"/"+Filename)) {
-        if (CurDirLookup)
-          CurDir = CurDirLookup;
-        else
-          CurDir = 0;
-        
-        // This file is a system header or C++ unfriendly if the old file is.
-        getFileInfo(FE).DirInfo = getFileInfo(CurFE).DirInfo;
-        return FE;
-      }
-    }
+    CurFileEnt = SourceMgr.getFileEntryForFileID(TheFileID);
   }
   
-  // If this is a system #include, ignore the user #include locs.
-  unsigned i = isAngled ? SystemDirIdx : 0;
-
-  // If this is a #include_next request, start searching after the directory the
-  // file was found in.
-  if (FromDir)
-    i = FromDir-&SearchDirs[0];
-  
-  // Check each directory in sequence to see if it contains this file.
-  for (; i != SearchDirs.size(); ++i) {
-    // Concatenate the requested file onto the directory.
-    std::string SearchDir;
-
-    if (!SearchDirs[i].isFramework()) {
-      // FIXME: Portability.  Adding file to dir should be in sys::Path.
-      SearchDir = SearchDirs[i].getDir()->getName()+"/"+Filename;
-    } else {
-      SearchDir = DoFrameworkLookup(SearchDirs[i].getDir(), Filename);
-      if (SearchDir.empty()) continue;
-    }
-    
-    if (const FileEntry *FE = FileMgr.getFile(SearchDir)) {
-      CurDir = &SearchDirs[i];
-      
-      // This file is a system header or C++ unfriendly if the dir is.
-      getFileInfo(FE).DirInfo = CurDir->getDirCharacteristic();
-      return FE;
-    }
-  }
-  
-  // Otherwise, didn't find it.
-  return 0;
+  CurDir = CurDirLookup;
+  return HeaderInfo.LookupFile(Filename, isAngled, FromDir, CurDir, CurFileEnt);
 }
 
 /// isInPrimaryFile - Return true if we're in the top-level file, not in a
@@ -522,7 +407,7 @@
     // Get the file entry for the current file.
     if (const FileEntry *FE = 
           SourceMgr.getFileEntryForFileID(CurLexer->getCurFileID()))
-      FileType = getFileInfo(FE).DirInfo;
+      FileType = HeaderInfo.getFileDirFlavor(FE);
     
     FileChangeHandler(SourceLocation(CurLexer->getCurFileID(), 0),
                       EnterFile, FileType);
@@ -1143,8 +1028,8 @@
           CurLexer->MIOpt.GetControllingMacroAtEndOfFile()) {
       // Okay, this has a controlling macro, remember in PerFileInfo.
       if (const FileEntry *FE = 
-          SourceMgr.getFileEntryForFileID(CurLexer->getCurFileID()))
-        getFileInfo(FE).ControllingMacro = ControllingMacro;
+            SourceMgr.getFileEntryForFileID(CurLexer->getCurFileID()))
+        HeaderInfo.SetFileControllingMacro(FE, ControllingMacro);
     }
   }
   
@@ -1161,7 +1046,7 @@
       // Get the file entry for the current file.
       if (const FileEntry *FE = 
             SourceMgr.getFileEntryForFileID(CurLexer->getCurFileID()))
-        FileType = getFileInfo(FE).DirInfo;
+        FileType = HeaderInfo.getFileDirFlavor(FE);
 
       FileChangeHandler(CurLexer->getSourceLocation(CurLexer->BufferPtr),
                         ExitFile, FileType);
@@ -1629,7 +1514,6 @@
 void Preprocessor::HandleIncludeDirective(LexerToken &IncludeTok,
                                           const DirectoryLookup *LookupFrom,
                                           bool isImport) {
-  ++NumIncluded;
 
   LexerToken FilenameTok;
   std::string Filename = CurLexer->LexIncludeFilename(FilenameTok);
@@ -1658,31 +1542,11 @@
   if (File == 0)
     return Diag(FilenameTok, diag::err_pp_file_not_found);
   
-  // Get information about this file.
-  PerFileInfo &FileInfo = getFileInfo(File);
-  
-  // If this is a #import directive, check that we have not already imported
-  // this header.
-  if (isImport) {
-    // If this has already been imported, don't import it again.
-    FileInfo.isImport = true;
-    
-    // Has this already been #import'ed or #include'd?
-    if (FileInfo.NumIncludes) return;
-  } else {
-    // Otherwise, if this is a #include of a file that was previously #import'd
-    // or if this is the second #include of a #pragma once file, ignore it.
-    if (FileInfo.isImport)
-      return;
-  }
-  
-  // Next, check to see if the file is wrapped with #ifndef guards.  If so, and
-  // if the macro that guards it is defined, we know the #include has no effect.
-  if (FileInfo.ControllingMacro && FileInfo.ControllingMacro->getMacroInfo()) {
-    ++NumMultiIncludeFileOptzn;
+  // Ask HeaderInfo if we should enter this #include file.
+  if (!HeaderInfo.ShouldEnterIncludeFile(File, isImport)) {
+    // If it returns true, #including this file will have no effect.
     return;
   }
-  
 
   // Look up the file, create a File ID for it.
   unsigned FileID = SourceMgr.createFileID(File, FilenameTok.getLocation());
@@ -1691,9 +1555,6 @@
 
   // Finally, if all is good, enter the new file!
   EnterSourceFile(FileID, CurDir);
-
-  // Increment the number of times this file has been included.
-  ++FileInfo.NumIncludes;
 }
 
 /// HandleIncludeNextDirective - Implements #include_next.

Modified: cfe/cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=39012&r1=39011&r2=39012&view=diff

==============================================================================
--- cfe/cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/cfe/trunk/clang.xcodeproj/project.pbxproj Wed Jul 11 11:26:48 2007
@@ -22,6 +22,8 @@
 		DE0FCB340A9C21F100248FD5 /* Expr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE0FCB330A9C21F100248FD5 /* Expr.cpp */; };
 		DE1F22030A7D852A00FBF588 /* Parser.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE1F22020A7D852A00FBF588 /* Parser.h */; };
 		DE1F24820A7DCD3800FBF588 /* Declarations.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE1F24810A7DCD3800FBF588 /* Declarations.h */; };
+		DE344AB80AE5DF6D00DBC861 /* HeaderSearch.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE344AB70AE5DF6D00DBC861 /* HeaderSearch.h */; };
+		DE344B540AE5E46C00DBC861 /* HeaderSearch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE344B530AE5E46C00DBC861 /* HeaderSearch.cpp */; };
 		DE46BF280AE0A82D00CC047C /* TargetInfo.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE46BF270AE0A82D00CC047C /* TargetInfo.h */; };
 		DE5932D10AD60FF400BC794C /* clang.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE5932CD0AD60FF400BC794C /* clang.cpp */; };
 		DE5932D20AD60FF400BC794C /* clang.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE5932CE0AD60FF400BC794C /* clang.h */; };
@@ -106,6 +108,7 @@
 				DE0FCA630A95859D00248FD5 /* Expr.h in CopyFiles */,
 				DE5932D20AD60FF400BC794C /* clang.h in CopyFiles */,
 				DE46BF280AE0A82D00CC047C /* TargetInfo.h in CopyFiles */,
+				DE344AB80AE5DF6D00DBC861 /* HeaderSearch.h in CopyFiles */,
 			);
 			runOnlyForDeploymentPostprocessing = 1;
 		};
@@ -128,6 +131,8 @@
 		DE0FCB330A9C21F100248FD5 /* Expr.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Expr.cpp; path = AST/Expr.cpp; sourceTree = "<group>"; };
 		DE1F22020A7D852A00FBF588 /* Parser.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Parser.h; path = clang/Parse/Parser.h; sourceTree = "<group>"; };
 		DE1F24810A7DCD3800FBF588 /* Declarations.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Declarations.h; path = clang/Parse/Declarations.h; sourceTree = "<group>"; };
+		DE344AB70AE5DF6D00DBC861 /* HeaderSearch.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HeaderSearch.h; sourceTree = "<group>"; };
+		DE344B530AE5E46C00DBC861 /* HeaderSearch.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = HeaderSearch.cpp; sourceTree = "<group>"; };
 		DE46BF270AE0A82D00CC047C /* TargetInfo.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = TargetInfo.h; sourceTree = "<group>"; };
 		DE5932CD0AD60FF400BC794C /* clang.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = clang.cpp; path = Driver/clang.cpp; sourceTree = "<group>"; };
 		DE5932CE0AD60FF400BC794C /* clang.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = clang.h; path = Driver/clang.h; sourceTree = "<group>"; };
@@ -318,6 +323,7 @@
 		DED7D7390A524295003AD0FB /* Lex */ = {
 			isa = PBXGroup;
 			children = (
+				DE344AB70AE5DF6D00DBC861 /* HeaderSearch.h */,
 				DED7D73A0A524295003AD0FB /* IdentifierTable.h */,
 				DED7D73B0A524295003AD0FB /* Lexer.h */,
 				DED7D73C0A524295003AD0FB /* LexerToken.h */,
@@ -348,6 +354,7 @@
 		DED7D78C0A5242E6003AD0FB /* Lex */ = {
 			isa = PBXGroup;
 			children = (
+				DE344B530AE5E46C00DBC861 /* HeaderSearch.cpp */,
 				DED7D79D0A5242E6003AD0FB /* IdentifierTable.cpp */,
 				DED7D79E0A5242E6003AD0FB /* Lexer.cpp */,
 				DED7D79F0A5242E6003AD0FB /* MacroExpander.cpp */,
@@ -431,6 +438,7 @@
 				DED626C90AE0C065001E80A4 /* TargetInfo.cpp in Sources */,
 				DED627030AE0C51D001E80A4 /* Targets.cpp in Sources */,
 				DED62ABB0AE2EDF1001E80A4 /* Decl.cpp in Sources */,
+				DE344B540AE5E46C00DBC861 /* HeaderSearch.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Added: cfe/cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=39012&view=auto

==============================================================================
--- cfe/cfe/trunk/include/clang/Lex/HeaderSearch.h (added)
+++ cfe/cfe/trunk/include/clang/Lex/HeaderSearch.h Wed Jul 11 11:26:48 2007
@@ -0,0 +1,196 @@
+//===--- HeaderSearch.h - Resolve Header File Locations ---------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by Chris Lattner and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the DirectoryLookup and HeaderSearch interfaces.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_LEX_HEADERSEARCH_H
+#define LLVM_CLANG_LEX_HEADERSEARCH_H
+
+#include <vector>
+#include <string>
+
+namespace llvm {
+namespace clang {
+class DirectoryEntry;
+class FileEntry;
+class FileManager;
+class IdentifierInfo;
+
+/// DirectoryLookup - This class is used to specify the search order for
+/// directories in #include directives.
+class DirectoryLookup {
+public:
+  enum DirType {
+    NormalHeaderDir,
+    SystemHeaderDir,
+    ExternCSystemHeaderDir
+  };
+private:  
+  /// Dir - This is the actual directory that we're referring to.
+  ///
+  const DirectoryEntry *Dir;
+  
+  /// DirCharacteristic - The type of directory this is, one of the DirType enum
+  /// values.
+  DirType DirCharacteristic : 2;
+  
+  /// UserSupplied - True if this is a user-supplied directory.
+  ///
+  bool UserSupplied : 1;
+  
+  /// Framework - True if this is a framework directory search-path.
+  ///
+  bool Framework : 1;
+public:
+  DirectoryLookup(const DirectoryEntry *dir, DirType DT, bool isUser,
+                  bool isFramework)
+    : Dir(dir), DirCharacteristic(DT), UserSupplied(isUser),
+      Framework(isFramework) {}
+  
+  /// getDir - Return the directory that this entry refers to.
+  ///
+  const DirectoryEntry *getDir() const { return Dir; }
+  
+  /// DirCharacteristic - The type of directory this is, one of the DirType enum
+  /// values.
+  DirType getDirCharacteristic() const { return DirCharacteristic; }
+  
+  /// isUserSupplied - True if this is a user-supplied directory.
+  ///
+  bool isUserSupplied() const { return UserSupplied; }
+  
+  /// isFramework - True if this is a framework directory.
+  ///
+  bool isFramework() const { return Framework; }
+};
+
+  
+/// HeaderSearch - This class encapsulates the information needed to find the
+/// file referenced by a #include or #include_next, (sub-)framework lookup, etc.
+class HeaderSearch {
+  FileManager &FileMgr;
+  
+  /// #include search path information.  Requests for #include "x" search the
+  /// directory of the #including file first, then each directory in SearchDirs
+  /// consequtively. Requests for <x> search the current dir first, then each
+  /// directory in SearchDirs, starting at SystemDirIdx, consequtively.  If
+  /// NoCurDirSearch is true, then the check for the file in the current
+  /// directory is supressed.
+  std::vector<DirectoryLookup> SearchDirs;
+  unsigned SystemDirIdx;
+  bool NoCurDirSearch;
+  
+  /// PreFileInfo - The preprocessor keeps track of this information for each
+  /// file that is #included.
+  struct PerFileInfo {
+    /// isImport - True if this is a #import'd or #pragma once file.
+    bool isImport : 1;
+    
+    /// DirInfo - Keep track of whether this is a system header, and if so,
+    /// whether it is C++ clean or not.  This can be set by the include paths or
+    /// by #pragma gcc system_header.
+    DirectoryLookup::DirType DirInfo : 2;
+    
+    /// NumIncludes - This is the number of times the file has been included
+    /// already.
+    unsigned short NumIncludes;
+    
+    /// ControllingMacro - If this file has a #ifndef XXX (or equivalent) guard
+    /// that protects the entire contents of the file, this is the identifier
+    /// for the macro that controls whether or not it has any effect.
+    const IdentifierInfo *ControllingMacro;
+    
+    PerFileInfo() : isImport(false), DirInfo(DirectoryLookup::NormalHeaderDir),
+      NumIncludes(0), ControllingMacro(0) {}
+  };
+  
+  /// FileInfo - This contains all of the preprocessor-specific data about files
+  /// that are included.  The vector is indexed by the FileEntry's UID.
+  ///
+  std::vector<PerFileInfo> FileInfo;
+  
+  // Various statistics we track for performance analysis.
+  unsigned NumIncluded;
+  unsigned NumMultiIncludeFileOptzn;
+public:
+  HeaderSearch(FileManager &FM) : FileMgr(FM) {
+    SystemDirIdx = 0;
+    NoCurDirSearch = false;
+
+    NumIncluded = 0;
+    NumMultiIncludeFileOptzn = 0;
+  }
+    
+  /// SetSearchPaths - Interface for setting the file search paths.
+  ///
+  void SetSearchPaths(const std::vector<DirectoryLookup> &dirs,
+                      unsigned systemDirIdx, bool noCurDirSearch) {
+    SearchDirs = dirs;
+    SystemDirIdx = systemDirIdx;
+    NoCurDirSearch = noCurDirSearch;
+  }
+  
+  /// LookupFile - Given a "foo" or <foo> reference, look up the indicated file,
+  /// return null on failure.  isAngled indicates whether the file reference is
+  /// a <> reference.  If successful, this returns 'UsedDir', the
+  /// DirectoryLookup member the file was found in, or null if not applicable.
+  /// If CurDir is non-null, the file was found in the specified directory
+  /// search location.  This is used to implement #include_next.  CurFileEnt, if
+  /// non-null, indicates where the #including file is, in case a relative
+  /// search is needed.
+  const FileEntry *LookupFile(const std::string &Filename, bool isAngled,
+                              const DirectoryLookup *FromDir,
+                              const DirectoryLookup *&CurDir,
+                              const FileEntry *CurFileEnt);
+  
+  /// ShouldEnterIncludeFile - Mark the specified file as a target of of a
+  /// #include, #include_next, or #import directive.  Return false if #including
+  /// the file will have no effect or true if we should include it.
+  bool ShouldEnterIncludeFile(const FileEntry *File, bool isImport);
+  
+  
+  /// getFileDirFlavor - Return whether the specified file is a normal header,
+  /// a system header, or a C++ friendly system header.
+  DirectoryLookup::DirType getFileDirFlavor(const FileEntry *File) {
+    return getFileInfo(File).DirInfo;
+  }
+    
+  /// MarkFileIncludeOnce - Mark the specified file as a "once only" file, e.g.
+  /// due to #pragma once.
+  void MarkFileIncludeOnce(const FileEntry *File) {
+    getFileInfo(File).isImport = true;
+  }
+
+  /// MarkFileSystemHeader - Mark the specified fiel as a system header, e.g.
+  /// due to #pragma GCC system_header.
+  void MarkFileSystemHeader(const FileEntry *File) {
+    getFileInfo(File).DirInfo = DirectoryLookup::SystemHeaderDir;
+  }
+  
+  /// SetFileControllingMacro - Mark the specified file as having a controlling
+  /// macro.  This is used by the multiple-include optimization to eliminate
+  /// no-op #includes.
+  void SetFileControllingMacro(const FileEntry *File,
+                               const IdentifierInfo *ControllingMacro) {
+    getFileInfo(File).ControllingMacro = ControllingMacro;
+  }
+  
+  void PrintStats();
+private:
+  /// getFileInfo - Return the PerFileInfo structure for the specified
+  /// FileEntry.
+  PerFileInfo &getFileInfo(const FileEntry *FE);
+};
+
+}  // end namespace llvm
+}  // end namespace clang
+
+#endif

Propchange: cfe/cfe/trunk/include/clang/Lex/HeaderSearch.h

------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cfe/cfe/trunk/include/clang/Lex/HeaderSearch.h

------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

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

==============================================================================
--- cfe/cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/cfe/trunk/include/clang/Lex/Preprocessor.h Wed Jul 11 11:26:48 2007
@@ -14,9 +14,10 @@
 #ifndef LLVM_CLANG_LEX_PREPROCESSOR_H
 #define LLVM_CLANG_LEX_PREPROCESSOR_H
 
+#include "clang/Lex/HeaderSearch.h"
+#include "clang/Lex/IdentifierTable.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Lex/MacroExpander.h"
-#include "clang/Lex/IdentifierTable.h"
 #include "clang/Basic/SourceLocation.h"
 
 namespace llvm {
@@ -24,61 +25,12 @@
   
 class SourceManager;
 class FileManager;
-class DirectoryEntry;
 class FileEntry;
 class PragmaNamespace;
 class PragmaHandler;
 class ScratchBuffer;
 class TargetInfo;
 
-/// DirectoryLookup - This class is used to specify the search order for
-/// directories in #include directives.
-class DirectoryLookup {
-public:
-  enum DirType {
-    NormalHeaderDir,
-    SystemHeaderDir,
-    ExternCSystemHeaderDir
-  };
-private:  
-  /// Dir - This is the actual directory that we're referring to.
-  ///
-  const DirectoryEntry *Dir;
-  
-  /// DirCharacteristic - The type of directory this is, one of the DirType enum
-  /// values.
-  DirType DirCharacteristic : 2;
-  
-  /// UserSupplied - True if this is a user-supplied directory.
-  ///
-  bool UserSupplied : 1;
-  
-  /// Framework - True if this is a framework directory search-path.
-  ///
-  bool Framework : 1;
-public:
-  DirectoryLookup(const DirectoryEntry *dir, DirType DT, bool isUser,
-                  bool isFramework)
-    : Dir(dir), DirCharacteristic(DT), UserSupplied(isUser),
-      Framework(isFramework) {}
-    
-  /// getDir - Return the directory that this entry refers to.
-  ///
-  const DirectoryEntry *getDir() const { return Dir; }
-  
-  /// DirCharacteristic - The type of directory this is, one of the DirType enum
-  /// values.
-  DirType getDirCharacteristic() const { return DirCharacteristic; }
-  
-  /// isUserSupplied - True if this is a user-supplied directory.
-  ///
-  bool isUserSupplied() const { return UserSupplied; }
-  
-  /// isFramework - True if this is a framework directory.
-  ///
-  bool isFramework() const { return Framework; }
-};
-
 /// Preprocessor - This object forms engages in a tight little dance to
 /// efficiently preprocess tokens.  Lexers know only about tokens within a
 /// single source file, and don't know anything about preprocessor-level issues
@@ -91,17 +43,8 @@
   FileManager       &FileMgr;
   SourceManager     &SourceMgr;
   ScratchBuffer     *ScratchBuf;
-  
-  // #include search path information.  Requests for #include "x" search the
-  /// directory of the #including file first, then each directory in SearchDirs
-  /// consequtively. Requests for <x> search the current dir first, then each
-  /// directory in SearchDirs, starting at SystemDirIdx, consequtively.  If
-  /// NoCurDirSearch is true, then the check for the file in the current
-  /// directory is supressed.
-  std::vector<DirectoryLookup> SearchDirs;
-  unsigned SystemDirIdx;
-  bool NoCurDirSearch;
-  
+  HeaderSearch      &HeaderInfo;
+    
   /// Identifiers for builtin macros and other builtins.
   IdentifierInfo *Ident__LINE__, *Ident__FILE__;   // __LINE__, __FILE__
   IdentifierInfo *Ident__DATE__, *Ident__TIME__;   // __DATE__, __TIME__
@@ -176,45 +119,16 @@
   std::vector<IncludeStackInfo> IncludeMacroStack;
   
   
-  /// PreFileInfo - The preprocessor keeps track of this information for each
-  /// file that is #included.
-  struct PerFileInfo {
-    /// isImport - True if this is a #import'd or #pragma once file.
-    bool isImport : 1;
-    
-    /// DirInfo - Keep track of whether this is a system header, and if so,
-    /// whether it is C++ clean or not.  This can be set by the include paths or
-    /// by #pragma gcc system_header.
-    DirectoryLookup::DirType DirInfo : 2;
-    
-    /// NumIncludes - This is the number of times the file has been included
-    /// already.
-    unsigned short NumIncludes;
-    
-    /// ControllingMacro - If this file has a #ifndef XXX (or equivalent) guard
-    /// that protects the entire contents of the file, this is the identifier
-    /// for the macro that controls whether or not it has any effect.
-    const IdentifierInfo *ControllingMacro;
-    
-    PerFileInfo() : isImport(false), DirInfo(DirectoryLookup::NormalHeaderDir),
-                    NumIncludes(0), ControllingMacro(0) {}
-  };
-  
-  /// FileInfo - This contains all of the preprocessor-specific data about files
-  /// that are included.  The vector is indexed by the FileEntry's UID.
-  ///
-  std::vector<PerFileInfo> FileInfo;
-  
   // Various statistics we track for performance analysis.
   unsigned NumDirectives, NumIncluded, NumDefined, NumUndefined, NumPragma;
   unsigned NumIf, NumElse, NumEndif;
-  unsigned NumEnteredSourceFiles, MaxIncludeStackDepth,NumMultiIncludeFileOptzn;
+  unsigned NumEnteredSourceFiles, MaxIncludeStackDepth;
   unsigned NumMacroExpanded, NumFnMacroExpanded, NumBuiltinMacroExpanded;
   unsigned NumFastMacroExpanded, NumTokenPaste, NumFastTokenPaste;
   unsigned NumSkipped;
 public:
   Preprocessor(Diagnostic &diags, const LangOptions &opts, TargetInfo &target,
-               FileManager &FM, SourceManager &SM);
+               FileManager &FM, SourceManager &SM, HeaderSearch &Headers);
   ~Preprocessor();
 
   Diagnostic &getDiagnostics() const { return Diags; }
@@ -222,6 +136,7 @@
   TargetInfo &getTargetInfo() const { return Target; }
   FileManager &getFileManager() const { return FileMgr; }
   SourceManager &getSourceManager() const { return SourceMgr; }
+  HeaderSearch &getHeaderSearchInfo() const { return HeaderInfo; }
 
   IdentifierTable &getIdentifierTable() { return Identifiers; }
 
@@ -241,15 +156,6 @@
   Lexer *getCurrentFileLexer() const;
   
   
-  /// SetSearchPaths - Interface for setting the file search paths.
-  ///
-  void SetSearchPaths(const std::vector<DirectoryLookup> &dirs,
-                      unsigned systemDirIdx, bool noCurDirSearch) {
-    SearchDirs = dirs;
-    SystemDirIdx = systemDirIdx;
-    NoCurDirSearch = noCurDirSearch;
-  }
-  
   /// setFileChangeHandler - Set the callback invoked whenever a source file is
   /// entered or exited.  The SourceLocation indicates the new location, and
   /// EnteringFile indicates whether this is because we are entering a new
@@ -298,16 +204,6 @@
   /// pragma line before the pragma string starts, e.g. "STDC" or "GCC".
   void AddPragmaHandler(const char *Namespace, PragmaHandler *Handler);
 
-  /// LookupFile - Given a "foo" or <foo> reference, look up the indicated file,
-  /// return null on failure.  isAngled indicates whether the file reference is
-  /// a <> reference.  If successful, this returns 'UsedDir', the
-  /// DirectoryLookup member the file was found in, or null if not applicable.
-  /// If CurDir is non-null, the file was found in the specified directory
-  /// search location.  This is used to implement #include_next.
-  const FileEntry *LookupFile(const std::string &Filename, bool isAngled,
-                              const DirectoryLookup *FromDir,
-                              const DirectoryLookup *&CurDir);
-  
   /// EnterSourceFile - Add a source file to the top of the include stack and
   /// start lexing tokens from it instead of the current buffer.  If isMainFile
   /// is true, this is the main file for the translation unit.
@@ -442,9 +338,6 @@
   /// not, emit a diagnostic and consume up until the eom.
   void CheckEndOfDirective(const char *Directive);
 private:
-  /// getFileInfo - Return the PerFileInfo structure for the specified
-  /// FileEntry.
-  PerFileInfo &getFileInfo(const FileEntry *FE);
 
   /// DiscardUntilEndOfDirective - Read and discard all tokens remaining on the
   /// current line until the tok::eom token is found.
@@ -515,6 +408,13 @@
   /// start lexing tokens from it instead of the current buffer.
   void EnterSourceFileWithLexer(Lexer *TheLexer, const DirectoryLookup *Dir);
   
+  /// LookupFile - Given a "foo" or <foo> reference, look up the indicated file,
+  /// return null on failure.  isAngled indicates whether the file reference is
+  /// for system #include's or not (i.e. using <> instead of "").
+  const FileEntry *LookupFile(const std::string &Filename, bool isAngled,
+                              const DirectoryLookup *FromDir,
+                              const DirectoryLookup *&CurDir);
+    
   //===--------------------------------------------------------------------===//
   /// Handle*Directive - implement the various preprocessor directives.  These
   /// should side-effect the current preprocessor object so that the next call





More information about the cfe-commits mailing list