[clang] df052e1 - Revert "Try to unbreak Win build differently after 973519826edb76"
Geoffrey Martin-Noble via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 2 12:07:04 PDT 2021
Author: Geoffrey Martin-Noble
Date: 2021-09-02T12:05:33-07:00
New Revision: df052e1732ab57f5d9c684ceeaed3ab39073cd9f
URL: https://github.com/llvm/llvm-project/commit/df052e1732ab57f5d9c684ceeaed3ab39073cd9f
DIFF: https://github.com/llvm/llvm-project/commit/df052e1732ab57f5d9c684ceeaed3ab39073cd9f.diff
LOG: 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 5881dcff7e76a68323edc8bb3c6e14420ad9cf7c.
Added:
Modified:
clang/lib/Driver/ToolChains/Arch/X86.cpp
llvm/include/llvm/ADT/StringMap.h
llvm/unittests/ADT/StringMapTest.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index bfa008f964e19..2e43c455b28fd 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -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)
diff --git a/llvm/include/llvm/ADT/StringMap.h b/llvm/include/llvm/ADT/StringMap.h
index fa99ecd81106e..003e62d98ec23 100644
--- a/llvm/include/llvm/ADT/StringMap.h
+++ b/llvm/include/llvm/ADT/StringMap.h
@@ -478,9 +478,13 @@ class StringMapKeyIterator
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
diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp
index f38a60452e3c7..6a3cca5a4a324 100644
--- a/llvm/unittests/ADT/StringMapTest.cpp
+++ b/llvm/unittests/ADT/StringMapTest.cpp
@@ -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;
More information about the cfe-commits
mailing list