aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-15 08:15:05 +0800
committer_ov4 <ov4@ov4.org>2026-10-15 08:15:05 +0800
commitbb64298ef26c9b42ae1bb50fb92b15e509b48c07 (patch)
treeff5227ff1d0685a3fd706c807f9ebef26a10ab21 /lib
parentb8c4b7040e222af1522b31a8739e679dacf87e03 (diff)
fix(codegen): use strtoll for integer string conversion
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/FunctionGen.cc2
-rw-r--r--lib/CodeGen/StringConversionHandler.cc6
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/CodeGen/FunctionGen.cc b/lib/CodeGen/FunctionGen.cc
index 9ccd8af..978970a 100644
--- a/lib/CodeGen/FunctionGen.cc
+++ b/lib/CodeGen/FunctionGen.cc
@@ -11,7 +11,7 @@ using namespace cps;
static bool isReservedRuntimeName(const std::string &Name) {
static const char *Reserved[] = {
"main", "printf", "scanf", "malloc", "free", "strlen", "memcpy",
- "strcpy", "strcat", "toupper", "tolower", "sprintf", "strtol",
+ "strcpy", "strcat", "toupper", "tolower", "sprintf", "strtol", "strtoll",
"strtod", "memset", "exit",
"fopen", "fclose", "fgetc", "ungetc", "fputs", "fputc",
"realloc", "strcmp", "__cxa_allocate_exception", "__cxa_throw",
diff --git a/lib/CodeGen/StringConversionHandler.cc b/lib/CodeGen/StringConversionHandler.cc
index 3b49cbb..6f7461c 100644
--- a/lib/CodeGen/StringConversionHandler.cc
+++ b/lib/CodeGen/StringConversionHandler.cc
@@ -12,8 +12,8 @@ void StringConversionHandler::setupExternalFunctions() {
FunctionType *SprintfType = FunctionType::get(Type::getInt32Ty(Context), {PointerType::getUnqual(Context), PointerType::getUnqual(Context)}, true);
SprintfFunc = Module.getOrInsertFunction("sprintf", SprintfType);
- FunctionType *StrtolType = FunctionType::get(Type::getInt64Ty(Context), {PointerType::getUnqual(Context), PointerType::getUnqual(Context), Type::getInt32Ty(Context)}, false);
- StrtolFunc = Module.getOrInsertFunction("strtol", StrtolType);
+ FunctionType *StrtollType = FunctionType::get(Type::getInt64Ty(Context), {PointerType::getUnqual(Context), PointerType::getUnqual(Context), Type::getInt32Ty(Context)}, false);
+ StrtollFunc = Module.getOrInsertFunction("strtoll", StrtollType);
FunctionType *StrtodType = FunctionType::get(Type::getDoubleTy(Context), {PointerType::getUnqual(Context), PointerType::getUnqual(Context)}, false);
StrtodFunc = Module.getOrInsertFunction("strtod", StrtodType);
@@ -43,7 +43,7 @@ Value *StringConversionHandler::emitStrToNum(Value *Str, bool AsReal) {
return Builder.CreateCall(StrtodFunc, {Str, NullPtr}, "str_to_real");
} else {
Value *Base = ConstantInt::get(Type::getInt32Ty(Context), 10);
- return Builder.CreateCall(StrtolFunc, {Str, NullPtr, Base}, "str_to_int");
+ return Builder.CreateCall(StrtollFunc, {Str, NullPtr, Base}, "str_to_int");
}
}