[cfe-commits] r144941 - /cfe/trunk/tools/libclang/IndexingContext.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Thu Nov 17 16:26:46 PST 2011
Author: akirtzidis
Date: Thu Nov 17 18:26:46 2011
New Revision: 144941
URL: http://llvm.org/viewvc/llvm-project?rev=144941&view=rev
Log:
[libclang] Indexing API: make sure we don't pass declarations/references without USR or location.
Modified:
cfe/trunk/tools/libclang/IndexingContext.cpp
Modified: cfe/trunk/tools/libclang/IndexingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexingContext.cpp?rev=144941&r1=144940&r2=144941&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexingContext.cpp (original)
+++ cfe/trunk/tools/libclang/IndexingContext.cpp Thu Nov 17 18:26:46 2011
@@ -105,11 +105,14 @@
void IndexingContext::handleDecl(const NamedDecl *D,
SourceLocation Loc, CXCursor Cursor,
DeclInfo &DInfo) {
- if (!CB.indexDeclaration)
+ if (!CB.indexDeclaration || !D)
return;
StrAdapter SA(*this);
getEntityInfo(D, DInfo.CXEntInfo, SA);
+ if (!DInfo.CXEntInfo.USR || Loc.isInvalid())
+ return;
+
DInfo.entityInfo = &DInfo.CXEntInfo;
DInfo.cursor = Cursor;
DInfo.loc = getIndexLoc(Loc);
@@ -307,6 +310,14 @@
D = getEntityDecl(D);
+ StrAdapter SA(*this);
+ CXIdxEntityInfo RefEntity, ParentEntity;
+ getEntityInfo(D, RefEntity, SA);
+ if (!RefEntity.USR)
+ return;
+
+ getEntityInfo(Parent, ParentEntity, SA);
+
if (onlyOneRefPerFile()) {
SourceManager &SM = Ctx->getSourceManager();
SourceLocation FileLoc = SM.getFileLoc(Loc);
@@ -326,14 +337,9 @@
return; // already in map.
}
- StrAdapter SA(*this);
CXCursor Cursor = E ? MakeCXCursor(const_cast<Expr*>(E),
const_cast<Decl*>(cast<Decl>(DC)), CXTU)
: getRefCursor(D, Loc);
-
- CXIdxEntityInfo RefEntity, ParentEntity;
- getEntityInfo(D, RefEntity, SA);
- getEntityInfo(Parent, ParentEntity, SA);
CXIdxEntityRefInfo Info = { Cursor,
getIndexLoc(Loc),
&RefEntity,
@@ -543,7 +549,7 @@
unsigned Begin = SA.getCurSize();
bool Ignore = getDeclCursorUSR(D, SA.getBuffer());
if (Ignore) {
- EntityInfo.USR = "";
+ EntityInfo.USR = 0;
} else {
EntityInfo.USR = SA.getCStr(Begin);
}
More information about the cfe-commits
mailing list