From: Chris Lattner Date: Wed, 6 Feb 2008 04:51:19 +0000 (+0000) Subject: Finish off the refactoring of type handling stuff. Now we recompile every X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9eee0f8593fcd2426b043fb0164f87ff36bd213f;p=clang Finish off the refactoring of type handling stuff. Now we recompile every tag decl after it has been completed git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46798 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/CodeGen/ModuleBuilder.cpp b/CodeGen/ModuleBuilder.cpp index c59ef447e6..8d3207a19c 100644 --- a/CodeGen/ModuleBuilder.cpp +++ b/CodeGen/ModuleBuilder.cpp @@ -71,9 +71,19 @@ namespace { // FIXME: implement C++ linkage, C linkage works mostly by C // language reuse already. } else { - Builder->EmitType(cast(D)); + assert(isa(D) && "Unknown top level decl"); + // TODO: handle debug info? } } + + /// HandleTagDeclDefinition - This callback is invoked each time a TagDecl + /// (e.g. struct, union, enum, class) is completed. This allows the client to + /// hack on the type, which can occur at any point in the file (because these + /// can be defined in declspecs). + virtual void HandleTagDeclDefinition(TagDecl *D) { + Builder->EmitType(D); + } + }; } diff --git a/test/CodeGen/types.c b/test/CodeGen/types.c index 01286e8962..2bbcec106a 100644 --- a/test/CodeGen/types.c +++ b/test/CodeGen/types.c @@ -1,4 +1,4 @@ -// RUN: clang -emit-llvm %s +// RUN: clang -emit-llvm <%s struct FileName { struct FileName *next; @@ -10,7 +10,12 @@ struct ieeeExternal { } *exthead; -void f() +void test1() { struct ieeeExternal *exttmp = exthead; } + +struct MpegEncContext; +typedef struct MpegEncContext {int pb;} MpegEncContext; +static void test2(void) {MpegEncContext s; s.pb;} +