aboutsummaryrefslogtreecommitdiff
path: root/src/zig_clang.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zig_clang.cpp')
-rw-r--r--src/zig_clang.cpp19
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());