clang API Documentation

HeaderMap.h
Go to the documentation of this file.
00001 //===--- HeaderMap.h - A file that acts like dir of symlinks ----*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file defines the HeaderMap interface.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_CLANG_LEX_HEADERMAP_H
00015 #define LLVM_CLANG_LEX_HEADERMAP_H
00016 
00017 #include "clang/Basic/LLVM.h"
00018 
00019 namespace llvm {
00020   class MemoryBuffer;
00021 }
00022 namespace clang {
00023   class FileEntry;
00024   class FileManager;
00025   struct HMapBucket;
00026   struct HMapHeader;
00027 
00028 /// This class represents an Apple concept known as a 'header map'.  To the
00029 /// #include file resolution process, it basically acts like a directory of
00030 /// symlinks to files.  Its advantages are that it is dense and more efficient
00031 /// to create and process than a directory of symlinks.
00032 class HeaderMap {
00033   HeaderMap(const HeaderMap&); // DO NOT IMPLEMENT
00034   void operator=(const HeaderMap&); // DO NOT IMPLEMENT
00035 
00036   const llvm::MemoryBuffer *FileBuffer;
00037   bool NeedsBSwap;
00038 
00039   HeaderMap(const llvm::MemoryBuffer *File, bool BSwap)
00040     : FileBuffer(File), NeedsBSwap(BSwap) {
00041   }
00042 public:
00043   ~HeaderMap();
00044 
00045   /// HeaderMap::Create - This attempts to load the specified file as a header
00046   /// map.  If it doesn't look like a HeaderMap, it gives up and returns null.
00047   static const HeaderMap *Create(const FileEntry *FE, FileManager &FM);
00048 
00049   /// LookupFile - Check to see if the specified relative filename is located in
00050   /// this HeaderMap.  If so, open it and return its FileEntry.
00051   /// If RawPath is not NULL and the file is found, RawPath will be set to the
00052   /// raw path at which the file was found in the file system. For example,
00053   /// for a search path ".." and a filename "../file.h" this would be
00054   /// "../../file.h".
00055   const FileEntry *LookupFile(StringRef Filename, FileManager &FM) const;
00056 
00057   /// getFileName - Return the filename of the headermap.
00058   const char *getFileName() const;
00059 
00060   /// dump - Print the contents of this headermap to stderr.
00061   void dump() const;
00062 
00063 private:
00064   unsigned getEndianAdjustedWord(unsigned X) const;
00065   const HMapHeader &getHeader() const;
00066   HMapBucket getBucket(unsigned BucketNo) const;
00067   const char *getString(unsigned StrTabIdx) const;
00068 };
00069 
00070 } // end namespace clang.
00071 
00072 #endif