Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 193b99d

Browse files
authored
Merge pull request #17 from jrose-apple/string-switch-safety
Prevent unsafe use of llvm::StringSwitch.
2 parents a556865 + 02ad3e2 commit 193b99d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

include/llvm/ADT/StringSwitch.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,21 @@ class StringSwitch {
5353
explicit StringSwitch(StringRef S)
5454
: Str(S), Result(nullptr) { }
5555

56+
// StringSwitch is not copyable.
57+
StringSwitch(const StringSwitch &) = delete;
58+
void operator=(const StringSwitch &) = delete;
59+
60+
StringSwitch(StringSwitch &&other) {
61+
*this = std::move(other);
62+
}
63+
StringSwitch &operator=(StringSwitch &&other) {
64+
Str = other.Str;
65+
Result = other.Result;
66+
return *this;
67+
}
68+
69+
~StringSwitch() = default;
70+
5671
template<unsigned N>
5772
LLVM_ATTRIBUTE_ALWAYS_INLINE
5873
StringSwitch& Case(const char (&S)[N], const T& Value) {

0 commit comments

Comments
 (0)