Skip to content

Commit dc2c0ec

Browse files
authored
Merge pull request #3337 from augusto2112/typedef-skip-simd-validation
[lldb] Skip validation of simd types on typedef functions in tsstyperef
2 parents 4258a92 + 9c6b8ad commit dc2c0ec

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "lldb/Symbol/TypeList.h"
2020
#include "lldb/Symbol/TypeMap.h"
2121
#include "lldb/Utility/Log.h"
22+
#include "lldb/Utility/RegularExpression.h"
2223
#include "lldb/Utility/Timer.h"
2324

2425
#include "Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h"
@@ -3288,6 +3289,36 @@ TypeSystemSwiftTypeRef::GetTypeBitAlign(opaque_compiler_type_t type,
32883289
return {};
32893290
}
32903291

3292+
#ifndef NDEBUG
3293+
static bool IsSIMDNode(NodePointer node) {
3294+
// A SIMD vector is a clang typealias whose identifier starts with "simd_".
3295+
if (node->getKind() == Node::Kind::TypeAlias && node->getNumChildren() >= 2) {
3296+
NodePointer module = node->getFirstChild();
3297+
NodePointer identifier = node->getChild(1);
3298+
return module->getKind() == Node::Kind::Module &&
3299+
module->getText() == "__C" &&
3300+
identifier->getKind() == Node::Kind::Identifier &&
3301+
identifier->getText().startswith("simd_");
3302+
}
3303+
// A SIMD matrix is a BoundGenericStructure whose inner identifier starts with
3304+
// SIMD.
3305+
if (node->getKind() == Node::Kind::BoundGenericStructure &&
3306+
node->hasChildren()) {
3307+
NodePointer type = node->getFirstChild();
3308+
if (type->getKind() == Node::Kind::Type && node->hasChildren()) {
3309+
NodePointer structure = type->getFirstChild();
3310+
if (structure->getKind() == Node::Kind::Structure &&
3311+
structure->getNumChildren() >= 2) {
3312+
NodePointer identifier = structure->getChild(1);
3313+
return identifier->getKind() == Node::Kind::Identifier &&
3314+
identifier->getText().startswith("SIMD");
3315+
}
3316+
}
3317+
}
3318+
return false;
3319+
}
3320+
#endif
3321+
32913322
bool TypeSystemSwiftTypeRef::IsTypedefType(opaque_compiler_type_t type) {
32923323
auto impl = [&]() {
32933324
using namespace swift::Demangle;
@@ -3317,6 +3348,11 @@ bool TypeSystemSwiftTypeRef::IsTypedefType(opaque_compiler_type_t type) {
33173348
if (mangled_name == "$sSo18NSNotificationNameaD" ||
33183349
mangled_name == "$sSo9NSDecimalaD")
33193350
return impl();
3351+
3352+
// SIMD types have some special handling in the compiler, causing divergences
3353+
// on the way SwiftASTContext and TypeSystemSwiftTypeRef view the same type.
3354+
if (IsSIMDNode(node))
3355+
return impl();
33203356
#endif
33213357
VALIDATE_AND_RETURN(impl, IsTypedefType, type, (ReconstructType(type)),
33223358
(ReconstructType(type)));
@@ -3363,6 +3399,11 @@ TypeSystemSwiftTypeRef::GetTypedefedType(opaque_compiler_type_t type) {
33633399
if (mangled_name == "$sSo18NSNotificationNameaD" ||
33643400
mangled_name == "$sSo9NSDecimalaD")
33653401
return impl();
3402+
3403+
// SIMD types have some special handling in the compiler, causing divergences
3404+
// on the way SwiftASTContext and TypeSystemSwiftTypeRef view the same type.
3405+
if (IsSIMDNode(node))
3406+
return impl();
33663407
#endif
33673408
VALIDATE_AND_RETURN(impl, GetTypedefedType, type, (ReconstructType(type)),
33683409
(ReconstructType(type)));

0 commit comments

Comments
 (0)