Ted Kremenek | 0a90d32 | 2010-11-17 23:24:11 +0000 | [diff] [blame] | 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 | |
Dmitri Gribenko | 5694feb | 2013-01-26 18:53:38 +0000 | [diff] [blame] | 17 | #include "clang-c/Index.h" |
Dmitri Gribenko | 9c48d16 | 2013-01-26 22:44:19 +0000 | [diff] [blame] | 18 | #include "CXString.h" |
Dmitri Gribenko | 5694feb | 2013-01-26 18:53:38 +0000 | [diff] [blame] | 19 | |
Dmitri Gribenko | e42e578 | 2013-01-26 21:32:42 +0000 | [diff] [blame] | 20 | namespace clang { |
| 21 | class ASTUnit; |
| 22 | class CIndexer; |
Dmitri Gribenko | 337ee24 | 2013-01-26 21:39:50 +0000 | [diff] [blame] | 23 | class SimpleFormatContext; |
Dmitri Gribenko | e42e578 | 2013-01-26 21:32:42 +0000 | [diff] [blame] | 24 | } // namespace clang |
| 25 | |
Ted Kremenek | 0a90d32 | 2010-11-17 23:24:11 +0000 | [diff] [blame] | 26 | struct CXTranslationUnitImpl { |
Dmitri Gribenko | 8c718e7 | 2013-01-26 21:49:50 +0000 | [diff] [blame] | 27 | clang::CIndexer *CIdx; |
Dmitri Gribenko | e42e578 | 2013-01-26 21:32:42 +0000 | [diff] [blame] | 28 | clang::ASTUnit *TheASTUnit; |
Dmitri Gribenko | 9c48d16 | 2013-01-26 22:44:19 +0000 | [diff] [blame] | 29 | clang::cxstring::CXStringPool *StringPool; |
Ted Kremenek | 1532217 | 2011-11-10 08:43:12 +0000 | [diff] [blame] | 30 | void *Diagnostics; |
Ted Kremenek | bbf66ca | 2012-04-30 19:06:49 +0000 | [diff] [blame] | 31 | void *OverridenCursorsPool; |
Dmitri Gribenko | 337ee24 | 2013-01-26 21:39:50 +0000 | [diff] [blame] | 32 | clang::SimpleFormatContext *FormatContext; |
Fariborz Jahanian | 88b9521 | 2012-12-18 23:02:59 +0000 | [diff] [blame] | 33 | unsigned FormatInMemoryUniqueId; |
Ted Kremenek | 0a90d32 | 2010-11-17 23:24:11 +0000 | [diff] [blame] | 34 | }; |
Ted Kremenek | 0a90d32 | 2010-11-17 23:24:11 +0000 | [diff] [blame] | 35 | |
Argyrios Kyrtzidis | 9049cf6 | 2011-10-12 07:07:33 +0000 | [diff] [blame] | 36 | namespace clang { |
Argyrios Kyrtzidis | 9049cf6 | 2011-10-12 07:07:33 +0000 | [diff] [blame] | 37 | namespace cxtu { |
| 38 | |
Dmitri Gribenko | e42e578 | 2013-01-26 21:32:42 +0000 | [diff] [blame] | 39 | CXTranslationUnitImpl *MakeCXTranslationUnit(CIndexer *CIdx, ASTUnit *AU); |
Dmitri Gribenko | 5694feb | 2013-01-26 18:53:38 +0000 | [diff] [blame] | 40 | |
| 41 | static inline ASTUnit *getASTUnit(CXTranslationUnit TU) { |
Dmitri Gribenko | e42e578 | 2013-01-26 21:32:42 +0000 | [diff] [blame] | 42 | return TU->TheASTUnit; |
Dmitri Gribenko | 5694feb | 2013-01-26 18:53:38 +0000 | [diff] [blame] | 43 | } |
| 44 | |
Argyrios Kyrtzidis | 4e7064f | 2011-10-17 19:48:19 +0000 | [diff] [blame] | 45 | class CXTUOwner { |
| 46 | CXTranslationUnitImpl *TU; |
| 47 | |
| 48 | public: |
| 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 | |
Argyrios Kyrtzidis | 9049cf6 | 2011-10-12 07:07:33 +0000 | [diff] [blame] | 62 | }} // end namespace clang::cxtu |
| 63 | |
Ted Kremenek | 0a90d32 | 2010-11-17 23:24:11 +0000 | [diff] [blame] | 64 | #endif |