Skip to content

Commit df052e1

Browse files
committed
Revert "Try to unbreak Win build differently after 9735198"
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 5881dcf.
1 parent 5881dcf commit df052e1

File tree

3 files changed

+10
-19
lines changed

3 files changed

+10
-19
lines changed

clang/lib/Driver/ToolChains/Arch/X86.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ std::string x86::getX86TargetCPU(const Driver &D, const ArgList &Args,
5959
}
6060
StringRef CPU = ArchMap.lookup(A->getValue());
6161
if (CPU.empty()) {
62-
std::vector<StringRef> ValidArchs{ArchMap.keys().begin(),
63-
ArchMap.keys().end()};
62+
std::vector<StringRef> ValidArchs;
63+
for (StringRef Key : ArchMap.keys())
64+
ValidArchs.push_back(Key);
6465
sort(ValidArchs);
6566
D.Diag(diag::warn_drv_invalid_arch_name_with_suggestion)
6667
<< A->getValue() << (Triple.getArch() == llvm::Triple::x86)

llvm/include/llvm/ADT/StringMap.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,13 @@ class StringMapKeyIterator
478478
explicit StringMapKeyIterator(StringMapConstIterator<ValueTy> Iter)
479479
: base(std::move(Iter)) {}
480480

481-
StringRef operator*() const {
482-
return this->wrapped()->getKey();
481+
StringRef &operator*() {
482+
Key = this->wrapped()->getKey();
483+
return Key;
483484
}
485+
486+
private:
487+
StringRef Key;
484488
};
485489

486490
} // end namespace llvm

llvm/unittests/ADT/StringMapTest.cpp

+1-15
Original file line numberDiff line numberDiff line change
@@ -308,21 +308,7 @@ TEST_F(StringMapTest, InsertOrAssignTest) {
308308
EXPECT_EQ(0, try1.first->second.copy);
309309
}
310310

311-
TEST_F(StringMapTest, IterMapKeysVector) {
312-
StringMap<int> Map;
313-
Map["A"] = 1;
314-
Map["B"] = 2;
315-
Map["C"] = 3;
316-
Map["D"] = 3;
317-
318-
std::vector<StringRef> Keys{Map.keys().begin(), Map.keys().end()};
319-
llvm::sort(Keys);
320-
321-
std::vector<StringRef> Expected{{"A", "B", "C", "D"}};
322-
EXPECT_EQ(Expected, Keys);
323-
}
324-
325-
TEST_F(StringMapTest, IterMapKeysSmallVector) {
311+
TEST_F(StringMapTest, IterMapKeys) {
326312
StringMap<int> Map;
327313
Map["A"] = 1;
328314
Map["B"] = 2;

0 commit comments

Comments
 (0)