CXTranslationUnit.h revision 84347225fcf5aae5ff982e94f4c95548ae26b846
1//===- CXTranslationUnit.h - Routines for manipulating CXTranslationUnits -===// 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 routines for manipulating CXTranslationUnits. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_CLANG_CXTRANSLATIONUNIT_H 15#define LLVM_CLANG_CXTRANSLATIONUNIT_H 16 17#include "clang-c/Index.h" 18#include "CXString.h" 19 20namespace clang { 21 class ASTUnit; 22 class CIndexer; 23 class SimpleFormatContext; 24} // namespace clang 25 26struct CXTranslationUnitImpl { 27 clang::CIndexer *CIdx; 28 clang::ASTUnit *TheASTUnit; 29 clang::cxstring::CXStringPool *StringPool; 30 void *Diagnostics; 31 void *OverridenCursorsPool; 32 clang::SimpleFormatContext *FormatContext; 33 unsigned FormatInMemoryUniqueId; 34}; 35 36namespace clang { 37namespace cxtu { 38 39CXTranslationUnitImpl *MakeCXTranslationUnit(CIndexer *CIdx, ASTUnit *AU); 40 41static inline ASTUnit *getASTUnit(CXTranslationUnit TU) { 42 if (!TU) 43 return 0; 44 return TU->TheASTUnit; 45} 46 47class CXTUOwner { 48 CXTranslationUnitImpl *TU; 49 50public: 51 CXTUOwner(CXTranslationUnitImpl *tu) : TU(tu) { } 52 ~CXTUOwner(); 53 54 CXTranslationUnitImpl *getTU() const { return TU; } 55 56 CXTranslationUnitImpl *takeTU() { 57 CXTranslationUnitImpl *retTU = TU; 58 TU = 0; 59 return retTU; 60 } 61}; 62 63 64}} // end namespace clang::cxtu 65 66#endif 67