Skip to content

Commit de408e1

Browse files
committed
[ObjC] Fix parsing method type encoding strings for 32-bit platforms
Incorrect parsing of method type encoding strings was causing incorrect function types to be applied to Objective-C method implementations. In some cases this would result in confusion about which stack locations specific parameters resided at. `q`, `Q and `d` were being mapped to `NSInteger`, `NSUInteger` and `CGFloat` respectively. While this works for 64-bit platforms, the type aliases refer to 32-bit types on 32-bit platforms. These type encodings are explicitly for 64-bit types. To address this `q`, `Q` and `d` are now mapped to `int64_t`, `uint64_t` and `double` respectively. `l` and `L` were incorrectly being interpreted as `int64_t` and `uint64_t`. While `long` is a 64-bit type on 64-bit Apple platforms, the `l` / `L` type encodings always refer to a 32-bit type. `S` was mistakenly being mapped to `uint8_t`. It is now `uint16_t` as intended.
1 parent 373145b commit de408e1

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

objectivec/objc.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ std::vector<QualifiedNameOrType> ObjCProcessor::ParseEncodedType(const std::stri
295295
nameOrType.type = Type::IntegerType(2, true);
296296
break;
297297
case 'S':
298-
nameOrType.type = Type::IntegerType(1, false);
298+
nameOrType.type = Type::IntegerType(2, false);
299299
break;
300300
case 'i':
301301
nameOrType.type = Type::IntegerType(4, true);
@@ -304,27 +304,27 @@ std::vector<QualifiedNameOrType> ObjCProcessor::ParseEncodedType(const std::stri
304304
nameOrType.type = Type::IntegerType(4, false);
305305
break;
306306
case 'l':
307-
nameOrType.type = Type::IntegerType(8, true);
307+
nameOrType.type = Type::IntegerType(4, true);
308308
break;
309309
case 'L':
310+
nameOrType.type = Type::IntegerType(4, false);
311+
break;
312+
case 'q':
310313
nameOrType.type = Type::IntegerType(8, true);
311314
break;
315+
case 'Q':
316+
nameOrType.type = Type::IntegerType(8, false);
317+
break;
312318
case 'f':
313-
nameOrType.type = Type::IntegerType(4, true);
319+
nameOrType.type = Type::FloatType(4);
320+
break;
321+
case 'd':
322+
nameOrType.type = Type::FloatType(8);
314323
break;
315324
case 'b':
316325
case 'B':
317326
nameOrType.type = Type::BoolType();
318327
break;
319-
case 'q':
320-
qualifiedName = "NSInteger";
321-
break;
322-
case 'Q':
323-
qualifiedName = "NSUInteger";
324-
break;
325-
case 'd':
326-
qualifiedName = "CGFloat";
327-
break;
328328
case '*':
329329
nameOrType.type = Type::PointerType(m_data->GetAddressSize(), Type::IntegerType(1, true));
330330
break;

0 commit comments

Comments
 (0)