]> granicus.if.org Git - clang/commitdiff
[libclang] Stick to the silly notion that a forward class/protocol
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 4 Feb 2012 01:04:58 +0000 (01:04 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 4 Feb 2012 01:04:58 +0000 (01:04 +0000)
declaration is a reference. rdar://10749990

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149733 91177308-0d34-0410-b5e6-96231b3b80d8

tools/libclang/CIndex.cpp

index a2c0fb0bdfb1424fb4d68513f748be2dd51defe1..675126de09d4fe37ba5affcf7c3de2d87967724e 100644 (file)
@@ -560,6 +560,20 @@ bool CursorVisitor::VisitDeclContext(DeclContext *DC) {
     if (D->getLexicalDeclContext() != DC)
       continue;
     CXCursor Cursor = MakeCXCursor(D, TU, RegionOfInterest);
+
+    // FIXME: ObjCClassRef/ObjCProtocolRef for forward class/protocol
+    // declarations is a mismatch with the compiler semantics.
+    if (Cursor.kind == CXCursor_ObjCInterfaceDecl) {
+      ObjCInterfaceDecl *ID = cast<ObjCInterfaceDecl>(D);
+      if (!ID->isThisDeclarationADefinition())
+        Cursor = MakeCursorObjCClassRef(ID, ID->getLocation(), TU);
+
+    } else if (Cursor.kind == CXCursor_ObjCProtocolDecl) {
+      ObjCProtocolDecl *PD = cast<ObjCProtocolDecl>(D);
+      if (!PD->isThisDeclarationADefinition())
+        Cursor = MakeCursorObjCProtocolRef(PD, PD->getLocation(), TU);
+    }
+
     const llvm::Optional<bool> &V = shouldVisitCursor(Cursor);
     if (!V.hasValue())
       continue;