diff options
| author | Takeshi Yoneda <takeshi@tetrate.io> | 2021-08-09 14:39:26 +0900 |
|---|---|---|
| committer | Takeshi Yoneda <takeshi@tetrate.io> | 2021-08-09 14:39:26 +0900 |
| commit | 97560cd915008f04addc2c30af087aa89c162b02 (patch) | |
| tree | 8aed12c207ff84cc256a0c78955c23b61129ba22 /src/zig_clang.cpp | |
| parent | 7814a2bd4a3ec22cd9548c622f7dc837dba968f7 (diff) | |
| parent | 799fedf612aa8742c446b015c12d21707a1dbec0 (diff) | |
| download | zig-97560cd915008f04addc2c30af087aa89c162b02.tar.gz zig-97560cd915008f04addc2c30af087aa89c162b02.zip | |
Merge remote-tracking branch 'origin' into libc-wasi-test
Diffstat (limited to 'src/zig_clang.cpp')
| -rw-r--r-- | src/zig_clang.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/zig_clang.cpp b/src/zig_clang.cpp index 7c923021d8..6611585f68 100644 --- a/src/zig_clang.cpp +++ b/src/zig_clang.cpp @@ -2754,7 +2754,7 @@ struct ZigClangSourceLocation ZigClangIntegerLiteral_getBeginLoc(const struct Zi return bitcast(casted->getBeginLoc()); } -bool ZigClangIntegerLiteral_isZero(const struct ZigClangIntegerLiteral *self, bool *result, const struct ZigClangASTContext *ctx) { +bool ZigClangIntegerLiteral_getSignum(const struct ZigClangIntegerLiteral *self, int *result, const struct ZigClangASTContext *ctx) { auto casted_self = reinterpret_cast<const clang::IntegerLiteral *>(self); auto casted_ctx = reinterpret_cast<const clang::ASTContext *>(ctx); clang::Expr::EvalResult eval_result; @@ -2763,7 +2763,17 @@ bool ZigClangIntegerLiteral_isZero(const struct ZigClangIntegerLiteral *self, bo } const llvm::APSInt result_int = eval_result.Val.getInt(); const llvm::APSInt zero(result_int.getBitWidth(), result_int.isUnsigned()); - *result = zero == result_int; + + if (zero == result_int) { + *result = 0; + } else if (result_int < zero) { + *result = -1; + } else if (result_int > zero) { + *result = 1; + } else { + return false; + } + return true; } @@ -2832,6 +2842,11 @@ unsigned ZigClangCharacterLiteral_getValue(const struct ZigClangCharacterLiteral return casted->getValue(); } +const struct ZigClangExpr *ZigClangChooseExpr_getChosenSubExpr(const struct ZigClangChooseExpr *self) { + auto casted = reinterpret_cast<const clang::ChooseExpr *>(self); + return reinterpret_cast<const ZigClangExpr *>(casted->getChosenSubExpr()); +} + const struct ZigClangExpr *ZigClangAbstractConditionalOperator_getCond(const struct ZigClangAbstractConditionalOperator *self) { auto casted = reinterpret_cast<const clang::AbstractConditionalOperator *>(self); return reinterpret_cast<const struct ZigClangExpr *>(casted->getCond()); |
