PTHManager.h revision 6183e4815a4019e97ad01bd880f12355599b75fd
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; 30class PTHLexer; 31 32class PTHManager { 33 34 friend class PTHLexer; 35 36 /// The memory mapped PTH file. 37 const llvm::MemoryBuffer* Buf; 38 39 /// IdMap - A lazily generated cache mapping from persistent identifiers to 40 /// IdentifierInfo*. 41 void* PerIDCache; 42 43 /// FileLookup - Abstract data structure used for mapping between files 44 /// and token data in the PTH file. 45 void* FileLookup; 46 47 /// IdDataTable - Array representing the mapping from persistent IDs to the 48 /// data offset within the PTH file containing the information to 49 /// reconsitute an IdentifierInfo. 50 const char* IdDataTable; 51 52 /// ITable - The IdentifierTable used for the translation unit being lexed. 53 IdentifierTable& ITable; 54 55 /// PP - The Preprocessor object that will use this PTHManager to create 56 /// PTHLexer objects. 57 Preprocessor& PP; 58 59 /// This constructor is intended to only be called by the static 'Create' 60 /// method. 61 PTHManager(const llvm::MemoryBuffer* buf, void* fileLookup, 62 const char* idDataTable, void* perIDCache, Preprocessor& pp); 63 64 // Do not implement. 65 PTHManager(); 66 void operator=(const PTHManager&); 67 68 /// ReadIdentifierInfo - Used by PTHManager to reconstruct IdentifierInfo 69 /// objects from the PTH file. 70 IdentifierInfo* ReadIdentifierInfo(const char*& D); 71 72public: 73 74 ~PTHManager(); 75 76 /// Create - This method creates PTHManager objects. The 'file' argument 77 /// is the name of the PTH file. This method returns NULL upon failure. 78 static PTHManager* Create(const std::string& file, Preprocessor& PP); 79 80 /// CreateLexer - Return a PTHLexer that "lexes" the cached tokens for the 81 /// specified file. This method returns NULL if no cached tokens exist. 82 /// It is the responsibility of the caller to 'delete' the returned object. 83 PTHLexer* CreateLexer(unsigned FileID, const FileEntry* FE); 84}; 85 86} // end namespace clang 87 88#endif 89