summaryrefslogtreecommitdiffstats
path: root/include/clang/Lex
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-12-17 06:36:45 +0000
committerChris Lattner <sabre@nondot.org>2007-12-17 06:36:45 +0000
commit822da61b74ce14e89b3fa8774db18c833aa5748b (patch)
tree94c98ef06bf1e44bd5a9bda3dbd702bc360df92b /include/clang/Lex
parentd66552797f9a34f5b966adbe45234111752678a0 (diff)
Step #1 in adding headermap support to clang.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45089 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Lex')
-rw-r--r--include/clang/Lex/DirectoryLookup.h48
-rw-r--r--include/clang/Lex/HeaderMap.h37
-rw-r--r--include/clang/Lex/HeaderSearch.h9
3 files changed, 85 insertions, 9 deletions
diff --git a/include/clang/Lex/DirectoryLookup.h b/include/clang/Lex/DirectoryLookup.h
index a1cfb0a340..817c1597bc 100644
--- a/include/clang/Lex/DirectoryLookup.h
+++ b/include/clang/Lex/DirectoryLookup.h
@@ -16,9 +16,13 @@
namespace clang {
class DirectoryEntry;
+class HeaderMap;
-/// DirectoryLookup - This class is used to specify the search order for
-/// directories in #include directives.
+/// DirectoryLookup - This class represents one entry in the search list that
+/// specifies the search order for directories in #include directives. It
+/// represents either a directory or a 'headermap'. A headermap is just like a
+/// directory, but it remaps its contents through an indirection table instead
+/// of indexing a directory.
class DirectoryLookup {
public:
enum DirType {
@@ -26,10 +30,16 @@ public:
SystemHeaderDir,
ExternCSystemHeaderDir
};
-private:
- /// Dir - This is the actual directory that we're referring to.
- ///
- const DirectoryEntry *Dir;
+private:
+ union { // This union is discriminated by isHeaderMap.
+ /// Dir - This is the actual directory that we're referring to.
+ ///
+ const DirectoryEntry *Dir;
+
+ /// Map - This is the HeaderMap corresponding if the isHeaderMap field is
+ /// true.
+ const HeaderMap *Map;
+ } u;
/// DirCharacteristic - The type of directory this is, one of the DirType enum
/// values.
@@ -42,15 +52,35 @@ private:
/// Framework - True if this is a framework directory search-path.
///
bool Framework : 1;
+
+ /// isHeaderMap - True if the HeaderMap field is valid, false if the Dir field
+ /// is valid.
+ bool isHeaderMap : 1;
public:
+ /// DirectoryLookup ctor - Note that this ctor *does not take ownership* of
+ /// 'dir'.
DirectoryLookup(const DirectoryEntry *dir, DirType DT, bool isUser,
bool isFramework)
- : Dir(dir), DirCharacteristic(DT), UserSupplied(isUser),
- Framework(isFramework) {}
+ : DirCharacteristic(DT), UserSupplied(isUser),
+ Framework(isFramework), isHeaderMap(false) {
+ u.Dir = dir;
+ }
+
+ /// DirectoryLookup ctor - Note that this ctor *does not take ownership* of
+ /// 'map'.
+ DirectoryLookup(const HeaderMap *map, DirType DT, bool isUser, bool isFWork)
+ : DirCharacteristic(DT), UserSupplied(isUser), Framework(isFWork),
+ isHeaderMap(true) {
+ u.Map = map;
+ }
/// getDir - Return the directory that this entry refers to.
///
- const DirectoryEntry *getDir() const { return Dir; }
+ const DirectoryEntry *getDir() const { return !isHeaderMap ? u.Dir : 0; }
+
+ /// getHeaderMap - Return the directory that this entry refers to.
+ ///
+ const HeaderMap *getHeaderMap() const { return isHeaderMap ? u.Map : 0; }
/// DirCharacteristic - The type of directory this is, one of the DirType enum
/// values.
diff --git a/include/clang/Lex/HeaderMap.h b/include/clang/Lex/HeaderMap.h
new file mode 100644
index 0000000000..7c79fe0447
--- /dev/null
+++ b/include/clang/Lex/HeaderMap.h
@@ -0,0 +1,37 @@
+//===--- HeaderMap.h - A file that acts like dir of symlinks ----*- 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 HeaderMap interface.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_LEX_HEADERMAP_H
+#define LLVM_CLANG_LEX_HEADERMAP_H
+
+namespace clang {
+
+/// This class represents an Apple concept known as a 'header map'. To the
+/// #include file resolution process, it basically acts like a directory of
+/// symlinks to files. Its advantages are that it is dense and more efficient
+/// to create and process than a directory of symlinks.
+class HeaderMap {
+public:
+ /// HeaderMap::Create - This attempts to load the specified file as a header
+ /// map. If it doesn't look like a HeaderMap, it gives up and returns null.
+ /// If it looks like a HeaderMap but is obviously corrupted, it puts a reason
+ /// into the string error argument and returns null.
+ static const HeaderMap *Create(const FileEntry *FE, std::string &ErrorInfo) {
+ // FIXME: woot!
+ return 0;
+ }
+};
+
+} // end namespace clang.
+
+#endif \ No newline at end of file
diff --git a/include/clang/Lex/HeaderSearch.h b/include/clang/Lex/HeaderSearch.h
index 381c672aeb..70f7d957ba 100644
--- a/include/clang/Lex/HeaderSearch.h
+++ b/include/clang/Lex/HeaderSearch.h
@@ -81,12 +81,17 @@ class HeaderSearch {
/// name like "Carbon" to the Carbon.framework directory.
llvm::StringMap<const DirectoryEntry *> FrameworkMap;
+ /// HeaderMaps - This is a mapping from FileEntry -> HeaderMap, uniquing
+ /// headermaps. This vector owns the headermap.
+ std::vector<std::pair<const FileEntry*, const HeaderMap*> > HeaderMaps;
+
// Various statistics we track for performance analysis.
unsigned NumIncluded;
unsigned NumMultiIncludeFileOptzn;
unsigned NumFrameworkLookups, NumSubFrameworkLookups;
public:
HeaderSearch(FileManager &FM);
+ ~HeaderSearch();
FileManager &getFileMgr() const { return FileMgr; }
@@ -166,6 +171,10 @@ public:
getFileInfo(File).ControllingMacro = ControllingMacro;
}
+ /// CreateHeaderMap - This method returns a HeaderMap for the specified
+ /// FileEntry, uniquing them through the the 'HeaderMaps' datastructure.
+ const HeaderMap *CreateHeaderMap(const FileEntry *FE, std::string &ErrorInfo);
+
void PrintStats();
private:
const FileEntry *DoFrameworkLookup(const DirectoryEntry *Dir,