blob: 428f5622e751894b93468f3b1a2b78e07c2feb33 [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;
Dmitri Gribenko337ee242013-01-26 21:39:50 +000022 class SimpleFormatContext;
Dmitri Gribenkoe42e5782013-01-26 21:32:42 +000023} // namespace clang
24
Ted Kremenek0a90d322010-11-17 23:24:11 +000025struct CXTranslationUnitImpl {
Argyrios Kyrtzidisfdc17952012-03-28 02:18:05 +000026 void *CIdx;
Dmitri Gribenkoe42e5782013-01-26 21:32:42 +000027 clang::ASTUnit *TheASTUnit;
Ted Kremenek0a90d322010-11-17 23:24:11 +000028 void *StringPool;
Ted Kremenek15322172011-11-10 08:43:12 +000029 void *Diagnostics;
Ted Kremenekbbf66ca2012-04-30 19:06:49 +000030 void *OverridenCursorsPool;
Dmitri Gribenko337ee242013-01-26 21:39:50 +000031 clang::SimpleFormatContext *FormatContext;
Fariborz Jahanian88b95212012-12-18 23:02:59 +000032 unsigned FormatInMemoryUniqueId;
Ted Kremenek0a90d322010-11-17 23:24:11 +000033};
Ted Kremenek0a90d322010-11-17 23:24:11 +000034
Argyrios Kyrtzidis9049cf62011-10-12 07:07:33 +000035namespace clang {
Argyrios Kyrtzidis9049cf62011-10-12 07:07:33 +000036namespace cxtu {
37
Dmitri Gribenkoe42e5782013-01-26 21:32:42 +000038CXTranslationUnitImpl *MakeCXTranslationUnit(CIndexer *CIdx, ASTUnit *AU);
Dmitri Gribenko5694feb2013-01-26 18:53:38 +000039
40static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
Dmitri Gribenkoe42e5782013-01-26 21:32:42 +000041 return TU->TheASTUnit;
Dmitri Gribenko5694feb2013-01-26 18:53:38 +000042}
43
Argyrios Kyrtzidis4e7064f2011-10-17 19:48:19 +000044class CXTUOwner {
45 CXTranslationUnitImpl *TU;
46
47public:
48 CXTUOwner(CXTranslationUnitImpl *tu) : TU(tu) { }
49 ~CXTUOwner();
50
51 CXTranslationUnitImpl *getTU() const { return TU; }
52
53 CXTranslationUnitImpl *takeTU() {
54 CXTranslationUnitImpl *retTU = TU;
55 TU = 0;
56 return retTU;
57 }
58};
59
60
Argyrios Kyrtzidis9049cf62011-10-12 07:07:33 +000061}} // end namespace clang::cxtu
62
Ted Kremenek0a90d322010-11-17 23:24:11 +000063#endif