From b55ac6e9cb539a52e6bdc5ce6bf40258dd41f63e Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Fri, 21 Jul 2023 23:23:32 -0700 Subject: [PATCH] [VirtualFileSystem] Make gcc<7.5 happy after 75d71800aa384ee58663d892c325572f5588df2a MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit There is a libstdc++ stl_map.h bug that is only back ported to 7.5. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78595#c13 ``` /tmp/opt/gcc-7.3.0/include/c++/7.3.0/bits/stl_tree.h:2091:28: error: no matching function for call to ‘std::_Rb_tree, std::pair, std::unique_ptr >, std::_Select1st, std::unique_ptr > >, std::less >, std::allocator, std::unique_ptr > > >::_M_get_insert_unique_pos(std::pair >::first_type&)’ = _M_get_insert_unique_pos(_KeyOfValue()(__v)); ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ ``` Just construct a std::string from StringRef to work around it. --- llvm/lib/Support/VirtualFileSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp index 9c1c990..25d057b 100644 --- a/llvm/lib/Support/VirtualFileSystem.cpp +++ b/llvm/lib/Support/VirtualFileSystem.cpp @@ -749,7 +749,7 @@ public: } InMemoryNode *addChild(StringRef Name, std::unique_ptr Child) { - return Entries.insert(make_pair(Name, std::move(Child))) + return Entries.insert(make_pair(Name.str(), std::move(Child))) .first->second.get(); } -- 2.7.4