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

Prevent unsafe use of llvm::StringSwitch. #17

Merged
merged 2 commits into from
Jul 29, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions include/llvm/ADT/StringSwitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ class StringSwitch {
explicit StringSwitch(StringRef S)
: Str(S), Result(nullptr) { }

// StringSwitch is not copyable.
StringSwitch(const StringSwitch &) = delete;
void operator=(const StringSwitch &) = delete;

StringSwitch(StringSwitch &&other) {
*this = std::move(other);
}
StringSwitch &operator=(StringSwitch &&other) {
Str = other.Str;
Result = other.Result;
return *this;
}

~StringSwitch() = default;

template<unsigned N>
LLVM_ATTRIBUTE_ALWAYS_INLINE
StringSwitch& Case(const char (&S)[N], const T& Value) {
Expand Down