Revert "Try to unbreak Win build differently after 973519826edb76"

Breaks the build and failed pre-merge checks:
https://buildkite.com/llvm-project/premerge-checks/builds/54930#07373971-3d37-49cf-9def-22c0d724ee23

> llvm-project/lld/wasm/Writer.cpp:521:16: error: non-const lvalue reference to
>  type 'llvm::StringRef' cannot bind to a temporary of type 'llvm::StringRef'
>    for (auto &feature : used.keys()) {

This reverts commit 5881dcff7e.
This commit is contained in:
Geoffrey Martin-Noble 2021-09-02 12:05:33 -07:00
parent 5881dcff7e
commit df052e1732
3 changed files with 10 additions and 19 deletions

View File

@ -59,8 +59,9 @@ std::string x86::getX86TargetCPU(const Driver &D, const ArgList &Args,
}
StringRef CPU = ArchMap.lookup(A->getValue());
if (CPU.empty()) {
std::vector<StringRef> ValidArchs{ArchMap.keys().begin(),
ArchMap.keys().end()};
std::vector<StringRef> ValidArchs;
for (StringRef Key : ArchMap.keys())
ValidArchs.push_back(Key);
sort(ValidArchs);
D.Diag(diag::warn_drv_invalid_arch_name_with_suggestion)
<< A->getValue() << (Triple.getArch() == llvm::Triple::x86)

View File

@ -478,9 +478,13 @@ public:
explicit StringMapKeyIterator(StringMapConstIterator<ValueTy> Iter)
: base(std::move(Iter)) {}
StringRef operator*() const {
return this->wrapped()->getKey();
StringRef &operator*() {
Key = this->wrapped()->getKey();
return Key;
}
private:
StringRef Key;
};
} // end namespace llvm

View File

@ -308,21 +308,7 @@ TEST_F(StringMapTest, InsertOrAssignTest) {
EXPECT_EQ(0, try1.first->second.copy);
}
TEST_F(StringMapTest, IterMapKeysVector) {
StringMap<int> Map;
Map["A"] = 1;
Map["B"] = 2;
Map["C"] = 3;
Map["D"] = 3;
std::vector<StringRef> Keys{Map.keys().begin(), Map.keys().end()};
llvm::sort(Keys);
std::vector<StringRef> Expected{{"A", "B", "C", "D"}};
EXPECT_EQ(Expected, Keys);
}
TEST_F(StringMapTest, IterMapKeysSmallVector) {
TEST_F(StringMapTest, IterMapKeys) {
StringMap<int> Map;
Map["A"] = 1;
Map["B"] = 2;