r276352 - [Sema] Handle errors during rewriteBuiltinFunctionDecl
David Majnemer via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 21 16:03:43 PDT 2016
Author: majnemer
Date: Thu Jul 21 18:03:43 2016
New Revision: 276352
URL: http://llvm.org/viewvc/llvm-project?rev=276352&view=rev
Log:
[Sema] Handle errors during rewriteBuiltinFunctionDecl
rewriteBuiltinFunctionDecl can encounter errors when performing
DefaultFunctionArrayLvalueConversion. These errors were not handled
which led to a null pointer dereference.
This fixes PR28651.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/builtins.cl
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=276352&r1=276351&r2=276352&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Jul 21 18:03:43 2016
@@ -5051,7 +5051,11 @@ static FunctionDecl *rewriteBuiltinFunct
for (QualType ParamType : FT->param_types()) {
// Convert array arguments to pointer to simplify type lookup.
- Expr *Arg = Sema->DefaultFunctionArrayLvalueConversion(ArgExprs[i++]).get();
+ ExprResult ArgRes =
+ Sema->DefaultFunctionArrayLvalueConversion(ArgExprs[i++]);
+ if (ArgRes.isInvalid())
+ return nullptr;
+ Expr *Arg = ArgRes.get();
QualType ArgType = Arg->getType();
if (!ParamType->isPointerType() ||
ParamType.getQualifiers().hasAddressSpace() ||
Modified: cfe/trunk/test/Sema/builtins.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/builtins.cl?rev=276352&r1=276351&r2=276352&view=diff
==============================================================================
--- cfe/trunk/test/Sema/builtins.cl (original)
+++ cfe/trunk/test/Sema/builtins.cl Thu Jul 21 18:03:43 2016
@@ -1,8 +1,11 @@
// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
-// expected-no-diagnostics
kernel void test(global float *out, global float *in, global int* in2) {
out[0] = __builtin_nanf("");
__builtin_memcpy(out, in, 32);
out[0] = __builtin_frexpf(in[0], in2);
}
+
+void pr28651() {
+ __builtin_alloca(value); // expected-error{{use of undeclared identifier}}
+}
More information about the cfe-commits
mailing list