This is an archive of the discontinued LLVM Phabricator instance.

Inherit dll attributes to static locals
ClosedPublic

Authored by hans on Jun 13 2014, 8:58 AM.

Details

Diff Detail

Repository
rL LLVM

Event Timeline

hans updated this revision to Diff 10392.Jun 13 2014, 8:58 AM
hans retitled this revision from to Inherit dll attributes to static locals.
hans updated this object.
hans edited the test plan for this revision. (Show Details)
hans added reviewers: rnk, nrieck.
hans added subscribers: Unknown Object (MLST), hansw.

It would be nice to have similar tests for the Itanium ABI, but I suspect that you are less interested in that.

lib/CodeGen/MicrosoftCXXABI.cpp
1429 ↗(On Diff #10392)

clsas -> class.

test/CodeGenCXX/dllexport.cpp
274 ↗(On Diff #10392)

It really would be nice to split this file up at some point.

nrieck added inline comments.Jun 13 2014, 11:27 AM
lib/CodeGen/MicrosoftCXXABI.cpp
1429 ↗(On Diff #10392)

"class"

lib/Sema/SemaDecl.cpp
9112 ↗(On Diff #10392)

There's already a getDLLAttr() function somewhere, but I guess it's not available here. Maybe this helper could be moved to SemaInternal.h?

test/CodeGenCXX/dllexport.cpp
257 ↗(On Diff #10392)

These tests should be at the end of the section for globals (like in SemaCXX/dllexport.cpp) IMO. Same goes for the dllimport tests.

262 ↗(On Diff #10392)

These checks can be MSC-DAG.

267 ↗(On Diff #10392)

Superfluous ";"

269 ↗(On Diff #10392)

These checks can be MSC-DAG, and please add a comment that MinGW doesn't do this and is not just forgotten here (at least my tests with GCC show this to be true).

hans added a comment.Jun 13 2014, 2:32 PM

Thanks for the review!

It would be nice to have similar tests for the Itanium ABI, but I suspect that you are less interested in that.

As Nico pointed out, they don't seem to export the static locals :/

lib/CodeGen/MicrosoftCXXABI.cpp
1429 ↗(On Diff #10392)

Done.

lib/Sema/SemaDecl.cpp
9112 ↗(On Diff #10392)

Sounds good to me.

test/CodeGenCXX/dllexport.cpp
257 ↗(On Diff #10392)

Done.

262 ↗(On Diff #10392)

Done.

267 ↗(On Diff #10392)

Removed.

269 ↗(On Diff #10392)

Done.

hans updated this revision to Diff 10407.Jun 13 2014, 2:33 PM

Addressing review comments.

Please take another look!

hans added a comment.Jun 16 2014, 5:59 PM

Nico: does the new version of the patch look ok to you?

rnk added inline comments.Jun 17 2014, 5:50 PM
lib/Sema/SemaDecl.cpp
9108 ↗(On Diff #10407)

Should this go before checkAttributesAfterMerging? Consider this obnoxious test case:

int f();
inline __declspec(dllexport) int g() {
  static __declspec(dllimport) int x = f();
  return x;
}
hans added inline comments.Jun 17 2014, 7:27 PM
lib/Sema/SemaDecl.cpp
9108 ↗(On Diff #10407)

Local variables cannot have explicit dll attributes. They can only get them by inheriting from the function they're part of, so calling checkAttributesAfterMerging to check up on the attribute we just added seems redundant.

rnk accepted this revision.Jun 17 2014, 7:49 PM
rnk edited edge metadata.

lgtm

lib/Sema/SemaDecl.cpp
9108 ↗(On Diff #10407)

OK. I assume this is covered by Nico's extensive test cases. :)

This revision is now accepted and ready to land.Jun 17 2014, 7:49 PM
nrieck edited edge metadata.Jun 18 2014, 8:08 AM
In D4136#10, @hans wrote:

Nico: does the new version of the patch look ok to you?

LGTM

lib/Sema/SemaDecl.cpp
9108 ↗(On Diff #10407)

Yup, this is handled by requiring external linkage.

hans closed this revision.Jun 18 2014, 9:03 AM
hans updated this revision to Diff 10570.

Closed by commit rL211173 (authored by @hans).