[cfe-commits] r137426 - in /cfe/trunk: lib/Analysis/CFG.cpptest/SemaCXX/cfg.cpp
Ted Kremenek
kremenek at apple.com
Thu Aug 11 22:34:07 PDT 2011
No we don't need to support this. I was surprised that Clang accepted it. If GCC rejects it, Clang certainly should.
On Aug 11, 2011, at 9:44 PM, Xu Zhongxing <xuzhongxing at foxmail.com> wrote:
> Hi Ted,
>
> This code is ill-formed per n3242: 6.7 p3. gcc rejects it. But clang accepts it. Do we need to handle it?
>
>
> ------------------ Original ------------------
> From: "kremenek"<kremenek at apple.com>;
> Date: Fri, Aug 12, 2011 12:09 PM
> To: "cfe-commits"<cfe-commits at cs.uiuc.edu>;
> Subject: [cfe-commits] r137426 - in /cfe/trunk: lib/Analysis/CFG.cpptest/SemaCXX/cfg.cpp
>
> Author: kremenek
> Date: Thu Aug 11 23:09:00 2011
> New Revision: 137426
>
> URL: http://llvm.org/viewvc/llvm-project?rev=137426&view=rev
> Log:
> Fix crash in CFGBuilder involving implicit destructor calls and gotos jumping after an object was declared. Fixes PR 10620.
>
> Added:
> cfe/trunk/test/SemaCXX/cfg.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=137426&r1=137425&r2=137426&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Analysis/CFG.cpp (original)
> +++ cfe/trunk/lib/Analysis/CFG.cpp Thu Aug 11 23:09:00 2011
> @@ -191,8 +191,8 @@
> int D = 0;
> const_iterator F = *this;
> while (F.Scope != L.Scope) {
> - assert (F != const_iterator()
> - && "L iterator is not reachable from F iterator.");
> + if (F == const_iterator())
> + return D;
> D += F.VarIter;
> F = F.Scope->Prev;
> }
> @@ -816,10 +816,12 @@
> /// performed in place specified with iterator.
> void CFGBuilder::insertAutomaticObjDtors(CFGBlock* Blk, CFGBlock::iterator I,
> LocalScope::const_iterator B, LocalScope::const_iterator E, Stmt* S) {
> - BumpVectorContext& C = cfg->getBumpVectorContext();
> - I = Blk->beginAutomaticObjDtorsInsert(I, B.distance(E), C);
> - while (B != E)
> - I = Blk->insertAutomaticObjDtor(I, *B++, S);
> + if (int Cnt = B.distance(E)) {
> + BumpVectorContext& C = cfg->getBumpVectorContext();
> + I = Blk->beginAutomaticObjDtorsInsert(I, Cnt, C);
> + while (B != E)
> + I = Blk->insertAutomaticObjDtor(I, *B++, S);
> + }
> }
>
> /// appendAutomaticObjDtors - Append destructor CFGElements for variables with
>
> Added: cfe/trunk/test/SemaCXX/cfg.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cfg.cpp?rev=137426&view=auto
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/cfg.cpp (added)
> +++ cfe/trunk/test/SemaCXX/cfg.cpp Thu Aug 11 23:09:00 2011
> @@ -0,0 +1,23 @@
> +// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -fsyntax-only %s
> +
> +// Test that the CFG builder handles destructors and gotos jumping between
> +// scope boundaries. Previously this crashed (PR 10620).
> +struct S_10620 {
> + S_10620(const S_10620 &x);
> + ~S_10620();
> +};
> +void PR10620(int x, const S_10620& s) {
> + if (x) {
> + goto done;
> + }
> + const S_10620 s2(s);
> +done:
> + ;
> +}
> +void PR10620_2(int x, const S_10620& s) {
> + if (x)
> + goto done;
> + const S_10620 s2(s);
> +done:
> + ;
> +}
> \ 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/20110811/0fa185a8/attachment.html>
More information about the cfe-commits
mailing list