blob: 15e89ea849933c8d5500522aad6300f43f4f7808 [file] [log] [blame]
Ted Kremenek0a90d322010-11-17 23:24:11 +00001//===- 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 Gribenko5694feb2013-01-26 18:53:38 +000017#include "clang-c/Index.h"
18
Dmitri Gribenkoe42e5782013-01-26 21:32:42 +000019namespace clang {
20 class ASTUnit;
21 class CIndexer;
22} // namespace clang
23
Ted Kremenek0a90d322010-11-17 23:24:11 +000024struct CXTranslationUnitImpl {
Argyrios Kyrtzidisfdc17952012-03-28 02:18:05 +000025 void *CIdx;
Dmitri Gribenkoe42e5782013-01-26 21:32:42 +000026 clang::ASTUnit *TheASTUnit;
Ted Kremenek0a90d322010-11-17 23:24:11 +000027 void *StringPool;
Ted Kremenek15322172011-11-10 08:43:12 +000028 void *Diagnostics;
Ted Kremenekbbf66ca2012-04-30 19:06:49 +000029 void *OverridenCursorsPool;
Fariborz Jahanian88b95212012-12-18 23:02:59 +000030 void *FormatContext;
31 unsigned FormatInMemoryUniqueId;
Ted Kremenek0a90d322010-11-17 23:24:11 +000032};
Ted Kremenek0a90d322010-11-17 23:24:11 +000033
Argyrios Kyrtzidis9049cf62011-10-12 07:07:33 +000034namespace clang {
35 class ASTUnit;
Argyrios Kyrtzidisfdc17952012-03-28 02:18:05 +000036 class CIndexer;
Argyrios Kyrtzidis9049cf62011-10-12 07:07:33 +000037
38namespace cxtu {
39
Dmitri Gribenkoe42e5782013-01-26 21:32:42 +000040CXTranslationUnitImpl *MakeCXTranslationUnit(CIndexer *CIdx, ASTUnit *AU);
Dmitri Gribenko5694feb2013-01-26 18:53:38 +000041
42static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
Dmitri Gribenkoe42e5782013-01-26 21:32:42 +000043 return TU->TheASTUnit;
Dmitri Gribenko5694feb2013-01-26 18:53:38 +000044}
45
Argyrios Kyrtzidis4e7064f2011-10-17 19:48:19 +000046class CXTUOwner {
47 CXTranslationUnitImpl *TU;
48
49public:
50 CXTUOwner(CXTranslationUnitImpl *tu) : TU(tu) { }
51 ~CXTUOwner();
52
53 CXTranslationUnitImpl *getTU() const { return TU; }
54
55 CXTranslationUnitImpl *takeTU() {
56 CXTranslationUnitImpl *retTU = TU;
57 TU = 0;
58 return retTU;
59 }
60};
61
62
Argyrios Kyrtzidis9049cf62011-10-12 07:07:33 +000063}} // end namespace clang::cxtu
64
Ted Kremenek0a90d322010-11-17 23:24:11 +000065#endif