diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-22 03:24:18 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-22 03:58:36 +0000 |
| commit | e575826c287f0dd0afeb1b9c6c8db45fb44c8d26 (patch) | |
| tree | cda407c503473817670188e02cc77d7f7a8331e9 | |
| parent | f58bbaa006cb0bb29739a168ed39286f6db0a8b4 (diff) | |
refactor(codegen): remove dead code in type system and runtime checks
Drop the unused TypeInfo::isNumeric, pass emitCheck's format arguments
straight to emitStderr, remove unused <cctype>/<cstdio> includes and
turn always-true trailing operator tests in ArithmeticHandler into plain
returns.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| -rw-r--r-- | include/cps/TypeSystem.h | 1 | ||||
| -rw-r--r-- | lib/CodeGen/ArithmeticHandler.cc | 5 | ||||
| -rw-r--r-- | lib/CodeGen/NativeTypeSystem.cc | 1 | ||||
| -rw-r--r-- | lib/CodeGen/RuntimeCheck.cc | 5 | ||||
| -rw-r--r-- | lib/CodeGen/TypeSystem.cc | 5 |
5 files changed, 3 insertions, 14 deletions
diff --git a/include/cps/TypeSystem.h b/include/cps/TypeSystem.h index 2d885fa..69283bc 100644 --- a/include/cps/TypeSystem.h +++ b/include/cps/TypeSystem.h @@ -82,7 +82,6 @@ struct TypeInfo { bool isC() const; bool sameType(const TypeInfo *Other) const; - bool isNumeric() const; bool isIntegral() const; bool isReal() const; bool isBoolean() const; diff --git a/lib/CodeGen/ArithmeticHandler.cc b/lib/CodeGen/ArithmeticHandler.cc index 480c963..6c7a7ff 100644 --- a/lib/CodeGen/ArithmeticHandler.cc +++ b/lib/CodeGen/ArithmeticHandler.cc @@ -2,7 +2,6 @@ #include "cps/ArithmeticHandler.h" #include "cps/Lexer.h" #include "cps/RuntimeCheck.h" -#include <cstdio> using namespace llvm; using namespace cps; @@ -46,7 +45,7 @@ Value *ArithmeticHandler::emitBinaryOp(int Op, Value *LHS, Value *RHS, int Line) } RuntimeChecker.emitDivZeroCheck(RHS, Line); if (Op == tok_div) return Builder.CreateSDiv(LHS, RHS, "div_int_tmp"); - if (Op == tok_mod) return Builder.CreateSRem(LHS, RHS, "mod_tmp"); + return Builder.CreateSRem(LHS, RHS, "mod_tmp"); } if (Op == tok_and || Op == tok_or) { @@ -64,7 +63,7 @@ Value *ArithmeticHandler::emitBinaryOp(int Op, Value *LHS, Value *RHS, int Line) R = Builder.CreateFCmpONE(R, ConstantFP::get(Context, APFloat(0.0)), "tobool"); if (Op == tok_and) return Builder.CreateAnd(L, R, "andtmp"); - if (Op == tok_or) return Builder.CreateOr(L, R, "ortmp"); + return Builder.CreateOr(L, R, "ortmp"); } if (LIsDouble || RIsDouble) { diff --git a/lib/CodeGen/NativeTypeSystem.cc b/lib/CodeGen/NativeTypeSystem.cc index 7accda7..d5d1c93 100644 --- a/lib/CodeGen/NativeTypeSystem.cc +++ b/lib/CodeGen/NativeTypeSystem.cc @@ -4,7 +4,6 @@ #include <limits> #include <type_traits> #include <sstream> -#include <cctype> using namespace llvm; using namespace cps; diff --git a/lib/CodeGen/RuntimeCheck.cc b/lib/CodeGen/RuntimeCheck.cc index 4cee16f..e15c10b 100644 --- a/lib/CodeGen/RuntimeCheck.cc +++ b/lib/CodeGen/RuntimeCheck.cc @@ -77,10 +77,7 @@ void RuntimeCheck::emitCheck(Value *Condition, Value *Msg, ArrayRef<Value *> Fmt Builder.CreateCondBr(Condition, FailBB, ContBB); Builder.SetInsertPoint(FailBB); - std::vector<Value*> PrintArgs; - PrintArgs.push_back(Msg); - PrintArgs.insert(PrintArgs.end(), FmtArgs.begin(), FmtArgs.end()); - emitStderr(Msg, ArrayRef<Value *>(PrintArgs).drop_front()); + emitStderr(Msg, FmtArgs); Exceptions.emitThrow(); diff --git a/lib/CodeGen/TypeSystem.cc b/lib/CodeGen/TypeSystem.cc index c5db1eb..7763d35 100644 --- a/lib/CodeGen/TypeSystem.cc +++ b/lib/CodeGen/TypeSystem.cc @@ -22,11 +22,6 @@ const RecordFieldInfo *RecordPayload::findField(const std::string &Name) const { return nullptr; } -bool TypeInfo::isNumeric() const { - return Kind == TypeKind::Integer || Kind == TypeKind::Real || - (Kind == TypeKind::CScalar && !isVoid()); -} - bool TypeInfo::isIntegral() const { return Kind == TypeKind::Integer || Kind == TypeKind::Char || (Kind == TypeKind::CScalar && LLVMType->isIntegerTy()); |
