PTHManager.h revision 866bdf74547efe32c320554837ffce00fcc084fe
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 IdentifierInfo** 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, IdentifierInfo** perIDCache, 63 Preprocessor& pp); 64 65 // Do not implement. 66 PTHManager(); 67 void operator=(const PTHManager&); 68 69 /// GetIdentifierInfo - Used by PTHManager to reconstruct IdentifierInfo 70 /// objects from the PTH file. 71 IdentifierInfo* GetIdentifierInfo(unsigned); 72 73public: 74 75 ~PTHManager(); 76 77 /// Create - This method creates PTHManager objects. The 'file' argument 78 /// is the name of the PTH file. This method returns NULL upon failure. 79 static PTHManager* Create(const std::string& file, Preprocessor& PP); 80 81 /// CreateLexer - Return a PTHLexer that "lexes" the cached tokens for the 82 /// specified file. This method returns NULL if no cached tokens exist. 83 /// It is the responsibility of the caller to 'delete' the returned object. 84 PTHLexer* CreateLexer(unsigned FileID, const FileEntry* FE); 85}; 86 87} // end namespace clang 88 89#endif 90