diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/zig_clang.cpp | 23 | ||||
| -rw-r--r-- | src/zig_clang.h | 13 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/zig_clang.cpp b/src/zig_clang.cpp index b558fa318c..e7f00773fd 100644 --- a/src/zig_clang.cpp +++ b/src/zig_clang.cpp @@ -1255,6 +1255,22 @@ static_assert((clang::StorageClass)ZigClangStorageClass_PrivateExtern == clang:: static_assert((clang::StorageClass)ZigClangStorageClass_Auto == clang::SC_Auto, ""); static_assert((clang::StorageClass)ZigClangStorageClass_Register == clang::SC_Register, ""); +void ZigClang_detect_enum_RoundingMode(llvm::APFloat::roundingMode x) { + switch (x) { + case llvm::APFloat::rmNearestTiesToEven: + case llvm::APFloat::rmTowardPositive: + case llvm::APFloat::rmTowardNegative: + case llvm::APFloat::rmTowardZero: + case llvm::APFloat::rmNearestTiesToAway: + break; + } +} +static_assert((llvm::APFloat::roundingMode)ZigClangAPFloat_roundingMode_NearestTiesToEven == llvm::APFloat::rmNearestTiesToEven, ""); +static_assert((llvm::APFloat::roundingMode)ZigClangAPFloat_roundingMode_TowardPositive == llvm::APFloat::rmTowardPositive, ""); +static_assert((llvm::APFloat::roundingMode)ZigClangAPFloat_roundingMode_TowardNegative == llvm::APFloat::rmTowardNegative, ""); +static_assert((llvm::APFloat::roundingMode)ZigClangAPFloat_roundingMode_TowardZero == llvm::APFloat::rmTowardZero, ""); +static_assert((llvm::APFloat::roundingMode)ZigClangAPFloat_roundingMode_NearestTiesToAway == llvm::APFloat::rmNearestTiesToAway, ""); + static_assert(sizeof(ZigClangSourceLocation) == sizeof(clang::SourceLocation), ""); static ZigClangSourceLocation bitcast(clang::SourceLocation src) { @@ -1829,3 +1845,10 @@ ZigClangCompoundStmt_const_body_iterator ZigClangCompoundStmt_body_end(const str auto casted = reinterpret_cast<const clang::CompoundStmt *>(self); return bitcast(casted->body_end()); } + +unsigned ZigClangAPFloat_convertToHexString(const ZigClangAPFloat *self, char *DST, + unsigned HexDigits, bool UpperCase, enum ZigClangAPFloat_roundingMode RM) +{ + auto casted = reinterpret_cast<const llvm::APFloat *>(self); + return casted->convertToHexString(DST, HexDigits, UpperCase, (llvm::APFloat::roundingMode)RM); +} diff --git a/src/zig_clang.h b/src/zig_clang.h index fd74536b28..5bf922eec0 100644 --- a/src/zig_clang.h +++ b/src/zig_clang.h @@ -32,6 +32,7 @@ struct ZigClangAPValueLValueBase { struct ZigClangAPValue; struct ZigClangAPSInt; +struct ZigClangAPFloat; struct ZigClangASTContext; struct ZigClangASTUnit; struct ZigClangArraySubscriptExpr; @@ -713,6 +714,15 @@ enum ZigClangStorageClass { ZigClangStorageClass_Register, }; +/// IEEE-754R 4.3: Rounding-direction attributes. +enum ZigClangAPFloat_roundingMode { + ZigClangAPFloat_roundingMode_NearestTiesToEven, + ZigClangAPFloat_roundingMode_TowardPositive, + ZigClangAPFloat_roundingMode_TowardNegative, + ZigClangAPFloat_roundingMode_TowardZero, + ZigClangAPFloat_roundingMode_NearestTiesToAway, +}; + ZIG_EXTERN_C struct ZigClangSourceLocation ZigClangSourceManager_getSpellingLoc(const struct ZigClangSourceManager *, struct ZigClangSourceLocation Loc); ZIG_EXTERN_C const char *ZigClangSourceManager_getFilename(const struct ZigClangSourceManager *, @@ -827,4 +837,7 @@ ZIG_EXTERN_C struct ZigClangQualType ZigClangFunctionProtoType_getParamType(cons ZIG_EXTERN_C ZigClangCompoundStmt_const_body_iterator ZigClangCompoundStmt_body_begin(const struct ZigClangCompoundStmt *self); ZIG_EXTERN_C ZigClangCompoundStmt_const_body_iterator ZigClangCompoundStmt_body_end(const struct ZigClangCompoundStmt *self); +ZIG_EXTERN_C unsigned ZigClangAPFloat_convertToHexString(const struct ZigClangAPFloat *self, char *DST, + unsigned HexDigits, bool UpperCase, enum ZigClangAPFloat_roundingMode RM); + #endif |
