diff options
| author | George Burgess IV <george.burgess.iv@gmail.com> | 2017-03-21 20:09:35 +0000 |
|---|---|---|
| committer | George Burgess IV <george.burgess.iv@gmail.com> | 2017-03-21 20:09:35 +0000 |
| commit | a63f91574fcbbcef412d44d5ec352a1b3d0b1606 (patch) | |
| tree | ee350291d67db8446815b6fb1860bc13ef3e295d /clang/lib/CodeGen/CGBuiltin.cpp | |
| parent | 56c7e88c2cd8f4f6d440f50d9f19401763f3122b (diff) | |
| download | bcm5719-llvm-a63f91574fcbbcef412d44d5ec352a1b3d0b1606.tar.gz bcm5719-llvm-a63f91574fcbbcef412d44d5ec352a1b3d0b1606.zip | |
Let llvm.objectsize be conservative with null pointers
D28494 adds another parameter to @llvm.objectsize. Clang needs to be
sure to pass that third arg whenever applicable.
llvm-svn: 298431
Diffstat (limited to 'clang/lib/CodeGen/CGBuiltin.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGBuiltin.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 005c824024f..817589064a3 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -470,10 +470,13 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, assert(Ptr->getType()->isPointerTy() && "Non-pointer passed to __builtin_object_size?"); - // LLVM only supports 0 and 2, make sure that we pass along that as a boolean. - auto *CI = ConstantInt::get(Builder.getInt1Ty(), (Type & 2) >> 1); Value *F = CGM.getIntrinsic(Intrinsic::objectsize, {ResType, Ptr->getType()}); - return Builder.CreateCall(F, {Ptr, CI}); + + // LLVM only supports 0 and 2, make sure that we pass along that as a boolean. + Value *Min = Builder.getInt1((Type & 2) != 0); + // For GCC compatability, __builtin_object_size treat NULL as unknown size. + Value *NullIsUnknown = Builder.getTrue(); + return Builder.CreateCall(F, {Ptr, Min, NullIsUnknown}); } // Many of MSVC builtins are on both x64 and ARM; to avoid repeating code, we |

