diff options
author | Justin Lebar <jlebar@google.com> | 2016-02-11 02:00:52 +0000 |
---|---|---|
committer | Justin Lebar <jlebar@google.com> | 2016-02-11 02:00:52 +0000 |
commit | 9a2c0fbaf56af2d03933affa6f5a99c215911231 (patch) | |
tree | f8e391ccf12ead9418e6e543276693d2eaa750ce /clang/lib/CodeGen/CGCUDABuiltin.cpp | |
parent | 0f3474c1dcd0650696c1a2cdfdf57a3982a25e3c (diff) | |
download | bcm5719-llvm-9a2c0fbaf56af2d03933affa6f5a99c215911231.tar.gz bcm5719-llvm-9a2c0fbaf56af2d03933affa6f5a99c215911231.zip |
[CUDA] Don't crash when trying to printf a non-scalar object.
Summary:
We can't do the right thing, since there's no right thing to do, but at
least we can not crash the compiler.
Reviewers: majnemer, rnk
Subscribers: cfe-commits, jhen, tra
Differential Revision: http://reviews.llvm.org/D17103
llvm-svn: 260479
Diffstat (limited to 'clang/lib/CodeGen/CGCUDABuiltin.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGCUDABuiltin.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGCUDABuiltin.cpp b/clang/lib/CodeGen/CGCUDABuiltin.cpp index 0ccba8982a6..ea3b888635c 100644 --- a/clang/lib/CodeGen/CGCUDABuiltin.cpp +++ b/clang/lib/CodeGen/CGCUDABuiltin.cpp @@ -83,6 +83,13 @@ CodeGenFunction::EmitCUDADevicePrintfCallExpr(const CallExpr *E, E->arguments(), E->getDirectCallee(), /* ParamsToSkip = */ 0); + // We don't know how to emit non-scalar varargs. + if (std::any_of(Args.begin() + 1, Args.end(), + [](const CallArg &A) { return !A.RV.isScalar(); })) { + CGM.ErrorUnsupported(E, "non-scalar arg to printf"); + return RValue::get(llvm::ConstantInt::get(IntTy, 0)); + } + // Construct and fill the args buffer that we'll pass to vprintf. llvm::Value *BufferPtr; if (Args.size() <= 1) { |