r174477 - Use a dyn_cast to avoid a crash when the TypeLoc is not a ConstantArrayTypeLoc.

David Blaikie dblaikie at gmail.com
Tue Feb 5 19:27:56 PST 2013


On Feb 5, 2013 5:00 PM, "Chad Rosier" <mcrosier at apple.com> wrote:
>
> Author: mcrosier
> Date: Tue Feb  5 18:58:34 2013
> New Revision: 174477
>
> URL: http://llvm.org/viewvc/llvm-project?rev=174477&view=rev
> Log:
> Use a dyn_cast to avoid a crash when the TypeLoc is not a
ConstantArrayTypeLoc.
> rdar://13153516
>
> Modified:
>     cfe/trunk/lib/Sema/SemaChecking.cpp

Test case?

>
> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=174477&r1=174476&r2=174477&view=diff
>
==============================================================================
> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Feb  5 18:58:34 2013
> @@ -5777,10 +5777,11 @@ static bool IsTailPaddedMemberArray(Sema
>        TInfo = TDL->getTypeSourceInfo();
>        continue;
>      }
> -    ConstantArrayTypeLoc CTL = cast<ConstantArrayTypeLoc>(TL);
> -    const Expr *SizeExpr = dyn_cast<IntegerLiteral>(CTL.getSizeExpr());
> -    if (!SizeExpr || SizeExpr->getExprLoc().isMacroID())
> -      return false;
> +    if (const ConstantArrayTypeLoc *CTL =
dyn_cast<ConstantArrayTypeLoc>(&TL)) {
> +      const Expr *SizeExpr =
dyn_cast<IntegerLiteral>(CTL->getSizeExpr());
> +      if (!SizeExpr || SizeExpr->getExprLoc().isMacroID())
> +        return false;
> +    }
>      break;
>    }
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130205/3d53db8b/attachment.html>


More information about the cfe-commits mailing list