Skip to content

Commit 223ebe0

Browse files
committed
AST: avoid truncation
`Swift.Int` is *NOT* `int` or `long`, it is `uintptr_t`. Replace many of the size parameters with `size_t`.
1 parent 253e624 commit 223ebe0

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

include/swift/AST/CASTBridging.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@
2525
SWIFT_BEGIN_NULLABILITY_ANNOTATIONS
2626
SWIFT_BEGIN_ASSUME_NONNULL
2727

28-
typedef long SwiftInt;
29-
typedef unsigned long SwiftUInt;
28+
typedef long long SwiftInt;
29+
typedef unsigned long long SwiftUInt;
3030

3131
typedef struct {
3232
const unsigned char *_Nullable data;
33-
long length;
33+
size_t length;
3434
} BridgedString;
3535

3636
typedef struct {
3737
const void *_Nullable data;
38-
long numElements;
38+
size_t numElements;
3939
} BridgedArrayRef;
4040

4141
typedef struct BridgedASTContext {
@@ -113,7 +113,7 @@ typedef struct BridgedDiagnosticEngine {
113113
void *raw;
114114
} BridgedDiagnosticEngine;
115115

116-
typedef enum ENUM_EXTENSIBILITY_ATTR(open) BridgedMacroDefinitionKind : long {
116+
typedef enum ENUM_EXTENSIBILITY_ATTR(open) BridgedMacroDefinitionKind : size_t {
117117
/// An expanded macro.
118118
BridgedExpandedMacro = 0,
119119
/// An external macro, spelled with either the old spelling (Module.Type)
@@ -307,7 +307,7 @@ void *IfStmt_create(BridgedASTContext cContext, BridgedSourceLoc cIfLoc,
307307
void *BraceStmt_create(BridgedASTContext cContext, BridgedSourceLoc cLBLoc,
308308
BridgedArrayRef elements, BridgedSourceLoc cRBLoc);
309309

310-
BridgedSourceLoc SourceLoc_advanced(BridgedSourceLoc cLoc, long len);
310+
BridgedSourceLoc SourceLoc_advanced(BridgedSourceLoc cLoc, size_t len);
311311

312312
void *ParamDecl_create(BridgedASTContext cContext, BridgedSourceLoc cLoc,
313313
BridgedSourceLoc cArgLoc, BridgedIdentifier argName,
@@ -357,7 +357,7 @@ void *GenericTypeParamDecl_create(BridgedASTContext cContext,
357357
BridgedDeclContext cDeclContext,
358358
BridgedIdentifier name,
359359
BridgedSourceLoc cNameLoc,
360-
BridgedSourceLoc cEachLoc, long index,
360+
BridgedSourceLoc cEachLoc, size_t index,
361361
_Bool isParameterPack);
362362
void GenericTypeParamDecl_setInheritedType(BridgedASTContext cContext,
363363
void *Param, void *ty);

lib/AST/CASTBridging.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ void *ImportDecl_create(BridgedASTContext cContext,
204204
std::move(importPath).get());
205205
}
206206

207-
BridgedSourceLoc SourceLoc_advanced(BridgedSourceLoc cLoc, long len) {
207+
BridgedSourceLoc SourceLoc_advanced(BridgedSourceLoc cLoc, size_t len) {
208208
SourceLoc loc = convertSourceLoc(cLoc).getAdvancedLoc(len);
209209
return {loc.getOpaquePointerValue()};
210210
}
@@ -764,7 +764,7 @@ void *GenericTypeParamDecl_create(BridgedASTContext cContext,
764764
BridgedDeclContext cDeclContext,
765765
BridgedIdentifier name,
766766
BridgedSourceLoc cNameLoc,
767-
BridgedSourceLoc cEachLoc, long index,
767+
BridgedSourceLoc cEachLoc, size_t index,
768768
bool isParameterPack) {
769769
return GenericTypeParamDecl::createParsed(
770770
convertDeclContext(cDeclContext), convertIdentifier(name),

0 commit comments

Comments
 (0)