aboutsummaryrefslogtreecommitdiff
path: root/tools/libclang/CXTranslationUnit.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/libclang/CXTranslationUnit.h')
-rw-r--r--tools/libclang/CXTranslationUnit.h22
1 files changed, 19 insertions, 3 deletions
diff --git a/tools/libclang/CXTranslationUnit.h b/tools/libclang/CXTranslationUnit.h
index c0014c0c8f13..d86ed2b8d342 100644
--- a/tools/libclang/CXTranslationUnit.h
+++ b/tools/libclang/CXTranslationUnit.h
@@ -14,8 +14,9 @@
#ifndef LLVM_CLANG_CXTRANSLATIONUNIT_H
#define LLVM_CLANG_CXTRANSLATIONUNIT_H
-#include "clang-c/Index.h"
+#include "CLog.h"
#include "CXString.h"
+#include "clang-c/Index.h"
namespace clang {
class ASTUnit;
@@ -41,10 +42,25 @@ CXTranslationUnitImpl *MakeCXTranslationUnit(CIndexer *CIdx, ASTUnit *AU);
static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
if (!TU)
- return 0;
+ return nullptr;
return TU->TheASTUnit;
}
+/// \returns true if the ASTUnit has a diagnostic about the AST file being
+/// corrupted.
+bool isASTReadError(ASTUnit *AU);
+
+static inline bool isNotUsableTU(CXTranslationUnit TU) {
+ return !TU;
+}
+
+#define LOG_BAD_TU(TU) \
+ do { \
+ LOG_FUNC_SECTION { \
+ *Log << "called with a bad TU: " << TU; \
+ } \
+ } while(false)
+
class CXTUOwner {
CXTranslationUnitImpl *TU;
@@ -56,7 +72,7 @@ public:
CXTranslationUnitImpl *takeTU() {
CXTranslationUnitImpl *retTU = TU;
- TU = 0;
+ TU = nullptr;
return retTU;
}
};