r276352 - [Sema] Handle errors during rewriteBuiltinFunctionDecl
Hans Wennborg via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 22 07:02:09 PDT 2016
Richard: should we merge this to 3.9?
On Thu, Jul 21, 2016 at 7:03 PM, David Majnemer via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
> 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}}
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list