Dynamically get the right-sized member of a GenericValue to hold a size_t, and

use it to return the result of strlen.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10433 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Brian Gaeke 2003-12-12 15:38:06 +00:00
parent 8b644f9073
commit 6c9d582738

View File

@ -481,11 +481,17 @@ GenericValue lle_X_strcpy(FunctionType *M, const vector<GenericValue> &Args) {
return PTOGV(strcpy((char*)GVTOP(Args[0]), (char*)GVTOP(Args[1])));
}
// long strlen(const char *src);
// size_t strlen(const char *src);
GenericValue lle_X_strlen(FunctionType *M, const vector<GenericValue> &Args) {
assert(Args.size() == 1);
size_t strlenResult = strlen ((char *) GVTOP (Args[0]));
GenericValue Ret;
Ret.LongVal = strlen((char*)GVTOP(Args[0]));
if (sizeof (size_t) == sizeof (uint64_t)) {
Ret.ULongVal = strlenResult;
} else {
assert (sizeof (size_t) == sizeof (unsigned int));
Ret.UIntVal = strlenResult;
}
return Ret;
}