CXTranslationUnit.h revision 337ee24785a784ba5418c2e78716d15b94fd57f0
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 19namespace clang { 20 class ASTUnit; 21 class CIndexer; 22 class SimpleFormatContext; 23} // namespace clang 24 25struct CXTranslationUnitImpl { 26 void *CIdx; 27 clang::ASTUnit *TheASTUnit; 28 void *StringPool; 29 void *Diagnostics; 30 void *OverridenCursorsPool; 31 clang::SimpleFormatContext *FormatContext; 32 unsigned FormatInMemoryUniqueId; 33}; 34 35namespace clang { 36namespace cxtu { 37 38CXTranslationUnitImpl *MakeCXTranslationUnit(CIndexer *CIdx, ASTUnit *AU); 39 40static inline ASTUnit *getASTUnit(CXTranslationUnit TU) { 41 return TU->TheASTUnit; 42} 43 44class CXTUOwner { 45 CXTranslationUnitImpl *TU; 46 47public: 48 CXTUOwner(CXTranslationUnitImpl *tu) : TU(tu) { } 49 ~CXTUOwner(); 50 51 CXTranslationUnitImpl *getTU() const { return TU; } 52 53 CXTranslationUnitImpl *takeTU() { 54 CXTranslationUnitImpl *retTU = TU; 55 TU = 0; 56 return retTU; 57 } 58}; 59 60 61}} // end namespace clang::cxtu 62 63#endif 64