[llvm] r228756 - Oops. Don't call Windows functions on non-windows.

David Blaikie dblaikie at gmail.com
Wed Feb 11 11:13:46 PST 2015


On Wed, Feb 11, 2015 at 11:09 AM, Zachary Turner <zturner at google.com> wrote:

> It's difficult to move this specific piece to the DIA implementation, and
> I think should probably stay here.  CoInitialize is supposed to be called
> by the application once per thread.  We can, of course, wrap this up inside
> the library with the use of some thread specific data, but the normal
> paradigm for doing programming with COM is to do this very early in main
> for the main thread.  It's usually the responsibility of the executable.
> Because if you write it your library, what happens if someone else called
> it earlier with a different set of parameters?
>

Fair enough.


> It could be possible to write something like llvm::pdb::Initialize(); and
> llvm::pdb::Shutdown(); but this still has side effects outside of the
> library, and someone who wishes to use this library as part of a larger
> application would have confusing semantics.
>

Maybe something more explicit (llvm::CoInit?) but at least hides the 3
instances of #ifdef in an implementation, and possibly is a scoped device
(so 9 lines come down to 2).

- Dave


>
> On Tue Feb 10 2015 at 2:56:38 PM David Blaikie <dblaikie at gmail.com> wrote:
>
>> On Tue, Feb 10, 2015 at 2:47 PM, Zachary Turner <zturner at google.com>
>> wrote:
>>
>>> Author: zturner
>>> Date: Tue Feb 10 16:47:14 2015
>>> New Revision: 228756
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=228756&view=rev
>>> Log:
>>> Oops.  Don't call Windows functions on non-windows.
>>>
>>> Modified:
>>>     llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
>>>
>>> Modified: llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp?rev=228756&r1=228755&r2=228756&view=diff
>>>
>>> ==============================================================================
>>> --- llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp (original)
>>> +++ llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp Tue Feb 10 16:47:14
>>> 2015
>>> @@ -15,6 +15,7 @@
>>>
>>>  #include "llvm/ADT/ArrayRef.h"
>>>  #include "llvm/ADT/StringExtras.h"
>>> +#include "llvm/Config/config.h"
>>>  #include "llvm/DebugInfo/PDB/PDB.h"
>>>  #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
>>>  #include "llvm/DebugInfo/PDB/IPDBSession.h"
>>> @@ -30,7 +31,9 @@
>>>  #include "llvm/Support/PrettyStackTrace.h"
>>>  #include "llvm/Support/Signals.h"
>>>
>>> +#if defined(HAVE_DIA_SDK)
>>>
>>
>> I'm assuming this logic will eventually be moved/built in to the DIA PDB
>> library implementation?
>>
>>
>>>  #include <Windows.h>
>>> +#endif
>>>
>>>  using namespace llvm;
>>>
>>> @@ -88,11 +91,16 @@ int main(int argc_, const char *argv_[])
>>>
>>>    cl::ParseCommandLineOptions(argv.size(), argv.data(), "LLVM PDB
>>> Dumper\n");
>>>
>>> +#if defined(HAVE_DIA_SDK)
>>>    CoInitializeEx(nullptr, COINIT_MULTITHREADED);
>>> +#endif
>>>
>>>    std::for_each(opts::InputFilenames.begin(),
>>> opts::InputFilenames.end(),
>>>                  dumpInput);
>>>
>>> +#if defined(HAVE_DIA_SDK)
>>>    CoUninitialize();
>>> +#endif
>>> +
>>>    return 0;
>>>  }
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150211/73f80854/attachment.html>


More information about the llvm-commits mailing list