2010-11-18 07:24:11 +08:00
|
|
|
//===- CXTranslationUnit.h - Routines for manipulating CXTranslationUnits -===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines routines for manipulating CXTranslationUnits.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:25:19 +08:00
|
|
|
#ifndef LLVM_CLANG_TOOLS_LIBCLANG_CXTRANSLATIONUNIT_H
|
|
|
|
#define LLVM_CLANG_TOOLS_LIBCLANG_CXTRANSLATIONUNIT_H
|
2010-11-18 07:24:11 +08:00
|
|
|
|
2014-02-11 22:34:14 +08:00
|
|
|
#include "CLog.h"
|
2014-03-04 18:05:20 +08:00
|
|
|
#include "CXString.h"
|
2014-01-07 19:51:46 +08:00
|
|
|
#include "clang-c/Index.h"
|
2013-01-27 02:53:38 +08:00
|
|
|
|
2013-01-27 05:32:42 +08:00
|
|
|
namespace clang {
|
|
|
|
class ASTUnit;
|
|
|
|
class CIndexer;
|
2013-11-14 06:16:51 +08:00
|
|
|
namespace index {
|
|
|
|
class CommentToXMLConverter;
|
|
|
|
} // namespace index
|
2013-01-27 05:32:42 +08:00
|
|
|
} // namespace clang
|
|
|
|
|
2010-11-18 07:24:11 +08:00
|
|
|
struct CXTranslationUnitImpl {
|
2013-01-27 05:49:50 +08:00
|
|
|
clang::CIndexer *CIdx;
|
2013-01-27 05:32:42 +08:00
|
|
|
clang::ASTUnit *TheASTUnit;
|
2013-01-27 06:44:19 +08:00
|
|
|
clang::cxstring::CXStringPool *StringPool;
|
2011-11-10 16:43:12 +08:00
|
|
|
void *Diagnostics;
|
2012-05-01 03:06:49 +08:00
|
|
|
void *OverridenCursorsPool;
|
2013-11-14 06:16:51 +08:00
|
|
|
clang::index::CommentToXMLConverter *CommentToXML;
|
2010-11-18 07:24:11 +08:00
|
|
|
};
|
|
|
|
|
2011-10-12 15:07:33 +08:00
|
|
|
namespace clang {
|
|
|
|
namespace cxtu {
|
|
|
|
|
2013-01-27 05:32:42 +08:00
|
|
|
CXTranslationUnitImpl *MakeCXTranslationUnit(CIndexer *CIdx, ASTUnit *AU);
|
2013-01-27 02:53:38 +08:00
|
|
|
|
|
|
|
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
|
2013-04-10 04:03:03 +08:00
|
|
|
if (!TU)
|
2014-06-08 16:38:04 +08:00
|
|
|
return nullptr;
|
2013-01-27 05:32:42 +08:00
|
|
|
return TU->TheASTUnit;
|
2013-01-27 02:53:38 +08:00
|
|
|
}
|
|
|
|
|
2014-02-13 03:12:37 +08:00
|
|
|
/// \returns true if the ASTUnit has a diagnostic about the AST file being
|
|
|
|
/// corrupted.
|
|
|
|
bool isASTReadError(ASTUnit *AU);
|
|
|
|
|
2014-02-11 23:02:48 +08:00
|
|
|
static inline bool isNotUsableTU(CXTranslationUnit TU) {
|
2014-02-11 22:34:14 +08:00
|
|
|
return !TU;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define LOG_BAD_TU(TU) \
|
|
|
|
do { \
|
|
|
|
LOG_FUNC_SECTION { \
|
|
|
|
*Log << "called with a bad TU: " << TU; \
|
|
|
|
} \
|
|
|
|
} while(false)
|
|
|
|
|
2011-10-18 03:48:19 +08:00
|
|
|
class CXTUOwner {
|
|
|
|
CXTranslationUnitImpl *TU;
|
|
|
|
|
|
|
|
public:
|
|
|
|
CXTUOwner(CXTranslationUnitImpl *tu) : TU(tu) { }
|
|
|
|
~CXTUOwner();
|
|
|
|
|
|
|
|
CXTranslationUnitImpl *getTU() const { return TU; }
|
|
|
|
|
|
|
|
CXTranslationUnitImpl *takeTU() {
|
|
|
|
CXTranslationUnitImpl *retTU = TU;
|
2014-06-08 16:38:04 +08:00
|
|
|
TU = nullptr;
|
2011-10-18 03:48:19 +08:00
|
|
|
return retTU;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-06-23 07:07:51 +08:00
|
|
|
}} // end namespace clang::cxtu
|
2011-10-12 15:07:33 +08:00
|
|
|
|
2010-11-18 07:24:11 +08:00
|
|
|
#endif
|