From 6b9a6e390fbb92c40eb9c6ac9e7abbd88dd7a767 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Thu, 3 May 2012 16:53:59 +0000 Subject: Vendor import of clang release_31 branch r155985: http://llvm.org/svn/llvm-project/cfe/branches/release_31@155985 --- tools/libclang/CIndex.cpp | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'tools/libclang/CIndex.cpp') diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index ece91ce20e83..605cc8bdee26 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -3196,6 +3196,18 @@ CXSourceRange clang_Cursor_getSpellingNameRange(CXCursor C, } } + if (C.kind == CXCursor_ObjCCategoryDecl || + C.kind == CXCursor_ObjCCategoryImplDecl) { + if (pieceIndex > 0) + return clang_getNullRange(); + if (ObjCCategoryDecl * + CD = dyn_cast_or_null(getCursorDecl(C))) + return cxloc::translateSourceRange(Ctx, CD->getCategoryNameLoc()); + if (ObjCCategoryImplDecl * + CID = dyn_cast_or_null(getCursorDecl(C))) + return cxloc::translateSourceRange(Ctx, CID->getCategoryNameLoc()); + } + // FIXME: A CXCursor_InclusionDirective should give the location of the // filename, but we don't keep track of this. @@ -3620,9 +3632,29 @@ static enum CXChildVisitResult GetCursorVisitor(CXCursor cursor, if (clang_isDeclaration(cursor.kind)) { // Avoid having the implicit methods override the property decls. - if (ObjCMethodDecl *MD = dyn_cast_or_null(getCursorDecl(cursor))) + if (ObjCMethodDecl *MD + = dyn_cast_or_null(getCursorDecl(cursor))) { if (MD->isImplicit()) return CXChildVisit_Break; + + } else if (ObjCInterfaceDecl *ID + = dyn_cast_or_null(getCursorDecl(cursor))) { + // Check that when we have multiple @class references in the same line, + // that later ones do not override the previous ones. + // If we have: + // @class Foo, Bar; + // source ranges for both start at '@', so 'Bar' will end up overriding + // 'Foo' even though the cursor location was at 'Foo'. + if (BestCursor->kind == CXCursor_ObjCInterfaceDecl || + BestCursor->kind == CXCursor_ObjCClassRef) + if (ObjCInterfaceDecl *PrevID + = dyn_cast_or_null(getCursorDecl(*BestCursor))){ + if (PrevID != ID && + !PrevID->isThisDeclarationADefinition() && + !ID->isThisDeclarationADefinition()) + return CXChildVisit_Break; + } + } } if (clang_isExpression(cursor.kind) && -- cgit v1.2.3