Re: [PATCH] D22334: Fix for Bug 28172 : clang crashes on invalid code (with too few arguments to __builtin_signbit) without any proper diagnostics.
mayurpandey updated this revision to Diff 69354. mayurpandey added a comment. Hi, Updated the patch to handle the second crash. __builtin_signbit("1") was crashing. I am not fully sure whether the check : if (!Ty->isRealFloatingType()) is correct. Please review and let me know whether it is fine and if not what all changes are needed. Thanks, Mayur https://reviews.llvm.org/D22334 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaChecking.cpp test/Sema/builtins.c Index: test/Sema/builtins.c === --- test/Sema/builtins.c +++ test/Sema/builtins.c @@ -248,3 +248,11 @@ return buf; } + +int test21(double a) { + return __builtin_signbit(); // expected-error {{too few arguments}} +} + +int test22(void) { + return __builtin_signbit("1"); // expected-error {{Argument type mismatch}} +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -99,6 +99,22 @@ return false; } +static bool SemaBuiltinSignbit(Sema &S, CallExpr *TheCall) { + if (checkArgCount(S, TheCall, 1)) +return true; + + // Argument should be an float, double or long double. + Expr *ValArg = TheCall->getArg(0); + QualType Ty = ValArg->getType(); + if (!Ty->isRealFloatingType()) { +S.Diag(ValArg->getLocStart(), diag::err_builtin_signbit_wrong_argument) + << ValArg->getSourceRange(); +return true; + } + + return false; +} + /// Check that the argument to __builtin_addressof is a glvalue, and set the /// result type to the corresponding pointer type. static bool SemaBuiltinAddressof(Sema &S, CallExpr *TheCall) { @@ -763,6 +779,10 @@ } break; } + case Builtin::BI__builtin_signbit: +if (SemaBuiltinSignbit(*this, TheCall)) + return ExprError(); +break; case Builtin::BI__builtin_isgreater: case Builtin::BI__builtin_isgreaterequal: case Builtin::BI__builtin_isless: Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -7398,6 +7398,9 @@ def err_builtin_annotation_second_arg : Error< "second argument to __builtin_annotation must be a non-wide string constant">; +def err_builtin_signbit_wrong_argument : Error< + "Argument type mismatch, must be float, double or long double">; + // CFString checking def err_cfstring_literal_not_string_constant : Error< "CFString literal is not a string constant">; Index: test/Sema/builtins.c === --- test/Sema/builtins.c +++ test/Sema/builtins.c @@ -248,3 +248,11 @@ return buf; } + +int test21(double a) { + return __builtin_signbit(); // expected-error {{too few arguments}} +} + +int test22(void) { + return __builtin_signbit("1"); // expected-error {{Argument type mismatch}} +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -99,6 +99,22 @@ return false; } +static bool SemaBuiltinSignbit(Sema &S, CallExpr *TheCall) { + if (checkArgCount(S, TheCall, 1)) +return true; + + // Argument should be an float, double or long double. + Expr *ValArg = TheCall->getArg(0); + QualType Ty = ValArg->getType(); + if (!Ty->isRealFloatingType()) { +S.Diag(ValArg->getLocStart(), diag::err_builtin_signbit_wrong_argument) + << ValArg->getSourceRange(); +return true; + } + + return false; +} + /// Check that the argument to __builtin_addressof is a glvalue, and set the /// result type to the corresponding pointer type. static bool SemaBuiltinAddressof(Sema &S, CallExpr *TheCall) { @@ -763,6 +779,10 @@ } break; } + case Builtin::BI__builtin_signbit: +if (SemaBuiltinSignbit(*this, TheCall)) + return ExprError(); +break; case Builtin::BI__builtin_isgreater: case Builtin::BI__builtin_isgreaterequal: case Builtin::BI__builtin_isless: Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -7398,6 +7398,9 @@ def err_builtin_annotation_second_arg : Error< "second argument to __builtin_annotation must be a non-wide string constant">; +def err_builtin_signbit_wrong_argument : Error< + "Argument type mismatch, must be float, double or long double">; + // CFString checking def err_cfstring_literal_not_string_constant : Error< "CFString literal is not a string constant">; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22334: Fix for Bug 28172 : clang crashes on invalid code (with too few arguments to __builtin_signbit) without any proper diagnostics.
mayurpandey updated this revision to Diff 69674. mayurpandey added a comment. Hi, Updated the patch to add a template based testcase. As suggested by you, I tried updating the error diagnostic to err_typecheck_cond_expect_float and to issue diagnostic in similar fashion to err_typecheck_cond_expect_int_float, something like this : def err_typecheck_cond_expect_float : Error< "used type %0 where floating point type is required">; But on updating this clang was crashing with the following message: clang-3.9: llvm/tools/clang/include/clang/Basic/Diagnostic.h:1167: clang::DiagnosticsEngine::ArgumentKind clang::Diagnostic::getArgKind(unsigned int) const: Assertion `Idx < getNumArgs() && "Argument index out of range!"' failed. So reverted it to as it was earlier and similar to other builtin error err_builtin_annotation_first_arg. Please review the changes and let me know if any other change is needed. Thanks, Mayur https://reviews.llvm.org/D22334 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaChecking.cpp test/Sema/builtins.c test/SemaCXX/builtins.cpp Index: test/SemaCXX/builtins.cpp === --- test/SemaCXX/builtins.cpp +++ test/SemaCXX/builtins.cpp @@ -44,3 +44,10 @@ __noop(1); // expected-error {{use of undeclared}} __debugbreak(); // expected-error {{use of undeclared}} } + +template +int test_signbit(T t) { return __builtin_signbit(t); } // expected-error {{Argument type mismatch}} + +int test_signbit_call () { +return test_signbit("1"); // expected-note {{instantiation of function template specialization}} +} Index: test/Sema/builtins.c === --- test/Sema/builtins.c +++ test/Sema/builtins.c @@ -248,3 +248,11 @@ return buf; } + +int test21(double a) { + return __builtin_signbit(); // expected-error {{too few arguments}} +} + +int test22(void) { + return __builtin_signbit("1"); // expected-error {{Argument type mismatch}} +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -99,6 +99,22 @@ return false; } +static bool SemaBuiltinSignbit(Sema &S, CallExpr *TheCall) { + if (checkArgCount(S, TheCall, 1)) +return true; + + // Argument should be an float, double or long double. + Expr *ValArg = TheCall->getArg(0); + QualType Ty = ValArg->getType(); + if (!Ty->isRealFloatingType()) { +S.Diag(ValArg->getLocStart(), diag::err_builtin_signbit_wrong_argument) + << ValArg->getSourceRange(); +return true; + } + + return false; +} + /// Check that the argument to __builtin_addressof is a glvalue, and set the /// result type to the corresponding pointer type. static bool SemaBuiltinAddressof(Sema &S, CallExpr *TheCall) { @@ -763,6 +779,10 @@ } break; } + case Builtin::BI__builtin_signbit: +if (SemaBuiltinSignbit(*this, TheCall)) + return ExprError(); +break; case Builtin::BI__builtin_isgreater: case Builtin::BI__builtin_isgreaterequal: case Builtin::BI__builtin_isless: Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -7398,6 +7398,9 @@ def err_builtin_annotation_second_arg : Error< "second argument to __builtin_annotation must be a non-wide string constant">; +def err_builtin_signbit_wrong_argument : Error< + "Argument type mismatch, must be float, double or long double">; + // CFString checking def err_cfstring_literal_not_string_constant : Error< "CFString literal is not a string constant">; Index: test/SemaCXX/builtins.cpp === --- test/SemaCXX/builtins.cpp +++ test/SemaCXX/builtins.cpp @@ -44,3 +44,10 @@ __noop(1); // expected-error {{use of undeclared}} __debugbreak(); // expected-error {{use of undeclared}} } + +template +int test_signbit(T t) { return __builtin_signbit(t); } // expected-error {{Argument type mismatch}} + +int test_signbit_call () { +return test_signbit("1"); // expected-note {{instantiation of function template specialization}} +} Index: test/Sema/builtins.c === --- test/Sema/builtins.c +++ test/Sema/builtins.c @@ -248,3 +248,11 @@ return buf; } + +int test21(double a) { + return __builtin_signbit(); // expected-error {{too few arguments}} +} + +int test22(void) { + return __builtin_signbit("1"); // expected-error {{Argument type mismatch}} +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -99,6 +99,22 @@ return false; } +static bool SemaBuiltinSignbit(Sema &S, CallExpr *TheCall) { + if (
Re: [PATCH] D22334: Fix for Bug 28172 : clang crashes on invalid code (with too few arguments to __builtin_signbit) without any proper diagnostics.
ping. On Tue, Aug 30, 2016 at 7:32 PM, Mayur Pandey wrote: > mayurpandey updated this revision to Diff 69674. > mayurpandey added a comment. > > Hi, > > Updated the patch to add a template based testcase. As suggested by you, I > tried updating the error diagnostic to err_typecheck_cond_expect_float > and to issue diagnostic in similar fashion to > err_typecheck_cond_expect_int_float, > something like this : > def err_typecheck_cond_expect_float : Error< > > "used type %0 where floating point type is required">; > > But on updating this clang was crashing with the following message: > clang-3.9: llvm/tools/clang/include/clang/Basic/Diagnostic.h:1167: > clang::DiagnosticsEngine::ArgumentKind clang::Diagnostic::getArgKind(unsigned > int) const: Assertion `Idx < getNumArgs() && "Argument index out of > range!"' failed. > > So reverted it to as it was earlier and similar to other builtin error > err_builtin_annotation_first_arg. > > Please review the changes and let me know if any other change is needed. > > Thanks, > Mayur > > > https://reviews.llvm.org/D22334 > > Files: > include/clang/Basic/DiagnosticSemaKinds.td > lib/Sema/SemaChecking.cpp > test/Sema/builtins.c > test/SemaCXX/builtins.cpp > > Index: test/SemaCXX/builtins.cpp > === > --- test/SemaCXX/builtins.cpp > +++ test/SemaCXX/builtins.cpp > @@ -44,3 +44,10 @@ >__noop(1); // expected-error {{use of undeclared}} >__debugbreak(); // expected-error {{use of undeclared}} > } > + > +template > +int test_signbit(T t) { return __builtin_signbit(t); } // expected-error > {{Argument type mismatch}} > + > +int test_signbit_call () { > +return test_signbit("1"); // expected-note {{instantiation of function > template specialization}} > +} > Index: test/Sema/builtins.c > === > --- test/Sema/builtins.c > +++ test/Sema/builtins.c > @@ -248,3 +248,11 @@ > > return buf; > } > + > +int test21(double a) { > + return __builtin_signbit(); // expected-error {{too few arguments}} > +} > + > +int test22(void) { > + return __builtin_signbit("1"); // expected-error {{Argument type > mismatch}} > +} > Index: lib/Sema/SemaChecking.cpp > === > --- lib/Sema/SemaChecking.cpp > +++ lib/Sema/SemaChecking.cpp > @@ -99,6 +99,22 @@ >return false; > } > > +static bool SemaBuiltinSignbit(Sema &S, CallExpr *TheCall) { > + if (checkArgCount(S, TheCall, 1)) > +return true; > + > + // Argument should be an float, double or long double. > + Expr *ValArg = TheCall->getArg(0); > + QualType Ty = ValArg->getType(); > + if (!Ty->isRealFloatingType()) { > +S.Diag(ValArg->getLocStart(), diag::err_builtin_signbit_ > wrong_argument) > + << ValArg->getSourceRange(); > +return true; > + } > + > + return false; > +} > + > /// Check that the argument to __builtin_addressof is a glvalue, and set > the > /// result type to the corresponding pointer type. > static bool SemaBuiltinAddressof(Sema &S, CallExpr *TheCall) { > @@ -763,6 +779,10 @@ > } > break; >} > + case Builtin::BI__builtin_signbit: > +if (SemaBuiltinSignbit(*this, TheCall)) > + return ExprError(); > +break; >case Builtin::BI__builtin_isgreater: >case Builtin::BI__builtin_isgreaterequal: >case Builtin::BI__builtin_isless: > Index: include/clang/Basic/DiagnosticSemaKinds.td > === > --- include/clang/Basic/DiagnosticSemaKinds.td > +++ include/clang/Basic/DiagnosticSemaKinds.td > @@ -7398,6 +7398,9 @@ > def err_builtin_annotation_second_arg : Error< >"second argument to __builtin_annotation must be a non-wide string > constant">; > > +def err_builtin_signbit_wrong_argument : Error< > + "Argument type mismatch, must be float, double or long double">; > + > // CFString checking > def err_cfstring_literal_not_string_constant : Error< >"CFString literal is not a string constant">; > > > -- Thanx & Regards *Mayur Pandey * +91-9742959541 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D22334: Fix for Bug 28172 : clang crashes on invalid code (with too few arguments to __builtin_signbit) without any proper diagnostics.
mayurpandey updated this revision to Diff 78390. mayurpandey added a comment. Hi, Updated the patch to incorporate the review comments. I had missed adding ValArg->getType() when emitting the diagnostic which was cauing the crash. Testing done, no regressions. Thanks, Mayur https://reviews.llvm.org/D22334 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaChecking.cpp test/Sema/builtins.c test/SemaCXX/builtins.cpp Index: test/SemaCXX/builtins.cpp === --- test/SemaCXX/builtins.cpp +++ test/SemaCXX/builtins.cpp @@ -44,3 +44,10 @@ __noop(1); // expected-error {{use of undeclared}} __debugbreak(); // expected-error {{use of undeclared}} } + +template +int test_signbit(T t) { return __builtin_signbit(t); } // expected-error {{floating point type is required}} + +int test_signbit_call () { +return test_signbit("1"); // expected-note {{instantiation of function template specialization}} +} Index: test/Sema/builtins.c === --- test/Sema/builtins.c +++ test/Sema/builtins.c @@ -248,3 +248,11 @@ return buf; } + +int test21(double a) { + return __builtin_signbit(); // expected-error {{too few arguments}} +} + +int test22(void) { + return __builtin_signbit("1"); // expected-error {{floating point type is required}} +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -98,6 +98,22 @@ return false; } +static bool SemaBuiltinSignbit(Sema &S, CallExpr *TheCall) { + if (checkArgCount(S, TheCall, 1)) +return true; + + // Argument should be an float, double or long double. + Expr *ValArg = TheCall->getArg(0); + QualType Ty = ValArg->getType(); + if (!Ty->isRealFloatingType()) { +S.Diag(ValArg->getLocStart(), diag::err_typecheck_cond_expect_float) + << ValArg->getType() << ValArg->getSourceRange(); +return true; + } + + return false; +} + /// Check that the argument to __builtin_addressof is a glvalue, and set the /// result type to the corresponding pointer type. static bool SemaBuiltinAddressof(Sema &S, CallExpr *TheCall) { @@ -762,6 +778,10 @@ } break; } + case Builtin::BI__builtin_signbit: +if (SemaBuiltinSignbit(*this, TheCall)) + return ExprError(); +break; case Builtin::BI__builtin_isgreater: case Builtin::BI__builtin_isgreaterequal: case Builtin::BI__builtin_isless: Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -6845,6 +6845,8 @@ "(passed in %0)">; def err_typecheck_cond_expect_int_float : Error< "used type %0 where integer or floating point type is required">; +def err_typecheck_cond_expect_float : Error< + "used type %0 where floating point type is required">; def err_typecheck_cond_expect_scalar : Error< "used type %0 where arithmetic or pointer type is required">; def err_typecheck_cond_expect_nonfloat : Error< Index: test/SemaCXX/builtins.cpp === --- test/SemaCXX/builtins.cpp +++ test/SemaCXX/builtins.cpp @@ -44,3 +44,10 @@ __noop(1); // expected-error {{use of undeclared}} __debugbreak(); // expected-error {{use of undeclared}} } + +template +int test_signbit(T t) { return __builtin_signbit(t); } // expected-error {{floating point type is required}} + +int test_signbit_call () { +return test_signbit("1"); // expected-note {{instantiation of function template specialization}} +} Index: test/Sema/builtins.c === --- test/Sema/builtins.c +++ test/Sema/builtins.c @@ -248,3 +248,11 @@ return buf; } + +int test21(double a) { + return __builtin_signbit(); // expected-error {{too few arguments}} +} + +int test22(void) { + return __builtin_signbit("1"); // expected-error {{floating point type is required}} +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -98,6 +98,22 @@ return false; } +static bool SemaBuiltinSignbit(Sema &S, CallExpr *TheCall) { + if (checkArgCount(S, TheCall, 1)) +return true; + + // Argument should be an float, double or long double. + Expr *ValArg = TheCall->getArg(0); + QualType Ty = ValArg->getType(); + if (!Ty->isRealFloatingType()) { +S.Diag(ValArg->getLocStart(), diag::err_typecheck_cond_expect_float) + << ValArg->getType() << ValArg->getSourceRange(); +return true; + } + + return false; +} + /// Check that the argument to __builtin_addressof is a glvalue, and set the /// result type to the corresponding pointer type. static bool SemaBuiltinAddressof(Sema &S, CallEx
[PATCH] D22334: Fix for Bug 28172 : clang crashes on invalid code (with too few arguments to __builtin_signbit) without any proper diagnostics.
mayurpandey updated this revision to Diff 78471. mayurpandey added a comment. Hi, Updated the patch. Can you please commit it on my behalf as I don't have commit access. Thanks, Mayur https://reviews.llvm.org/D22334 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaChecking.cpp test/Sema/builtins.c test/SemaCXX/builtins.cpp Index: test/SemaCXX/builtins.cpp === --- test/SemaCXX/builtins.cpp +++ test/SemaCXX/builtins.cpp @@ -44,3 +44,10 @@ __noop(1); // expected-error {{use of undeclared}} __debugbreak(); // expected-error {{use of undeclared}} } + +template +int test_signbit(T t) { return __builtin_signbit(t); } // expected-error {{floating point type is required}} + +int test_signbit_call () { +return test_signbit("1"); // expected-note {{instantiation of function template specialization}} +} Index: test/Sema/builtins.c === --- test/Sema/builtins.c +++ test/Sema/builtins.c @@ -248,3 +248,11 @@ return buf; } + +int test21(double a) { + return __builtin_signbit(); // expected-error {{too few arguments}} +} + +int test22(void) { + return __builtin_signbit("1"); // expected-error {{floating point type is required}} +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -98,6 +98,22 @@ return false; } +static bool SemaBuiltinSignbit(Sema &S, CallExpr *TheCall) { + if (checkArgCount(S, TheCall, 1)) +return true; + + // Argument should be an float, double or long double. + Expr *ValArg = TheCall->getArg(0); + QualType Ty = ValArg->getType(); + if (!Ty->isRealFloatingType()) { +S.Diag(ValArg->getLocStart(), diag::err_typecheck_cond_expect_float) + << Ty << ValArg->getSourceRange(); +return true; + } + + return false; +} + /// Check that the argument to __builtin_addressof is a glvalue, and set the /// result type to the corresponding pointer type. static bool SemaBuiltinAddressof(Sema &S, CallExpr *TheCall) { @@ -762,6 +778,10 @@ } break; } + case Builtin::BI__builtin_signbit: +if (SemaBuiltinSignbit(*this, TheCall)) + return ExprError(); +break; case Builtin::BI__builtin_isgreater: case Builtin::BI__builtin_isgreaterequal: case Builtin::BI__builtin_isless: Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -6845,6 +6845,8 @@ "(passed in %0)">; def err_typecheck_cond_expect_int_float : Error< "used type %0 where integer or floating point type is required">; +def err_typecheck_cond_expect_float : Error< + "used type %0 where floating point type is required">; def err_typecheck_cond_expect_scalar : Error< "used type %0 where arithmetic or pointer type is required">; def err_typecheck_cond_expect_nonfloat : Error< Index: test/SemaCXX/builtins.cpp === --- test/SemaCXX/builtins.cpp +++ test/SemaCXX/builtins.cpp @@ -44,3 +44,10 @@ __noop(1); // expected-error {{use of undeclared}} __debugbreak(); // expected-error {{use of undeclared}} } + +template +int test_signbit(T t) { return __builtin_signbit(t); } // expected-error {{floating point type is required}} + +int test_signbit_call () { +return test_signbit("1"); // expected-note {{instantiation of function template specialization}} +} Index: test/Sema/builtins.c === --- test/Sema/builtins.c +++ test/Sema/builtins.c @@ -248,3 +248,11 @@ return buf; } + +int test21(double a) { + return __builtin_signbit(); // expected-error {{too few arguments}} +} + +int test22(void) { + return __builtin_signbit("1"); // expected-error {{floating point type is required}} +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -98,6 +98,22 @@ return false; } +static bool SemaBuiltinSignbit(Sema &S, CallExpr *TheCall) { + if (checkArgCount(S, TheCall, 1)) +return true; + + // Argument should be an float, double or long double. + Expr *ValArg = TheCall->getArg(0); + QualType Ty = ValArg->getType(); + if (!Ty->isRealFloatingType()) { +S.Diag(ValArg->getLocStart(), diag::err_typecheck_cond_expect_float) + << Ty << ValArg->getSourceRange(); +return true; + } + + return false; +} + /// Check that the argument to __builtin_addressof is a glvalue, and set the /// result type to the corresponding pointer type. static bool SemaBuiltinAddressof(Sema &S, CallExpr *TheCall) { @@ -762,6 +778,10 @@ } break; } + case Builtin::BI__builtin_signbit: +if (SemaBuiltinSign
[PATCH] D22334: Fix for Bug 28172 : clang crashes on invalid code (with too few arguments to __builtin_signbit) without any proper diagnostics.
mayurpandey added a comment. Hi David, The crash that we see can be seen with other diagnostics for builtin if we use the diagnostic format you suggested. I tried the same thing with err_builtin_annotation_first_arg. The same crash can be seen. So shall I fix this crash with this bug or file a new bug for this crash and work on it? Thanks, Mayur https://reviews.llvm.org/D22334 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22334: Fix for Bug 28172 : clang crashes on invalid code (with too few arguments to __builtin_signbit) without any proper diagnostics.
mayurpandey added a comment. The crash on : int x = __builtin_signbit("1"); is not a side effect of this patch. It was failing prior to the patch as well. I can work on a new patch for this crash. https://reviews.llvm.org/D22334 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D22334: Fix for Bug 28172 : clang crashes on invalid code (with too few arguments to __builtin_signbit) without any proper diagnostics.
mayurpandey created this revision. mayurpandey added reviewers: george.burgess.iv, hfinkel. mayurpandey added a subscriber: cfe-commits. clang was crashing when no argument was provided to __builtin_signbit function. Added a check to handle the error. No regressions on testing. http://reviews.llvm.org/D22334 Files: lib/Sema/SemaChecking.cpp test/Sema/builtins.c Index: test/Sema/builtins.c === --- test/Sema/builtins.c +++ test/Sema/builtins.c @@ -248,3 +248,7 @@ return buf; } + +int test21(double a) { + return __builtin_signbit(); // expected-error {{too few arguments}} +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -763,6 +763,10 @@ } break; } + case Builtin::BI__builtin_signbit: +if (checkArgCount(*this, TheCall, 1)) + return true; +break; case Builtin::BI__builtin_isgreater: case Builtin::BI__builtin_isgreaterequal: case Builtin::BI__builtin_isless: Index: test/Sema/builtins.c === --- test/Sema/builtins.c +++ test/Sema/builtins.c @@ -248,3 +248,7 @@ return buf; } + +int test21(double a) { + return __builtin_signbit(); // expected-error {{too few arguments}} +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -763,6 +763,10 @@ } break; } + case Builtin::BI__builtin_signbit: +if (checkArgCount(*this, TheCall, 1)) + return true; +break; case Builtin::BI__builtin_isgreater: case Builtin::BI__builtin_isgreaterequal: case Builtin::BI__builtin_isless: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits