PTHManager.h revision be1ee79d20db9cec7ef81d7a22ba2eaddc9c95b5
1//===--- PTHManager.h - Manager object for PTH processing -------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file defines the PTHManager interface. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_CLANG_PTHMANAGER_H 15#define LLVM_CLANG_PTHMANAGER_H 16 17#include "clang/Lex/PTHLexer.h" 18#include "clang/Basic/LangOptions.h" 19#include <string> 20 21namespace llvm { 22 class MemoryBuffer; 23} 24 25namespace clang { 26 27class FileEntry; 28class IdentifierInfo; 29class IdentifierTable; 30 31class PTHManager { 32 /// The memory mapped PTH file. 33 const llvm::MemoryBuffer* Buf; 34 35 /// IdMap - A lazily generated cache mapping from persistent identifiers to 36 /// IdentifierInfo*. 37 void* PersistentIDCache; 38 39 /// FileLookup - Abstract data structure used for mapping between files 40 /// and token data in the PTH file. 41 void* FileLookup; 42 43 /// IdDataTable - Array representing the mapping from persistent IDs to the 44 /// data offset within the PTH file containing the information to 45 /// reconsitute an IdentifierInfo. 46 const char* IdDataTable; 47 48 /// ITable - The IdentifierTable used for the translation unit being lexed. 49 IdentifierTable& ITable; 50 51 /// PP - The Preprocessor object that will use this PTHManager to create 52 /// PTHLexer objects. 53 Preprocessor& PP; 54 55 /// This constructor is intended to only be called by the static 'Create' 56 /// method. 57 PTHManager(const llvm::MemoryBuffer* buf, void* fileLookup, 58 const char* idDataTable, Preprocessor& pp); 59 60 // Do not implement. 61 PTHManager(); 62 void operator=(const PTHManager&); 63 64 /// ReadIdentifierInfo - Used by PTHManager to reconstruct IdentifierInfo 65 /// objects from the PTH file. 66 IdentifierInfo* ReadIdentifierInfo(const char*& D); 67 68 /// ReadToken - Used by PTHManager to read tokens from the PTH file. 69 void ReadToken(const char*& D, unsigned FileID, Token& T); 70 71public: 72 73 ~PTHManager(); 74 75 /// Create - This method creates PTHManager objects. The 'file' argument 76 /// is the name of the PTH file. This method returns NULL upon failure. 77 static PTHManager* Create(const std::string& file, Preprocessor& PP); 78 79 /// CreateLexer - Return a PTHLexer that "lexes" the cached tokens for the 80 /// specified file. This method returns NULL if no cached tokens exist. 81 /// It is the responsibility of the caller to 'delete' the returned object. 82 PTHLexer* CreateLexer(unsigned FileID, const FileEntry* FE); 83}; 84 85} // end namespace clang 86 87#endif 88