1 //===- CXTranslationUnit.h - Routines for manipulating CXTranslationUnits -===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file defines routines for manipulating CXTranslationUnits.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_TOOLS_LIBCLANG_CXTRANSLATIONUNIT_H
14 #define LLVM_CLANG_TOOLS_LIBCLANG_CXTRANSLATIONUNIT_H
18 #include "clang-c/Index.h"
24 class CommentToXMLConverter
;
28 struct CXTranslationUnitImpl
{
29 clang::CIndexer
*CIdx
;
30 clang::ASTUnit
*TheASTUnit
;
31 clang::cxstring::CXStringPool
*StringPool
;
33 void *OverridenCursorsPool
;
34 clang::index::CommentToXMLConverter
*CommentToXML
;
35 unsigned ParsingOptions
;
36 std::vector
<std::string
> Arguments
;
39 struct CXTargetInfoImpl
{
40 CXTranslationUnit TranslationUnit
;
46 CXTranslationUnitImpl
*MakeCXTranslationUnit(CIndexer
*CIdx
,
47 std::unique_ptr
<ASTUnit
> AU
);
49 static inline ASTUnit
*getASTUnit(CXTranslationUnit TU
) {
52 return TU
->TheASTUnit
;
55 /// \returns true if the ASTUnit has a diagnostic about the AST file being
57 bool isASTReadError(ASTUnit
*AU
);
59 static inline bool isNotUsableTU(CXTranslationUnit TU
) {
63 #define LOG_BAD_TU(TU) \
66 *Log << "called with a bad TU: " << TU; \
71 CXTranslationUnitImpl
*TU
;
74 CXTUOwner(CXTranslationUnitImpl
*tu
) : TU(tu
) { }
77 CXTranslationUnitImpl
*getTU() const { return TU
; }
79 CXTranslationUnitImpl
*takeTU() {
80 CXTranslationUnitImpl
*retTU
= TU
;
87 }} // end namespace clang::cxtu