blob: 699b74a642d12c4206087be39a12b42410f5b111 [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"
Dmitri Gribenko9c48d162013-01-26 22:44:19 +000018#include "CXString.h"
Dmitri Gribenko5694feb2013-01-26 18:53:38 +000019
Dmitri Gribenkoe42e5782013-01-26 21:32:42 +000020namespace clang {
21 class ASTUnit;
22 class CIndexer;
Dmitri Gribenko337ee242013-01-26 21:39:50 +000023 class SimpleFormatContext;
Dmitri Gribenkoe42e5782013-01-26 21:32:42 +000024} // namespace clang
25
Ted Kremenek0a90d322010-11-17 23:24:11 +000026struct CXTranslationUnitImpl {
Dmitri Gribenko8c718e72013-01-26 21:49:50 +000027 clang::CIndexer *CIdx;
Dmitri Gribenkoe42e5782013-01-26 21:32:42 +000028 clang::ASTUnit *TheASTUnit;
Dmitri Gribenko9c48d162013-01-26 22:44:19 +000029 clang::cxstring::CXStringPool *StringPool;
Ted Kremenek15322172011-11-10 08:43:12 +000030 void *Diagnostics;
Ted Kremenekbbf66ca2012-04-30 19:06:49 +000031 void *OverridenCursorsPool;
Dmitri Gribenko337ee242013-01-26 21:39:50 +000032 clang::SimpleFormatContext *FormatContext;
Fariborz Jahanian88b95212012-12-18 23:02:59 +000033 unsigned FormatInMemoryUniqueId;
Ted Kremenek0a90d322010-11-17 23:24:11 +000034};
Ted Kremenek0a90d322010-11-17 23:24:11 +000035
Argyrios Kyrtzidis9049cf62011-10-12 07:07:33 +000036namespace clang {
Argyrios Kyrtzidis9049cf62011-10-12 07:07:33 +000037namespace cxtu {
38
Dmitri Gribenkoe42e5782013-01-26 21:32:42 +000039CXTranslationUnitImpl *MakeCXTranslationUnit(CIndexer *CIdx, ASTUnit *AU);
Dmitri Gribenko5694feb2013-01-26 18:53:38 +000040
41static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
Dmitri Gribenkoe42e5782013-01-26 21:32:42 +000042 return TU->TheASTUnit;
Dmitri Gribenko5694feb2013-01-26 18:53:38 +000043}
44
Argyrios Kyrtzidis4e7064f2011-10-17 19:48:19 +000045class CXTUOwner {
46 CXTranslationUnitImpl *TU;
47
48public:
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 Kyrtzidis9049cf62011-10-12 07:07:33 +000062}} // end namespace clang::cxtu
63
Ted Kremenek0a90d322010-11-17 23:24:11 +000064#endif