]> granicus.if.org Git - clang/commitdiff
Make sure ObjCInterfaceDecl's that are forward declared always contain a valid location.
authorSteve Naroff <snaroff@apple.com>
Fri, 11 Sep 2009 00:12:01 +0000 (00:12 +0000)
committerSteve Naroff <snaroff@apple.com>
Fri, 11 Sep 2009 00:12:01 +0000 (00:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81487 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclObjC.cpp
tools/c-index-test/c-index-test.c

index 5b52ba9c8c4ece329bf3caf139b626881a3afecd..43d38f06799734e31deeb957d7b006d227075cd8 100644 (file)
@@ -111,6 +111,7 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
     } else {
       IDecl->setLocation(AtInterfaceLoc);
       IDecl->setForwardDecl(false);
+      IDecl->setClassLoc(ClassLoc);
     }
   } else {
     IDecl = ObjCInterfaceDecl::Create(Context, CurContext, AtInterfaceLoc,
@@ -1141,7 +1142,10 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
     ObjCInterfaceDecl *IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
     if (!IDecl) {  // Not already seen?  Make a forward decl.
       IDecl = ObjCInterfaceDecl::Create(Context, CurContext, AtClassLoc,
-                                        IdentList[i], SourceLocation(), true);
+                                        IdentList[i],
+                                        // FIXME: need to get the 'real'
+                                        // identifier loc from the parser.
+                                        AtClassLoc, true);
       PushOnScopeChains(IDecl, TUScope);
     }
 
index 6db4898b0869efead73109dc2b9694953ac2777a..101d71223a95df78ee099c10c833aa93575f05a6 100644 (file)
@@ -5,7 +5,7 @@
 #include <string.h>
 
 static void PrintCursor(CXCursor Cursor) {
-  printf("%s => %s\n", clang_getCursorKindSpelling(Cursor.kind),
+  printf("%s => %s ", clang_getCursorKindSpelling(Cursor.kind),
                        clang_getCursorSpelling(Cursor));
 }
 
@@ -13,8 +13,8 @@ static void DeclVisitor(CXDecl Dcl, CXCursor Cursor, CXClientData Filter)
 {
   if (!Filter || (Cursor.kind == *(enum CXCursorKind *)Filter)) {
     PrintCursor(Cursor);
-    printf("  Context: %s\n", clang_getDeclSpelling(Dcl));
-    printf("  Source:  %s (%d:%d)\n", clang_getCursorSource(Cursor),
+    printf("(Context: %s", clang_getDeclSpelling(Dcl));
+    printf(" Source:  %s (%d:%d))\n", clang_getCursorSource(Cursor),
                                       clang_getCursorLine(Cursor),
                                       clang_getCursorColumn(Cursor));
   }
@@ -24,8 +24,8 @@ static void TranslationUnitVisitor(CXTranslationUnit Unit, CXCursor Cursor,
 {
   if (!Filter || (Cursor.kind == *(enum CXCursorKind *)Filter)) {
     PrintCursor(Cursor);
-    printf("  Context: %s\n", clang_getTranslationUnitSpelling(Unit));
-    printf("  Source:  %s (%d:%d)\n", clang_getCursorSource(Cursor),
+    printf("(Context: %s", clang_getTranslationUnitSpelling(Unit));
+    printf(" Source:  %s (%d:%d))\n", clang_getCursorSource(Cursor),
                                       clang_getCursorLine(Cursor),
                                       clang_getCursorColumn(Cursor));