[cfe-commits] r153067 - in /cfe/trunk: lib/Analysis/CFG.cpp test/SemaCXX/warn-everthing.cpp

Richard Smith richard at metafoo.co.uk
Mon Mar 19 20:35:52 PDT 2012


On Mon, Mar 19, 2012 at 4:48 PM, Ted Kremenek <kremenek at apple.com> wrote:

> Author: kremenek
> Date: Mon Mar 19 18:48:41 2012
> New Revision: 153067
>
> URL: http://llvm.org/viewvc/llvm-project?rev=153067&view=rev
> Log:
> Fix crash when querying the CFG reported when using the thread safety
> analysis
> on code using multi-dimensional arrays.  Fix by DeLesley Hutchins, and
> reported in
> PR 12271.
>
> Added:
>    cfe/trunk/test/SemaCXX/warn-everthing.cpp
> Modified:
>    cfe/trunk/lib/Analysis/CFG.cpp
>
> Modified: cfe/trunk/lib/Analysis/CFG.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=153067&r1=153066&r2=153067&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Analysis/CFG.cpp (original)
> +++ cfe/trunk/lib/Analysis/CFG.cpp Mon Mar 19 18:48:41 2012
> @@ -3087,7 +3087,7 @@
>       const VarDecl *var = cast<CFGAutomaticObjDtor>(this)->getVarDecl();
>       QualType ty = var->getType();
>       ty = ty.getNonReferenceType();
> -      if (const ArrayType *arrayType = astContext.getAsArrayType(ty)) {
> +      while (const ArrayType *arrayType = astContext.getAsArrayType(ty)) {
>         ty = arrayType->getElementType();
>       }
>

This can be expressed more directly as:

ty = astContext.getBaseElementTy(ty);


>       const RecordType *recordType = ty->getAs<RecordType>();
>
> Added: cfe/trunk/test/SemaCXX/warn-everthing.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-everthing.cpp?rev=153067&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/warn-everthing.cpp (added)
> +++ cfe/trunk/test/SemaCXX/warn-everthing.cpp Mon Mar 19 18:48:41 2012
> @@ -0,0 +1,13 @@
> +// RUN: %clang -Weverything -fsyntax-only %s -verify
> +
> +// This previously crashed due to a bug in the CFG.  Exercising all
> +// warnings helps check CFG construction.
> +class PR12271 {
> +public:
> +  PR12271();
> +  ~PR12271();
> +};
> +
> +void testPR12271() {
> +  PR12271 a[1][1];
> +}
> \ No newline at end of file
>
>
> _______________________________________________
> 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/20120319/05ac160f/attachment.html>


More information about the cfe-commits mailing list