diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/CIndex/CIndex.cpp | 30 | ||||
-rw-r--r-- | tools/CIndex/CIndex.exports | 2 | ||||
-rw-r--r-- | tools/c-index-test/c-index-test.c | 8 |
3 files changed, 14 insertions, 26 deletions
diff --git a/tools/CIndex/CIndex.cpp b/tools/CIndex/CIndex.cpp index 5ffa6d78e8..71d76536c4 100644 --- a/tools/CIndex/CIndex.cpp +++ b/tools/CIndex/CIndex.cpp @@ -116,6 +116,10 @@ class TUVisitor : public DeclVisitor<TUVisitor> { if (ND->getPCHLevel() > MaxPCHLevel) return; + // Filter any implicit declarations (since the source info will be bogus). + if (ND->isImplicit()) + return; + CXCursor C = { CK, ND, 0 }; Callback(TUnit, C, CData); } @@ -721,26 +725,12 @@ static enum CXCursorKind TranslateKind(Decl *D) { // // CXCursor Operations. // -void clang_initCXLookupHint(CXLookupHint *hint) { - memset(hint, 0, sizeof(*hint)); -} - CXCursor clang_getCursor(CXTranslationUnit CTUnit, const char *source_name, - unsigned line, unsigned column) { - return clang_getCursorWithHint(CTUnit, source_name, line, column, NULL); -} - -CXCursor clang_getCursorWithHint(CXTranslationUnit CTUnit, - const char *source_name, - unsigned line, unsigned column, - CXLookupHint *hint) + unsigned line, unsigned column) { assert(CTUnit && "Passed null CXTranslationUnit"); ASTUnit *CXXUnit = static_cast<ASTUnit *>(CTUnit); - // FIXME: Make this better. - CXDecl RelativeToDecl = hint ? hint->decl : NULL; - FileManager &FMgr = CXXUnit->getFileManager(); const FileEntry *File = FMgr.getFile(source_name, source_name+strlen(source_name)); @@ -751,9 +741,13 @@ CXCursor clang_getCursorWithHint(CXTranslationUnit CTUnit, SourceLocation SLoc = CXXUnit->getSourceManager().getLocation(File, line, column); - ASTLocation ALoc = ResolveLocationInAST(CXXUnit->getASTContext(), SLoc, - static_cast<NamedDecl *>(RelativeToDecl)); - + ASTLocation LastLoc = CXXUnit->getLastASTLocation(); + + ASTLocation ALoc = ResolveLocationInAST(CXXUnit->getASTContext(), SLoc, + &LastLoc); + if (ALoc.isValid()) + CXXUnit->setLastASTLocation(ALoc); + Decl *Dcl = ALoc.getParentDecl(); if (ALoc.isNamedRef()) Dcl = ALoc.AsNamedRef().ND; diff --git a/tools/CIndex/CIndex.exports b/tools/CIndex/CIndex.exports index b726aa00e9..d2933cb336 100644 --- a/tools/CIndex/CIndex.exports +++ b/tools/CIndex/CIndex.exports @@ -7,7 +7,6 @@ _clang_getCursorFromDecl _clang_getCursorKind _clang_getCursorLine _clang_getCursorSource -_clang_getCursorWithHint _clang_getDeclarationName _clang_getDeclSpelling _clang_getDeclLine @@ -21,7 +20,6 @@ _clang_loadTranslationUnit _clang_createTranslationUnit _clang_createTranslationUnitFromSourceFile _clang_disposeTranslationUnit -_clang_initCXLookupHint _clang_isDeclaration _clang_isReference _clang_isDefinition diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c index 56b29ac136..8791ee20a5 100644 --- a/tools/c-index-test/c-index-test.c +++ b/tools/c-index-test/c-index-test.c @@ -70,7 +70,6 @@ static void TranslationUnitVisitor(CXTranslationUnit Unit, CXCursor Cursor, CXCursor Ref; while (startBuf < endBuf) { - CXLookupHint hint; if (*startBuf == '\n') { startBuf++; curLine++; @@ -78,11 +77,8 @@ static void TranslationUnitVisitor(CXTranslationUnit Unit, CXCursor Cursor, } else if (*startBuf != '\t') curColumn++; - clang_initCXLookupHint(&hint); - hint.decl = Cursor.decl; - - Ref = clang_getCursorWithHint(Unit, clang_getCursorSource(Cursor), - curLine, curColumn, &hint); + Ref = clang_getCursor(Unit, clang_getCursorSource(Cursor), + curLine, curColumn); if (Ref.kind == CXCursor_NoDeclFound) { /* Nothing found here; that's fine. */ } else if (Ref.kind != CXCursor_FunctionDecl) { |