]> granicus.if.org Git - clang/commit
Better codegen support for DLL attributes being dropped after the first declaration...
authorHans Wennborg <hans@hanshq.net>
Fri, 29 Aug 2014 00:16:06 +0000 (00:16 +0000)
committerHans Wennborg <hans@hanshq.net>
Fri, 29 Aug 2014 00:16:06 +0000 (00:16 +0000)
commitd4a1ae3f5696cc4c3741282569951dce3678d318
tree29f272acbaec7d3338416f800e885ba89ea26fc0
parentefc6cb24dd1fc8bf663e7bbcf8774e5a5ca04f42
Better codegen support for DLL attributes being dropped after the first declaration (PR20792)

For the following code:

  __declspec(dllimport) int f(int x);
  int user(int x) {
    return f(x);
  }
  int f(int x) { return 1; }

Clang will drop the dllimport attribute in the AST, but CodeGen would have
already put it on the LLVM::Function, and that would never get updated.
(The same thing happens for global variables.)

This makes Clang check dropped DLL attribute case each time the LLVM object
is referenced.

This isn't perfect, because we will still get it wrong if the function is
never referenced by codegen after the attribute is dropped, but this handles
the common cases and makes us not fail in the verifier.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216699 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CodeGenModule.cpp
test/CodeGen/dllimport.c