Skip to content

Commit

Permalink
Fix compile error: Use explicit conversion of unique_ptr to bool
Browse files Browse the repository at this point in the history
The aging LLVM code is converting  an object of type `unique_ptr` to
an object  of type  `bool`; this is  being done  implicitly, thereby
causing  a compile-time  error  with  a modern,  standards-compliant
compiler.

This is explained well here:

    microsoft/DirectXShaderCompiler#1692

In particular:

> The C++  standard specifies operator  bool on unique_ptr  as being
> explicit,  so this  is  clearly a  bug in  the  LLVM source  code:
> https://en.cppreference.com/w/cpp/memory/unique_ptr/operator_bool

This commit merely makes the  conversion explicit, allowing the code
to be built by GCC version 9.1.0.

This  bug was  fixed  by the  LLVM  project proper  as  part of  the
following commit:

    69341e6abca92f7f118ee7bd99be0cdfc649386f
    2016-04-08
    llvm/llvm-project@69341e6
  • Loading branch information
mfwitten committed Sep 21, 2019
1 parent 1eb8559 commit 27298d0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/llvm/IR/ValueMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class ValueMap {

~ValueMap() {}

bool hasMD() const { return MDMap; }
bool hasMD() const { return bool(MDMap); }
MDMapT &MD() {
if (!MDMap)
MDMap.reset(new MDMapT);
Expand Down

0 comments on commit 27298d0

Please sign in to comment.