Skip to content

Commit

Permalink
Update _MSC_VER equality checks for msdiaNNN.dll
Browse files Browse the repository at this point in the history
Use inequality instead of equality to defend against minor version
increases in _MSC_VER. An _MSC_VER value of 1901 should still use
msdia140.dll, as described in this blog post:
https://blogs.msdn.microsoft.com/vcblog/2016/10/05/visual-c-compiler-version/

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284058 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
rnk committed Oct 12, 2016
1 parent dee2afd commit 6cf9f6d
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions lib/DebugInfo/PDB/DIA/DIASession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
using namespace llvm;
using namespace llvm::pdb;

namespace {

Error ErrorFromHResult(HRESULT Result) {
static Error ErrorFromHResult(HRESULT Result) {
switch (Result) {
case E_PDB_NOT_FOUND:
return make_error<GenericError>(generic_error_code::invalid_path);
Expand All @@ -44,7 +42,7 @@ Error ErrorFromHResult(HRESULT Result) {
}
}

Error LoadDIA(CComPtr<IDiaDataSource> &DiaDataSource) {
static Error LoadDIA(CComPtr<IDiaDataSource> &DiaDataSource) {
if (SUCCEEDED(CoCreateInstance(CLSID_DiaSource, nullptr, CLSCTX_INPROC_SERVER,
IID_IDiaDataSource,
reinterpret_cast<LPVOID *>(&DiaDataSource))))
Expand All @@ -55,12 +53,11 @@ Error LoadDIA(CComPtr<IDiaDataSource> &DiaDataSource) {
#if !defined(_MSC_VER)
return llvm::make_error<GenericError>(
"DIA is only supported when using MSVC.");
#endif

#else
const wchar_t *msdia_dll = nullptr;
#if _MSC_VER == 1900
#if _MSC_VER >= 1900 && _MSC_VER < 2000
msdia_dll = L"msdia140.dll"; // VS2015
#elif _MSC_VER == 1800
#elif _MSC_VER >= 1800
msdia_dll = L"msdia120.dll"; // VS2013
#else
#error "Unknown Visual Studio version."
Expand All @@ -71,8 +68,7 @@ Error LoadDIA(CComPtr<IDiaDataSource> &DiaDataSource) {
reinterpret_cast<LPVOID *>(&DiaDataSource))))
return ErrorFromHResult(HR);
return Error::success();
}

#endif
}

DIASession::DIASession(CComPtr<IDiaSession> DiaSession) : Session(DiaSession) {}
Expand Down

0 comments on commit 6cf9f6d

Please sign in to comment.