|
19 | 19 | #include "lldb/Symbol/TypeList.h"
|
20 | 20 | #include "lldb/Symbol/TypeMap.h"
|
21 | 21 | #include "lldb/Utility/Log.h"
|
| 22 | +#include "lldb/Utility/RegularExpression.h" |
22 | 23 | #include "lldb/Utility/Timer.h"
|
23 | 24 |
|
24 | 25 | #include "Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h"
|
@@ -3288,6 +3289,36 @@ TypeSystemSwiftTypeRef::GetTypeBitAlign(opaque_compiler_type_t type,
|
3288 | 3289 | return {};
|
3289 | 3290 | }
|
3290 | 3291 |
|
| 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 | + |
3291 | 3322 | bool TypeSystemSwiftTypeRef::IsTypedefType(opaque_compiler_type_t type) {
|
3292 | 3323 | auto impl = [&]() {
|
3293 | 3324 | using namespace swift::Demangle;
|
@@ -3317,6 +3348,11 @@ bool TypeSystemSwiftTypeRef::IsTypedefType(opaque_compiler_type_t type) {
|
3317 | 3348 | if (mangled_name == "$sSo18NSNotificationNameaD" ||
|
3318 | 3349 | mangled_name == "$sSo9NSDecimalaD")
|
3319 | 3350 | 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(); |
3320 | 3356 | #endif
|
3321 | 3357 | VALIDATE_AND_RETURN(impl, IsTypedefType, type, (ReconstructType(type)),
|
3322 | 3358 | (ReconstructType(type)));
|
@@ -3363,6 +3399,11 @@ TypeSystemSwiftTypeRef::GetTypedefedType(opaque_compiler_type_t type) {
|
3363 | 3399 | if (mangled_name == "$sSo18NSNotificationNameaD" ||
|
3364 | 3400 | mangled_name == "$sSo9NSDecimalaD")
|
3365 | 3401 | 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(); |
3366 | 3407 | #endif
|
3367 | 3408 | VALIDATE_AND_RETURN(impl, GetTypedefedType, type, (ReconstructType(type)),
|
3368 | 3409 | (ReconstructType(type)));
|
|
0 commit comments