CXTranslationUnit.h revision 9c48d16a11872624410ab3a5944edcba0f32818c
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 return TU->TheASTUnit; 43} 44 45class CXTUOwner { 46 CXTranslationUnitImpl *TU; 47 48public: 49 CXTUOwner(CXTranslationUnitImpl *tu) : TU(tu) { } 50 ~CXTUOwner(); 51 52 CXTranslationUnitImpl *getTU() const { return TU; } 53 54 CXTranslationUnitImpl *takeTU() { 55 CXTranslationUnitImpl *retTU = TU; 56 TU = 0; 57 return retTU; 58 } 59}; 60 61 62}} // end namespace clang::cxtu 63 64#endif 65