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
This commit is contained in:
Erik Eckstein
2025-02-03 09:54:07 +01:00
parent c95c45201e
commit ed4863f76c

View File

@@ -2520,14 +2520,14 @@ static bool canDeclareSymbolName(StringRef symbol, ModuleDecl *fromModule) {
// to predict ways. Warn when code attempts to do so; hopefully we can // to predict ways. Warn when code attempts to do so; hopefully we can
// promote this to an error after a while. // promote this to an error after a while.
return llvm::StringSwitch<bool>(symbol)
#define FUNCTION(_, Module, Name, ...) \ #define FUNCTION(_, Module, Name, ...) \
.Case(#Name, false) \ if (symbol == #Name) { return false; } \
.Case("_" #Name, false) \ if (symbol == "_" #Name) { return false; } \
.Case(#Name "_", false) \ if (symbol == #Name "_") { return false; } \
.Case("_" #Name "_", false) if (symbol == "_" #Name "_") { return false; }
#include "swift/Runtime/RuntimeFunctions.def" #include "swift/Runtime/RuntimeFunctions.def"
.Default(true);
return true;
} }
void AttributeChecker::visitCDeclAttr(CDeclAttr *attr) { void AttributeChecker::visitCDeclAttr(CDeclAttr *attr) {