mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[sourcekitd] Fix crash in the document structure request when a class name starts with a number
rdar://33817431
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include "swift/AST/DiagnosticsClangImporter.h"
|
||||
#include "swift/AST/DiagnosticsParse.h"
|
||||
#include "swift/Basic/SourceManager.h"
|
||||
#include "swift/Demangling/ManglingUtils.h"
|
||||
#include "swift/Frontend/Frontend.h"
|
||||
#include "swift/Frontend/PrintingDiagnosticConsumer.h"
|
||||
#include "swift/IDE/CodeCompletion.h"
|
||||
@@ -1111,10 +1112,17 @@ public:
|
||||
}
|
||||
|
||||
StringRef getObjCRuntimeName(const Decl *D, SmallString<64> &Buf) {
|
||||
if (!D)
|
||||
if (!D || D->isInvalid())
|
||||
return StringRef();
|
||||
if (!isa<ClassDecl>(D) && !isa<ProtocolDecl>(D))
|
||||
return StringRef();
|
||||
auto *VD = cast<ValueDecl>(D);
|
||||
if (!VD->hasName())
|
||||
return StringRef();
|
||||
auto ident = VD->getBaseName().getIdentifier().str();
|
||||
if (ident.empty() || Mangle::isDigit(ident.front()))
|
||||
return StringRef();
|
||||
|
||||
// We don't support getting the runtime name for nested classes.
|
||||
// This would require typechecking or at least name lookup, if the nested
|
||||
// class is in an extension.
|
||||
|
||||
Reference in New Issue
Block a user