[lldb] Fix build with GCC 9 after "[ADT] Use Empty Base Optimization for Allocators"
authorMartin Storsjö <martin@martin.st>
Wed, 13 Jul 2022 09:53:31 +0000 (12:53 +0300)
committerMartin Storsjö <martin@martin.st>
Wed, 13 Jul 2022 09:57:04 +0000 (12:57 +0300)
This fixes this compilation error, after
a565509308f9372c4de1c4c32afde461a42e81c8:

In file included from ../tools/lldb/include/lldb/Host/Host.h:14,
                 from ../tools/lldb/source/Host/common/File.cpp:28:
../tools/lldb/include/lldb/Utility/Environment.h: In copy constructor ‘lldb_private::Environment::Environment(const lldb_private::Environment&)’:
../tools/lldb/include/lldb/Utility/Environment.h:60:49: error: call of overloaded ‘StringMap(const lldb_private::Environment&)’ is ambiguous
   60 |   Environment(const Environment &RHS) : Base(RHS) {}
      |                                                 ^
In file included from ../include/llvm/Support/YAMLTraits.h:16,
                 from ../tools/lldb/include/lldb/Utility/ConstString.h:15,
                 from ../tools/lldb/include/lldb/Utility/FileSpec.h:15,
                 from ../tools/lldb/include/lldb/Host/FileSystem.h:14,
                 from ../tools/lldb/source/Host/common/File.cpp:27:
../include/llvm/ADT/StringMap.h:137:3: note: candidate: ‘llvm::StringMap<ValueTy, AllocatorTy>::StringMap(const llvm::StringMap<ValueTy, AllocatorTy>&) [with ValueTy = std::__cxx11::basic_string<char>; AllocatorTy = llvm::MallocAllocator]’
  137 |   StringMap(const StringMap &RHS)
      |   ^~~~~~~~~
../include/llvm/ADT/StringMap.h:122:12: note: candidate: ‘llvm::StringMap<ValueTy, AllocatorTy>::StringMap(AllocatorTy) [with ValueTy = std::__cxx11::basic_string<char>; AllocatorTy = llvm::MallocAllocator]’
  122 |   explicit StringMap(AllocatorTy A)
      |            ^~~~~~~~~

lldb/include/lldb/Utility/Environment.h

index c1549a3d60a6430c76e18858f819ed5d4fee9919..27d740402c30c4c5a0c8014f3695d6a72c75fbf6 100644 (file)
@@ -57,7 +57,7 @@ public:
   using Base::operator[];
 
   Environment() {}
-  Environment(const Environment &RHS) : Base(RHS) {}
+  Environment(const Environment &RHS) : Base(static_cast<const Base&>(RHS)) {}
   Environment(Environment &&RHS) : Base(std::move(RHS)) {}
   Environment(char *const *Env)
       : Environment(const_cast<const char *const *>(Env)) {}