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