Skip to content

Commit 44dd4df

Browse files
eecksteinatrick
authored andcommitted
Sema: don't use llvm::StringSwitch for runtime function names
Using `llvm::StringSwitch` with this many cases causes clang to crash due to a stack overflow. Works around rdar://143944155 (cherry picked from commit ed4863f)
1 parent abab647 commit 44dd4df

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,14 +2294,14 @@ static bool canDeclareSymbolName(StringRef symbol, ModuleDecl *fromModule) {
22942294
// to predict ways. Warn when code attempts to do so; hopefully we can
22952295
// promote this to an error after a while.
22962296

2297-
return llvm::StringSwitch<bool>(symbol)
2298-
#define FUNCTION(_, Name, ...) \
2299-
.Case(#Name, false) \
2300-
.Case("_" #Name, false) \
2301-
.Case(#Name "_", false) \
2302-
.Case("_" #Name "_", false)
2297+
#define FUNCTION(_, Module, Name, ...) \
2298+
if (symbol == #Name) { return false; } \
2299+
if (symbol == "_" #Name) { return false; } \
2300+
if (symbol == #Name "_") { return false; } \
2301+
if (symbol == "_" #Name "_") { return false; }
23032302
#include "swift/Runtime/RuntimeFunctions.def"
2304-
.Default(true);
2303+
2304+
return true;
23052305
}
23062306

23072307
void AttributeChecker::visitCDeclAttr(CDeclAttr *attr) {

0 commit comments

Comments
 (0)