• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
20 namespace clang {
21   class ASTUnit;
22   class CIndexer;
23   class SimpleFormatContext;
24 } // namespace clang
25 
26 struct 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 
36 namespace clang {
37 namespace cxtu {
38 
39 CXTranslationUnitImpl *MakeCXTranslationUnit(CIndexer *CIdx, ASTUnit *AU);
40 
getASTUnit(CXTranslationUnit TU)41 static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
42   return TU->TheASTUnit;
43 }
44 
45 class CXTUOwner {
46   CXTranslationUnitImpl *TU;
47 
48 public:
CXTUOwner(CXTranslationUnitImpl * tu)49   CXTUOwner(CXTranslationUnitImpl *tu) : TU(tu) { }
50   ~CXTUOwner();
51 
getTU()52   CXTranslationUnitImpl *getTU() const { return TU; }
53 
takeTU()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