Skip to content

Commit 41bac50

Browse files
committed
Improve type checking of the additions
1 parent 8ccb91f commit 41bac50

File tree

6 files changed

+284
-200
lines changed

6 files changed

+284
-200
lines changed

src/parser/cxx/parser.cc

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2603,20 +2603,7 @@ auto Parser::parse_call_expression(ExpressionAST*& yyast,
26032603
expect(TokenKind::T_RPAREN, ast->rparenLoc);
26042604
}
26052605

2606-
std::vector<const Type*> argumentTypes;
2607-
2608-
for (auto it = ast->expressionList; it; it = it->next) {
2609-
const Type* argumentType = nullptr;
2610-
if (it->value) argumentType = it->value->type;
2611-
2612-
argumentTypes.push_back(argumentType);
2613-
}
2614-
2615-
if (auto access = ast_cast<MemberExpressionAST>(ast->baseExpression)) {
2616-
if (ast_cast<DestructorIdAST>(access->unqualifiedId)) {
2617-
ast->type = control_->getVoidType();
2618-
}
2619-
}
2606+
check(ast);
26202607

26212608
return true;
26222609
}
@@ -2676,13 +2663,6 @@ auto Parser::parse_cpp_cast_expression(ExpressionAST*& yyast,
26762663
return true;
26772664
}
26782665

2679-
auto Parser::get_cv_qualifiers(const Type* type) const -> CvQualifiers {
2680-
CvQualifiers cv = CvQualifiers::kNone;
2681-
if (control_->is_const(type)) cv = merge_cv(cv, CvQualifiers::kConst);
2682-
if (control_->is_volatile(type)) cv = merge_cv(cv, CvQualifiers::kVolatile);
2683-
return cv;
2684-
}
2685-
26862666
auto Parser::parse_builtin_bit_cast_expression(ExpressionAST*& yyast,
26872667
const ExprContext& ctx) -> bool {
26882668
if (!lookat(TokenKind::T___BUILTIN_BIT_CAST)) return false;
@@ -5939,34 +5919,6 @@ auto Parser::is_volatile(CvQualifiers cv) const -> bool {
59395919
return cv == CvQualifiers::kVolatile || cv == CvQualifiers::kConstVolatile;
59405920
}
59415921

5942-
auto Parser::merge_cv(CvQualifiers cv1, CvQualifiers cv2) const
5943-
-> CvQualifiers {
5944-
CvQualifiers cv = CvQualifiers::kNone;
5945-
if (is_const(cv1) || is_const(cv2)) cv = CvQualifiers::kConst;
5946-
if (is_volatile(cv1) || is_volatile(cv2)) {
5947-
if (cv == CvQualifiers::kConst)
5948-
cv = CvQualifiers::kConstVolatile;
5949-
else
5950-
cv = CvQualifiers::kVolatile;
5951-
}
5952-
return cv;
5953-
}
5954-
5955-
auto Parser::ensure_prvalue(ExpressionAST*& expr) -> bool {
5956-
TypeChecker checker{unit};
5957-
checker.setScope(scope_);
5958-
checker.setReportErrors(config_.checkTypes);
5959-
return checker.ensure_prvalue(expr);
5960-
}
5961-
5962-
auto Parser::implicit_conversion(ExpressionAST*& expr,
5963-
const Type* destinationType) -> bool {
5964-
TypeChecker checker{unit};
5965-
checker.setScope(scope_);
5966-
checker.setReportErrors(config_.checkTypes);
5967-
return checker.implicit_conversion(expr, destinationType);
5968-
}
5969-
59705922
auto Parser::is_prvalue(ExpressionAST* expr) const -> bool {
59715923
if (!expr) return false;
59725924
return expr->valueCategory == ValueCategory::kPrValue;

src/parser/cxx/parser.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -839,18 +839,9 @@ class Parser final {
839839

840840
[[nodiscard]] auto strip_parentheses(ExpressionAST* ast) -> ExpressionAST*;
841841
[[nodiscard]] auto strip_cv(const Type*& type) -> CvQualifiers;
842-
[[nodiscard]] auto merge_cv(CvQualifiers cv1, CvQualifiers cv2) const
843-
-> CvQualifiers;
844842
[[nodiscard]] auto is_const(CvQualifiers cv) const -> bool;
845843
[[nodiscard]] auto is_volatile(CvQualifiers cv) const -> bool;
846844

847-
[[nodiscard]] auto ensure_prvalue(ExpressionAST*& expr) -> bool;
848-
849-
[[nodiscard]] auto implicit_conversion(ExpressionAST*& expr,
850-
const Type* destinationType) -> bool;
851-
852-
[[nodiscard]] auto get_cv_qualifiers(const Type* type) const -> CvQualifiers;
853-
854845
[[nodiscard]] auto is_prvalue(ExpressionAST* expr) const -> bool;
855846
[[nodiscard]] auto is_lvalue(ExpressionAST* expr) const -> bool;
856847
[[nodiscard]] auto is_xvalue(ExpressionAST* expr) const -> bool;

0 commit comments

Comments
 (0)