r360998 - Fix crash if, during evaluation of __builtin_object_size, we try to load
Nico Weber via cfe-commits
cfe-commits at lists.llvm.org
Fri May 17 10:13:59 PDT 2019
The test fails on Windows:
*From: *Richard Smith via cfe-commits <cfe-commits at lists.llvm.org>
*Date: *Fri, May 17, 2019 at 3:58 AM
*To: * <cfe-commits at lists.llvm.org>
Author: rsmith
> Date: Fri May 17 01:01:34 2019
> New Revision: 360998
>
> URL: http://llvm.org/viewvc/llvm-project?rev=360998&view=rev
> Log:
> Fix crash if, during evaluation of __builtin_object_size, we try to load
> through an invalid base.
>
> Modified:
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp
>
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=360998&r1=360997&r2=360998&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri May 17 01:01:34 2019
> @@ -3285,6 +3285,11 @@ static bool AreElementsOfSameArray(QualT
> static CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E,
> AccessKinds AK, const LValue
> &LVal,
> QualType LValType) {
> + if (LVal.InvalidBase) {
> + Info.FFDiag(E);
> + return CompleteObject();
> + }
> +
> if (!LVal.Base) {
> Info.FFDiag(E, diag::note_constexpr_access_null) << AK;
> return CompleteObject();
>
> Modified: cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp?rev=360998&r1=360997&r2=360998&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp (original)
> +++ cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp Fri May 17
> 01:01:34 2019
> @@ -97,3 +97,10 @@ void tooSmallBuf() {
> copy5CharsIntoStrict(small.buf); // expected-error{{no matching
> function for call}}
> }
> }
> +
> +namespace InvalidBase {
> + // Ensure this doesn't crash.
> + struct S { const char *name; };
> + S invalid_base();
> + constexpr long bos_name = __builtin_object_size(invalid_base().name, 1);
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190517/006465e1/attachment.html>
More information about the cfe-commits
mailing list