diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-04-04 22:40:59 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-04-04 22:40:59 +0000 |
commit | 0b602836c63e702b2ba893e8439996b226fc248f (patch) | |
tree | 2f7e91275cebcacf07b4d45eabc6e50488dc6616 /tools | |
parent | 44405b7aacdb869be129430313a7bcb050336aa4 (diff) |
[libclang] Add some checks to make sure the given CXTranslationUnit is not null, before using it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178800 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/libclang/CIndex.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 59a7e8d112..a81f1e437d 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -2927,6 +2927,9 @@ CXString clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit) { } CXCursor clang_getTranslationUnitCursor(CXTranslationUnit TU) { + if (!TU) + return clang_getNullCursor(); + ASTUnit *CXXUnit = cxtu::getASTUnit(TU); return MakeCXCursor(CXXUnit->getASTContext().getTranslationUnitDecl(), TU); } @@ -4914,6 +4917,9 @@ void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range, if (NumTokens) *NumTokens = 0; + if (!TU) + return; + ASTUnit *CXXUnit = cxtu::getASTUnit(TU); if (!CXXUnit || !Tokens || !NumTokens) return; @@ -5610,7 +5616,7 @@ extern "C" { void clang_annotateTokens(CXTranslationUnit TU, CXToken *Tokens, unsigned NumTokens, CXCursor *Cursors) { - if (NumTokens == 0 || !Tokens || !Cursors) { + if (!TU || NumTokens == 0 || !Tokens || !Cursors) { LOG_FUNC_SECTION { *Log << "<null input>"; } return; } |