llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.06k stars 11.59k forks source link

Warn on missing exports in microsoft mode? #23553

Open nico opened 9 years ago

nico commented 9 years ago
Bugzilla Link 23179
Version trunk
OS All
CC @majnemer,@zmodem

Extended Description

Consider something like this:

struct CpuProfileDeoptFrame { int script_id; };

// XXX //template class V8_EXPORT std::vector;

struct V8_EXPORT CpuProfileDeoptInfo { std::vector stack; };

Unless the line marked XXX is present, cl will warn on this with

2>D:\src\v8\include/v8-profiler.h(31): warning C4251: 'v8::CpuProfileDeoptInfo::stack' : class 'std::vector<v8::CpuProfileDeoptFrame,std::allocator<_Ty>>' needs to have dll-interface to be used by clients of struct 'v8::CpuProfileDeoptInfo' 2> with 2> [ 2> _Ty=v8::CpuProfileDeoptFrame 2> ] (....\src\compiler\change-lowering.cc)

There's probably a good reason for that -- should we warn on this too?

zmodem commented 9 years ago

Seems like a nice warning. It works without templates too:

struct S { S(); };

struct __declspec(dllexport) T { S s; };

And inner classes:

struct __declspec(dllexport) T { struct Inner { Inner(); }; Inner x; }

But it doesn't warn here, despite this being a classic in Chromium by now:

struct __declspec(dllexport) T { struct Inner { Inner(); }; void f() { Inner x; } }

I wonder why.. f() is just as exported as the constructor for T..