[PATCH] D109181: Reland "Try to unbreak Win build differently after 973519826edb76""
Geoffrey Martin-Noble via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 2 16:20:46 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcc2d4dc3e0cc: Reland "Try to unbreak Win build differently after 973519826edb76"" (authored by thakis, committed by GMNGeoffrey).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109181/new/
https://reviews.llvm.org/D109181
Files:
clang/lib/Driver/ToolChains/Arch/X86.cpp
llvm/include/llvm/ADT/StringMap.h
llvm/unittests/ADT/StringMapTest.cpp
Index: llvm/unittests/ADT/StringMapTest.cpp
===================================================================
--- llvm/unittests/ADT/StringMapTest.cpp
+++ llvm/unittests/ADT/StringMapTest.cpp
@@ -308,7 +308,21 @@
EXPECT_EQ(0, try1.first->second.copy);
}
-TEST_F(StringMapTest, IterMapKeys) {
+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) {
StringMap<int> Map;
Map["A"] = 1;
Map["B"] = 2;
Index: llvm/include/llvm/ADT/StringMap.h
===================================================================
--- llvm/include/llvm/ADT/StringMap.h
+++ llvm/include/llvm/ADT/StringMap.h
@@ -478,13 +478,7 @@
explicit StringMapKeyIterator(StringMapConstIterator<ValueTy> Iter)
: base(std::move(Iter)) {}
- StringRef &operator*() {
- Key = this->wrapped()->getKey();
- return Key;
- }
-
-private:
- StringRef Key;
+ StringRef operator*() const { return this->wrapped()->getKey(); }
};
} // end namespace llvm
Index: clang/lib/Driver/ToolChains/Arch/X86.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -59,9 +59,8 @@
}
StringRef CPU = ArchMap.lookup(A->getValue());
if (CPU.empty()) {
- std::vector<StringRef> ValidArchs;
- for (StringRef Key : ArchMap.keys())
- ValidArchs.push_back(Key);
+ std::vector<StringRef> ValidArchs{ArchMap.keys().begin(),
+ ArchMap.keys().end()};
sort(ValidArchs);
D.Diag(diag::warn_drv_invalid_arch_name_with_suggestion)
<< A->getValue() << (Triple.getArch() == llvm::Triple::x86)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109181.370443.patch
Type: text/x-patch
Size: 1978 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210902/946367cd/attachment.bin>
More information about the cfe-commits
mailing list