Add support for the cases where the pointer is not char*.

This commit is contained in:
Baozeng Ding 2013-08-16 19:44:35 +02:00 committed by sftnight
parent 76c598f0ff
commit eca58d0ffc
2 changed files with 3 additions and 4 deletions

View File

@ -328,7 +328,6 @@ namespace cling {
void NullDerefProtectionTransformer::instrumentCallInst(llvm::Instruction*
TheCall, const std::bitset<32>& ArgIndexs) {
llvm::Type* Int8PtrTy = llvm::Type::getInt8PtrTy(TheCall->getContext());
llvm::CallSite CS = TheCall;
for (int index = 0; index < 32; ++index) {
@ -336,8 +335,6 @@ namespace cling {
llvm::Value* Arg = CS.getArgument(index);
if (!Arg) continue;
llvm::Type* ArgTy = Arg->getType();
if (ArgTy != Int8PtrTy)
continue;
llvm::BasicBlock* OldBB = TheCall->getParent();
llvm::ICmpInst* Cmp

View File

@ -1,7 +1,8 @@
// RUN: cat %s | %cling -Xclang -verify | FileCheck %s
//This file checks a call instruction. The called function has arguments with nonnull attribute.
// XFAIL: *
#include <string.h>
//XFAIL: darwin
char *p = 0;
strcmp("a", p); // expected-warning {{you are about to dereference null ptr, which probably will lead to seg violation. Do you want to proceed?[y/n]}}
@ -22,6 +23,7 @@ extern "C" int cannotCallWithNull(int* p) {
}
cannotCallWithNull() // warning-expected {{null passed to a callee which requires a non-null argument}}
// expected-warning {{you are about to dereference null ptr, which probably will lead to seg violation. Do you want to proceed?[y/n]}}
//CHECK-NOT: Must not be called with p=0.
//CHECK: (int) 1