[cfe-commits] r51363 - in /cfe/trunk: lib/AST/StmtIterator.cpp test/Sema/vla.c

Ted Kremenek kremenek at apple.com
Wed May 21 09:12:10 PDT 2008


Looks wonderful.  Thanks Eli!

On May 20, 2008, at 10:06 PM, Eli Friedman wrote:

> Author: efriedma
> Date: Wed May 21 00:06:46 2008
> New Revision: 51363
>
> URL: http://llvm.org/viewvc/llvm-project?rev=51363&view=rev
> Log:
> PR2347: Fix crash iterating over VLAs; this started triggering because
> we now iterate over the whole AST when we destroy it.
>
>
> Modified:
>    cfe/trunk/lib/AST/StmtIterator.cpp
>    cfe/trunk/test/Sema/vla.c
>
> Modified: cfe/trunk/lib/AST/StmtIterator.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtIterator.cpp?rev=51363&r1=51362&r2=51363&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/lib/AST/StmtIterator.cpp (original)
> +++ cfe/trunk/lib/AST/StmtIterator.cpp Wed May 21 00:06:46 2008
> @@ -36,16 +36,16 @@
>   p = FindVA(p->getElementType().getTypePtr());
>   setVAPtr(p);
>
> -  if (!p && decl) {
> +  if (!p && inDecl()) {
>     if (VarDecl* VD = dyn_cast<VarDecl>(decl))
>       if (VD->Init)
>         return;
>
>     NextDecl();
> -  }
> -  else {
> +  } else if (inSizeOfTypeVA()) {
> +    assert(!decl);
>     RawVAPtr = 0;
> -  }
> +  }
> }
>
> void StmtIteratorBase::NextDecl(bool ImmediateAdvance) {
> @@ -101,7 +101,6 @@
>   RawVAPtr |= reinterpret_cast<uintptr_t>(t);
> }
>
> -
> Stmt*& StmtIteratorBase::GetDeclExpr() const {
>   if (VariableArrayType* VAPtr = getVAPtr()) {
>     assert (VAPtr->SizeExpr);
>
> Modified: cfe/trunk/test/Sema/vla.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vla.c?rev=51363&r1=51362&r2=51363&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/test/Sema/vla.c (original)
> +++ cfe/trunk/test/Sema/vla.c Wed May 21 00:06:46 2008
> @@ -5,3 +5,11 @@
>   static int y = sizeof(x);  // expected-error {{not constant}}
> }
>
> +// PR2347
> +void f (unsigned int m)
> +{
> +  extern int e[2][m];
> +
> +  e[0][0] = 0;
> +}
> +
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list