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

Chad Rosier mcrosier at apple.com
Wed Feb 6 09:22:36 PST 2013


On Feb 5, 2013, at 7:27 PM, David Blaikie <dblaikie at gmail.com> wrote:

> 
> 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?
> 
> 

Certainly, I'll see if I can't reduce the original test case and commit shortly.

 Chad
> >
> > 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/20130206/79762118/attachment.html>


More information about the cfe-commits mailing list