[llvm-branch-commits] [cfe-tag] r94773 - /cfe/tags/cremebrulee/cremebrulee-36.1/tools/CIndex/CIndex.cpp
Douglas Gregor
dgregor at apple.com
Thu Jan 28 16:57:22 PST 2010
Author: dgregor
Date: Thu Jan 28 18:57:22 2010
New Revision: 94773
URL: http://llvm.org/viewvc/llvm-project?rev=94773&view=rev
Log:
Merge r94769 into cremebrulee-36.1
Modified:
cfe/tags/cremebrulee/cremebrulee-36.1/tools/CIndex/CIndex.cpp
Modified: cfe/tags/cremebrulee/cremebrulee-36.1/tools/CIndex/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/tags/cremebrulee/cremebrulee-36.1/tools/CIndex/CIndex.cpp?rev=94773&r1=94772&r2=94773&view=diff
==============================================================================
--- cfe/tags/cremebrulee/cremebrulee-36.1/tools/CIndex/CIndex.cpp (original)
+++ cfe/tags/cremebrulee/cremebrulee-36.1/tools/CIndex/CIndex.cpp Thu Jan 28 18:57:22 2010
@@ -310,7 +310,10 @@
// Move the end of the input range to the end of the last token in that
// range.
- R.setEnd(TU->getPreprocessor().getLocForEndOfToken(R.getEnd(), 1));
+ SourceLocation NewEnd
+ = TU->getPreprocessor().getLocForEndOfToken(R.getEnd(), 1);
+ if (NewEnd.isValid())
+ R.setEnd(NewEnd);
return RangeCompare(TU->getSourceManager(), R, RegionOfInterest);
}
@@ -915,20 +918,23 @@
}
void clang_disposeIndex(CXIndex CIdx) {
- assert(CIdx && "Passed null CXIndex");
- delete static_cast<CIndexer *>(CIdx);
+ if (CIdx)
+ delete static_cast<CIndexer *>(CIdx);
}
void clang_setUseExternalASTGeneration(CXIndex CIdx, int value) {
- assert(CIdx && "Passed null CXIndex");
- CIndexer *CXXIdx = static_cast<CIndexer *>(CIdx);
- CXXIdx->setUseExternalASTGeneration(value);
+ if (CIdx) {
+ CIndexer *CXXIdx = static_cast<CIndexer *>(CIdx);
+ CXXIdx->setUseExternalASTGeneration(value);
+ }
}
// FIXME: need to pass back error info.
CXTranslationUnit clang_createTranslationUnit(CXIndex CIdx,
const char *ast_filename) {
- assert(CIdx && "Passed null CXIndex");
+ if (!CIdx)
+ return 0;
+
CIndexer *CXXIdx = static_cast<CIndexer *>(CIdx);
return ASTUnit::LoadFromPCHFile(ast_filename, CXXIdx->getDiags(),
@@ -943,7 +949,9 @@
const char **command_line_args,
unsigned num_unsaved_files,
struct CXUnsavedFile *unsaved_files) {
- assert(CIdx && "Passed null CXIndex");
+ if (!CIdx)
+ return 0;
+
CIndexer *CXXIdx = static_cast<CIndexer *>(CIdx);
llvm::SmallVector<ASTUnit::RemappedFile, 4> RemappedFiles;
@@ -1077,12 +1085,14 @@
}
void clang_disposeTranslationUnit(CXTranslationUnit CTUnit) {
- assert(CTUnit && "Passed null CXTranslationUnit");
- delete static_cast<ASTUnit *>(CTUnit);
+ if (CTUnit)
+ delete static_cast<ASTUnit *>(CTUnit);
}
CXString clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit) {
- assert(CTUnit && "Passed null CXTranslationUnit");
+ if (!CTUnit)
+ return CIndexer::createCXString("");
+
ASTUnit *CXXUnit = static_cast<ASTUnit *>(CTUnit);
return CIndexer::createCXString(CXXUnit->getOriginalSourceFileName().c_str(),
true);
@@ -1216,7 +1226,6 @@
if (!SFile)
return 0;
- assert(SFile && "Passed null CXFile");
FileEntry *FEnt = static_cast<FileEntry *>(SFile);
return FEnt->getName();
}
@@ -1225,7 +1234,6 @@
if (!SFile)
return 0;
- assert(SFile && "Passed null CXFile");
FileEntry *FEnt = static_cast<FileEntry *>(SFile);
return FEnt->getModificationTime();
}
@@ -1309,7 +1317,6 @@
}
CXString clang_getCursorSpelling(CXCursor C) {
- assert(getCursorDecl(C) && "CXCursor has null decl");
if (clang_isTranslationUnit(C.kind))
return clang_getTranslationUnitSpelling(C.data[2]);
More information about the llvm-branch-commits
mailing list