Skip to content

Commit b068ac5

Browse files
authored
Merge pull request #3294 from bulbazord/reject-objc-embrace-swift
[lldb] SwiftLanguageRuntime::MethodName::Parse should reject objc methods
2 parents d5a7a34 + 1febca3 commit b068ac5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeNames.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,16 @@ void SwiftLanguageRuntime::MethodName::Parse() {
980980
llvm::StringRef full(m_full.GetCString());
981981
bool was_operator = false;
982982

983+
if (full.find("+") != llvm::StringRef::npos ||
984+
full.find("-") != llvm::StringRef::npos ||
985+
full.find("[") != llvm::StringRef::npos) {
986+
// Swift identifiers cannot contain +, -, or [. Objective-C expressions
987+
// will frequently begin with one of these characters, so reject these
988+
// defensively.
989+
m_parse_error = true;
990+
return;
991+
}
992+
983993
if (full.find("::") != llvm::StringRef::npos) {
984994
// :: is not an allowed operator in Swift (func ::(...) { fails to
985995
// compile)

0 commit comments

Comments
 (0)