Defer codegen of inline method definitions to the end of current top level declaration
authorHans Wennborg <hans@hanshq.net>
Fri, 6 Jun 2014 17:36:17 +0000 (17:36 +0000)
committerHans Wennborg <hans@hanshq.net>
Fri, 6 Jun 2014 17:36:17 +0000 (17:36 +0000)
commitdfcb7d6a979c8c3ac5b1044e9bcd0f06e22123b3
tree29bec582dd221a096c5a02470fe1d0fb39fa2880
parent9467be4f74a99a10924d2f3a66726351db698c71
Defer codegen of inline method definitions to the end of current top level declaration

We would previously fail to emit a definition of bar() for the following code:

  struct __declspec(dllexport) S {
    void foo() {
      t->bar();
    }
    struct T {
      void bar() {}
    };
    T *t;
  };

Note that foo() is an exported method, but bar() is not. However, foo() refers
to bar() so we need to emit its definition. We would previously fail to
realise that bar() is used.

By deferring the method definitions until the end of the top level declaration,
we can simply call EmitTopLevelDecl on them and rely on the usual mechanisms
to decide whether the method should be emitted or not.

Differential Revision: http://reviews.llvm.org/D4038

llvm-svn: 210356
clang/lib/CodeGen/ModuleBuilder.cpp
clang/test/CodeGenCXX/attr-used.cpp
clang/test/CodeGenCXX/dllexport-members.cpp
clang/test/CodeGenCXX/dllexport.cpp