[cfe-commits] r48082 - in /cfe/trunk/Lex: PPDirectives.cpp PPLexerChange.cpp

Chris Lattner sabre at nondot.org
Sat Mar 8 20:17:44 PST 2008


Author: lattner
Date: Sat Mar  8 22:17:44 2008
New Revision: 48082

URL: http://llvm.org/viewvc/llvm-project?rev=48082&view=rev
Log:
move PP::LookupFile from PPLexerChange -> PPDirectives.cpp

Modified:
    cfe/trunk/Lex/PPDirectives.cpp
    cfe/trunk/Lex/PPLexerChange.cpp

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

==============================================================================
--- cfe/trunk/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/Lex/PPDirectives.cpp Sat Mar  8 22:17:44 2008
@@ -288,6 +288,54 @@
   CurLexer->LexingRawMode = false;
 }
 
+/// 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 char *FilenameStart,
+                                          const char *FilenameEnd,
+                                          bool isAngled,
+                                          const DirectoryLookup *FromDir,
+                                          const DirectoryLookup *&CurDir) {
+  // 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 (!FromDir) {
+    SourceLocation FileLoc = getCurrentFileLexer()->getFileLoc();
+    CurFileEnt = SourceMgr.getFileEntryForLoc(FileLoc);
+  }
+  
+  // Do a standard file entry lookup.
+  CurDir = CurDirLookup;
+  const FileEntry *FE =
+  HeaderInfo.LookupFile(FilenameStart, FilenameEnd,
+                        isAngled, FromDir, CurDir, CurFileEnt);
+  if (FE) return FE;
+  
+  // Otherwise, see if this is a subframework header.  If so, this is relative
+  // to one of the headers on the #include stack.  Walk the list of the current
+  // headers on the #include stack and pass them to HeaderInfo.
+  if (CurLexer && !CurLexer->Is_PragmaLexer) {
+    if ((CurFileEnt = SourceMgr.getFileEntryForLoc(CurLexer->getFileLoc())))
+      if ((FE = HeaderInfo.LookupSubframeworkHeader(FilenameStart, FilenameEnd,
+                                                    CurFileEnt)))
+        return FE;
+  }
+  
+  for (unsigned i = 0, e = IncludeMacroStack.size(); i != e; ++i) {
+    IncludeStackInfo &ISEntry = IncludeMacroStack[e-i-1];
+    if (ISEntry.TheLexer && !ISEntry.TheLexer->Is_PragmaLexer) {
+      if ((CurFileEnt = 
+           SourceMgr.getFileEntryForLoc(ISEntry.TheLexer->getFileLoc())))
+        if ((FE = HeaderInfo.LookupSubframeworkHeader(FilenameStart,
+                                                      FilenameEnd, CurFileEnt)))
+          return FE;
+    }
+  }
+  
+  // Otherwise, we really couldn't find the file.
+  return 0;
+}
+
 
 //===----------------------------------------------------------------------===//
 // Preprocessor Directive Handling.

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

==============================================================================
--- cfe/trunk/Lex/PPLexerChange.cpp (original)
+++ cfe/trunk/Lex/PPLexerChange.cpp Sat Mar  8 22:17:44 2008
@@ -28,54 +28,6 @@
 // Source File Location Methods.
 //===----------------------------------------------------------------------===//
 
-/// 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 char *FilenameStart,
-                                          const char *FilenameEnd,
-                                          bool isAngled,
-                                          const DirectoryLookup *FromDir,
-                                          const DirectoryLookup *&CurDir) {
-  // 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 (!FromDir) {
-    SourceLocation FileLoc = getCurrentFileLexer()->getFileLoc();
-    CurFileEnt = SourceMgr.getFileEntryForLoc(FileLoc);
-  }
-  
-  // Do a standard file entry lookup.
-  CurDir = CurDirLookup;
-  const FileEntry *FE =
-    HeaderInfo.LookupFile(FilenameStart, FilenameEnd,
-                          isAngled, FromDir, CurDir, CurFileEnt);
-  if (FE) return FE;
-  
-  // Otherwise, see if this is a subframework header.  If so, this is relative
-  // to one of the headers on the #include stack.  Walk the list of the current
-  // headers on the #include stack and pass them to HeaderInfo.
-  if (CurLexer && !CurLexer->Is_PragmaLexer) {
-    if ((CurFileEnt = SourceMgr.getFileEntryForLoc(CurLexer->getFileLoc())))
-      if ((FE = HeaderInfo.LookupSubframeworkHeader(FilenameStart, FilenameEnd,
-                                                    CurFileEnt)))
-        return FE;
-  }
-  
-  for (unsigned i = 0, e = IncludeMacroStack.size(); i != e; ++i) {
-    IncludeStackInfo &ISEntry = IncludeMacroStack[e-i-1];
-    if (ISEntry.TheLexer && !ISEntry.TheLexer->Is_PragmaLexer) {
-      if ((CurFileEnt = 
-           SourceMgr.getFileEntryForLoc(ISEntry.TheLexer->getFileLoc())))
-        if ((FE = HeaderInfo.LookupSubframeworkHeader(FilenameStart,
-                                                      FilenameEnd, CurFileEnt)))
-          return FE;
-    }
-  }
-  
-  // Otherwise, we really couldn't find the file.
-  return 0;
-}
-
 /// isInPrimaryFile - Return true if we're in the top-level file, not in a
 /// #include.
 bool Preprocessor::isInPrimaryFile() const {





More information about the cfe-commits mailing list