From e25293055da812602f286b3a318a8b5339862768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B6r=C3=B6k=20Edvin?= Date: Wed, 4 Aug 2010 13:58:31 +0300 Subject: [PATCH] Use CallSite instead of CI->getOperand. getOperand was made private because order of operands got changed. CallSite works with both LLVM 2.7 and 2.8. --- libclamav/c++/ClamBCRTChecks.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libclamav/c++/ClamBCRTChecks.cpp b/libclamav/c++/ClamBCRTChecks.cpp index b39d83045..01d28d8b9 100644 --- a/libclamav/c++/ClamBCRTChecks.cpp +++ b/libclamav/c++/ClamBCRTChecks.cpp @@ -157,9 +157,11 @@ namespace { Value *V = CI->getCalledValue()->stripPointerCasts(); Function *F = cast(V); const FunctionType *FTy = F->getFunctionType(); + CallSite CS(CI); + if (F->getName().equals("memcmp") && FTy->getNumParams() == 3) { - valid &= validateAccess(CI->getOperand(1), CI->getOperand(3), CI); - valid &= validateAccess(CI->getOperand(2), CI->getOperand(3), CI); + valid &= validateAccess(CS.getArgument(0), CS.getArgument(2), CI); + valid &= validateAccess(CS.getArgument(1), CS.getArgument(2), CI); continue; } unsigned i; @@ -170,7 +172,7 @@ namespace { #endif for (;igetNumParams();i++) { if (isa(FTy->getParamType(i))) { - Value *Ptr = CI->getOperand(i+1); + Value *Ptr = CS.getArgument(i); if (i+1 >= FTy->getNumParams()) { printLocation(CI, false); errs() << "Call to external function with pointer parameter last cannot be analyzed\n"; @@ -178,7 +180,7 @@ namespace { valid = 0; break; } - Value *Size = CI->getOperand(i+2); + Value *Size = CS.getArgument(i+1); if (!Size->getType()->isIntegerTy()) { printLocation(CI, false); errs() << "Pointer argument must be followed by integer argument representing its size\n"; @@ -381,8 +383,9 @@ namespace { const FunctionType *FTy = F->getFunctionType(); // last operand is always size for this API call kind if (F->isDeclaration() && FTy->getNumParams() > 0) { + CallSite CS(CI); if (FTy->getParamType(FTy->getNumParams()-1)->isIntegerTy()) - V = CI->getOperand(FTy->getNumParams()); + V = CS.getArgument(FTy->getNumParams()-1); } } if (!V)