r178800 - [libclang] Add some checks to make sure the given CXTranslationUnit is not null, before using it.
Argyrios Kyrtzidis
akyrtzi at gmail.com
Thu Apr 4 15:40:59 PDT 2013
Author: akirtzidis
Date: Thu Apr 4 17:40:59 2013
New Revision: 178800
URL: http://llvm.org/viewvc/llvm-project?rev=178800&view=rev
Log:
[libclang] Add some checks to make sure the given CXTranslationUnit is not null, before using it.
Modified:
cfe/trunk/tools/libclang/CIndex.cpp
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=178800&r1=178799&r2=178800&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Thu Apr 4 17:40:59 2013
@@ -2927,6 +2927,9 @@ CXString clang_getTranslationUnitSpellin
}
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
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;
}
More information about the cfe-commits
mailing list