2009-06-02 17:58:47 +00:00
|
|
|
//===--- HeaderMap.h - A file that acts like dir of symlinks ----*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file 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 llvm {
|
|
|
|
class MemoryBuffer;
|
2010-01-15 15:39:40 +00:00
|
|
|
class StringRef;
|
2011-05-02 19:39:53 +00:00
|
|
|
template <typename T> class SmallVectorImpl;
|
2009-06-02 17:58:47 +00:00
|
|
|
}
|
|
|
|
namespace clang {
|
|
|
|
class FileEntry;
|
|
|
|
class FileManager;
|
|
|
|
struct HMapBucket;
|
|
|
|
struct HMapHeader;
|
|
|
|
|
|
|
|
/// 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 {
|
|
|
|
HeaderMap(const HeaderMap&); // DO NOT IMPLEMENT
|
|
|
|
void operator=(const HeaderMap&); // DO NOT IMPLEMENT
|
2009-10-14 18:03:49 +00:00
|
|
|
|
2009-06-02 17:58:47 +00:00
|
|
|
const llvm::MemoryBuffer *FileBuffer;
|
|
|
|
bool NeedsBSwap;
|
2009-10-14 18:03:49 +00:00
|
|
|
|
2009-06-02 17:58:47 +00:00
|
|
|
HeaderMap(const llvm::MemoryBuffer *File, bool BSwap)
|
|
|
|
: FileBuffer(File), NeedsBSwap(BSwap) {
|
|
|
|
}
|
|
|
|
public:
|
|
|
|
~HeaderMap();
|
2009-10-14 18:03:49 +00:00
|
|
|
|
2009-06-02 17:58:47 +00:00
|
|
|
/// 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.
|
2011-02-20 13:06:31 +00:00
|
|
|
static const HeaderMap *Create(const FileEntry *FE, FileManager &FM);
|
2009-10-14 18:03:49 +00:00
|
|
|
|
2009-06-02 17:58:47 +00:00
|
|
|
/// LookupFile - Check to see if the specified relative filename is located in
|
|
|
|
/// this HeaderMap. If so, open it and return its FileEntry.
|
2011-05-02 19:39:53 +00:00
|
|
|
/// If RawPath is not NULL and the file is found, RawPath will be set to the
|
|
|
|
/// raw path at which the file was found in the file system. For example,
|
|
|
|
/// for a search path ".." and a filename "../file.h" this would be
|
|
|
|
/// "../../file.h".
|
2010-01-15 15:39:40 +00:00
|
|
|
const FileEntry *LookupFile(llvm::StringRef Filename, FileManager &FM) const;
|
2009-10-14 18:03:49 +00:00
|
|
|
|
2009-06-02 17:58:47 +00:00
|
|
|
/// getFileName - Return the filename of the headermap.
|
|
|
|
const char *getFileName() const;
|
2009-10-14 18:03:49 +00:00
|
|
|
|
2009-06-02 17:58:47 +00:00
|
|
|
/// dump - Print the contents of this headermap to stderr.
|
|
|
|
void dump() const;
|
2009-10-14 18:03:49 +00:00
|
|
|
|
2009-06-02 17:58:47 +00:00
|
|
|
private:
|
|
|
|
unsigned getEndianAdjustedWord(unsigned X) const;
|
|
|
|
const HMapHeader &getHeader() const;
|
|
|
|
HMapBucket getBucket(unsigned BucketNo) const;
|
|
|
|
const char *getString(unsigned StrTabIdx) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace clang.
|
|
|
|
|
|
|
|
#endif
|