]> granicus.if.org Git - clang/commitdiff
Now that we are passing back "free standing decls", make sure -ast-dump works like...
authorSteve Naroff <snaroff@apple.com>
Sat, 17 Nov 2007 21:37:36 +0000 (21:37 +0000)
committerSteve Naroff <snaroff@apple.com>
Sat, 17 Nov 2007 21:37:36 +0000 (21:37 +0000)
Also added a cast to be safe...

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

AST/StmtDumper.cpp
Sema/SemaDecl.cpp

index a30b901c1c4ff018e27517be7dada302b524bf89..c6ab29880da066bb98c7acd9094a52d111245c0e 100644 (file)
@@ -219,8 +219,16 @@ void StmtDumper::DumpDeclarator(Decl *D) {
       }
     }
     fprintf(F, "\"");
+  } else if (TagDecl *TD = dyn_cast<TagDecl>(D)) {
+    // print a free standing tag decl (e.g. "struct x;").
+    const char *tagname;
+    if (const IdentifierInfo *II = TD->getIdentifier())
+      tagname = II->getName();
+    else
+      tagname = "<anonymous>";
+    fprintf(F, "\"%s %s;\"", TD->getKindName(), tagname);
+    // FIXME: print tag bodies.
   } else {
-    // FIXME: "struct x;"
     assert(0 && "Unexpected decl");
   }
 }
index bd6307f36b38bc8c89eeaec38eab44a46af3f773..2c3b335fb7a51a11f25a2f1bb5485d0a966cadd8 100644 (file)
@@ -347,7 +347,7 @@ Sema::DeclTy *Sema::ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
   // TODO: emit error on 'typedef int;'
   // if (!DS.isMissingDeclaratorOk()) Diag(...);
   
-  return DS.getTypeRep();
+  return dyn_cast_or_null<TagDecl>(static_cast<Decl *>(DS.getTypeRep()));
 }
 
 bool Sema::CheckSingleInitializer(Expr *&Init, bool isStatic,