summaryrefslogtreecommitdiffstats
path: root/clang/tools
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-12-13 18:47:35 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-12-13 18:47:35 +0000
commitccdf8276a3fc447a3d7657f3dd7fcce7624affdf (patch)
tree05623d0c08d7bb62dd03dc1d938fb3d2e52aacd0 /clang/tools
parent9f2a83eb595b41db9d89c86d12380ad3977dbbf7 (diff)
downloadbcm5719-llvm-ccdf8276a3fc447a3d7657f3dd7fcce7624affdf.tar.gz
bcm5719-llvm-ccdf8276a3fc447a3d7657f3dd7fcce7624affdf.zip
[libclang] Indexing API: Fix suppressing of references in macros and suppress
@class forward references. rdar://10568080&10568103&10568119 llvm-svn: 146496
Diffstat (limited to 'clang/tools')
-rw-r--r--clang/tools/c-index-test/c-index-test.c6
-rw-r--r--clang/tools/libclang/IndexingContext.cpp17
2 files changed, 20 insertions, 3 deletions
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c
index 1370e21c81b..fdc88a015ea 100644
--- a/clang/tools/c-index-test/c-index-test.c
+++ b/clang/tools/c-index-test/c-index-test.c
@@ -1580,6 +1580,10 @@ static void printCXIndexLoc(CXIdxLoc loc) {
printf("<null loc>");
return;
}
+ if (!file) {
+ printf("<no idxfile>");
+ return;
+ }
filename = clang_getFileName((CXFile)file);
cname = clang_getCString(filename);
end = cname + strlen(cname);
@@ -1694,9 +1698,9 @@ static void printEntityInfo(const char *cb,
printf("%s: kind: %s%s", cb, getEntityKindString(info->kind),
getEntityTemplateKindString(info->templateKind));
- printf(" | lang: %s", getEntityLanguageString(info->lang));
printf(" | name: %s", name);
printf(" | USR: %s", info->USR);
+ printf(" | lang: %s", getEntityLanguageString(info->lang));
}
static void printBaseClassInfo(CXClientData client_data,
diff --git a/clang/tools/libclang/IndexingContext.cpp b/clang/tools/libclang/IndexingContext.cpp
index b95d22d010a..66e552c8f47 100644
--- a/clang/tools/libclang/IndexingContext.cpp
+++ b/clang/tools/libclang/IndexingContext.cpp
@@ -228,7 +228,8 @@ bool IndexingContext::handleDecl(const NamedDecl *D,
if (!DInfo.EntInfo.USR || Loc.isInvalid())
return false;
- markEntityOccurrenceInFile(D, Loc);
+ if (suppressRefs())
+ markEntityOccurrenceInFile(D, Loc);
DInfo.entityInfo = &DInfo.EntInfo;
DInfo.cursor = Cursor;
@@ -304,6 +305,12 @@ bool IndexingContext::handleObjCClass(const ObjCClassDecl *D) {
SourceLocation Loc = Ref->getLocation();
bool isRedeclaration = IFaceD->getLocation() != Loc;
+ // For @class forward declarations, suppress them the same way as references.
+ if (suppressRefs()) {
+ if (markEntityOccurrenceInFile(IFaceD, Loc))
+ return false; // already occurred.
+ }
+
ObjCContainerDeclInfo ContDInfo(/*isForwardRef=*/true, isRedeclaration,
/*isImplementation=*/false);
return handleObjCContainer(IFaceD, Loc,
@@ -373,6 +380,9 @@ bool IndexingContext::handleObjCCategory(const ObjCCategoryDecl *D) {
: D->getCategoryNameLoc();
getEntityInfo(IFaceD, ClassEntity, SA);
+ if (suppressRefs())
+ markEntityOccurrenceInFile(IFaceD, ClassLoc);
+
CatDInfo.ObjCCatDeclInfo.containerInfo = &CatDInfo.ObjCContDeclInfo;
if (IFaceD) {
CatDInfo.ObjCCatDeclInfo.objcClass = &ClassEntity;
@@ -583,10 +593,13 @@ bool IndexingContext::handleCXXRecordDecl(const CXXRecordDecl *RD,
bool IndexingContext::markEntityOccurrenceInFile(const NamedDecl *D,
SourceLocation Loc) {
+ if (!D || Loc.isInvalid())
+ return true;
+
SourceManager &SM = Ctx->getSourceManager();
D = getEntityDecl(D);
- std::pair<FileID, unsigned> LocInfo = SM.getDecomposedLoc(Loc);
+ std::pair<FileID, unsigned> LocInfo = SM.getDecomposedLoc(SM.getFileLoc(Loc));
FileID FID = LocInfo.first;
if (FID.isInvalid())
return true;
OpenPOWER on IntegriCloud