authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-01-08 16:49:52-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-01-08 16:49:52-05:00
log1ca983dbd7af661d3f1f840138ecba9dc0a6e372
treee492c46a5013f33a1fe11216d3f5871e1153db6c
parent036a49e97d0bc556ece08562c9dd3c75879598cf

translate-c: update to llvm8


1 files changed, 13 insertions(+), 3 deletions(-)

src/translate_c.cpp+13-3
...@@ -129,6 +129,7 @@ static TransScope *trans_stmt(Context *c, TransScope *scope, const Stmt *stmt, A...@@ -129,6 +129,7 @@ static TransScope *trans_stmt(Context *c, TransScope *scope, const Stmt *stmt, A
129static AstNode *trans_expr(Context *c, ResultUsed result_used, TransScope *scope, const Expr *expr, TransLRValue lrval);129static AstNode *trans_expr(Context *c, ResultUsed result_used, TransScope *scope, const Expr *expr, TransLRValue lrval);
130static AstNode *trans_qual_type(Context *c, QualType qt, const SourceLocation &source_loc);130static AstNode *trans_qual_type(Context *c, QualType qt, const SourceLocation &source_loc);
131static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope *scope, const Expr *expr, TransLRValue lrval);131static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope *scope, const Expr *expr, TransLRValue lrval);
132static AstNode *trans_ap_value(Context *c, APValue *ap_value, QualType qt, const SourceLocation &source_loc);
132133
133ATTRIBUTE_PRINTF(3, 4)134ATTRIBUTE_PRINTF(3, 4)
134static void emit_warning(Context *c, const SourceLocation &sl, const char *format, ...) {135static void emit_warning(Context *c, const SourceLocation &sl, const char *format, ...) {
...@@ -1225,6 +1226,15 @@ static AstNode *trans_integer_literal(Context *c, const IntegerLiteral *stmt) {...@@ -1225,6 +1226,15 @@ static AstNode *trans_integer_literal(Context *c, const IntegerLiteral *stmt) {
1225 return trans_create_node_apint(c, result.Val.getInt());1226 return trans_create_node_apint(c, result.Val.getInt());
1226}1227}
12271228
1229static AstNode *trans_constant_expr(Context *c, const ConstantExpr *expr) {
1230 Expr::EvalResult result;
1231 if (!expr->EvaluateAsConstantExpr(result, Expr::EvaluateForCodeGen, *c->ctx)) {
1232 emit_warning(c, expr->getBeginLoc(), "invalid constant expression");
1233 return nullptr;
1234 }
1235 return trans_ap_value(c, &result.Val, expr->getType(), expr->getBeginLoc());
1236}
1237
1228static AstNode *trans_conditional_operator(Context *c, ResultUsed result_used, TransScope *scope,1238static AstNode *trans_conditional_operator(Context *c, ResultUsed result_used, TransScope *scope,
1229 const ConditionalOperator *stmt)1239 const ConditionalOperator *stmt)
1230{1240{
...@@ -3183,6 +3193,9 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const Stmt *stmt,...@@ -3183,6 +3193,9 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const Stmt *stmt,
3183 return trans_switch_case(c, scope, (const CaseStmt *)stmt, out_node, out_child_scope);3193 return trans_switch_case(c, scope, (const CaseStmt *)stmt, out_node, out_child_scope);
3184 case Stmt::DefaultStmtClass:3194 case Stmt::DefaultStmtClass:
3185 return trans_switch_default(c, scope, (const DefaultStmt *)stmt, out_node, out_child_scope);3195 return trans_switch_default(c, scope, (const DefaultStmt *)stmt, out_node, out_child_scope);
3196 case Stmt::ConstantExprClass:
3197 return wrap_stmt(out_node, out_child_scope, scope,
3198 trans_constant_expr(c, (const ConstantExpr *)stmt));
3186 case Stmt::NoStmtClass:3199 case Stmt::NoStmtClass:
3187 emit_warning(c, stmt->getBeginLoc(), "TODO handle C NoStmtClass");3200 emit_warning(c, stmt->getBeginLoc(), "TODO handle C NoStmtClass");
3188 return ErrorUnexpected;3201 return ErrorUnexpected;
...@@ -3690,9 +3703,6 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const Stmt *stmt,...@@ -3690,9 +3703,6 @@ static int trans_stmt_extra(Context *c, TransScope *scope, const Stmt *stmt,
3690 case Stmt::FixedPointLiteralClass:3703 case Stmt::FixedPointLiteralClass:
3691 emit_warning(c, stmt->getBeginLoc(), "TODO handle C FixedPointLiteralClass");3704 emit_warning(c, stmt->getBeginLoc(), "TODO handle C FixedPointLiteralClass");
3692 return ErrorUnexpected;3705 return ErrorUnexpected;
3693 case Stmt::ConstantExprClass:
3694 emit_warning(c, stmt->getBeginLoc(), "TODO handle C ConstantExprClass");
3695 return ErrorUnexpected;
3696 }3706 }
3697 zig_unreachable();3707 zig_unreachable();
3698}3708}