[cfe-commits] PATCH: Adds basic support for typeid to CFG

Ted Kremenek kremenek at apple.com
Wed Apr 13 18:44:20 PDT 2011


On Apr 13, 2011, at 1:27 AM, Chandler Carruth wrote:

> Hello,
> 
> This patch appears to add 'typeid' support to the CFG. I wrote it while working on r129431, before remembering that -Wuninitialized uses its own custom CFG builder.
> 
> Unfortunately, I'm not certain if the patch adds support in the desired manner (I grouped code with similar code for handling sizeof, etc., rather than with C++-specific bits of the code). Also, I'm not sure how best to write a test for this. A pointer or two in the right direction would help there.
> <add-typeid-to-cfg.patch>_______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Hi Chandler,

+      if (cast<CXXRecordDecl>(Record->getDecl())->isPolymorphic())
+        addStmt(E->getExprOperand());
+  }

Instead of 'addStmt', I think this only needs to be 'Visit'.  'addStmt' is only needed when we want to force the expression to be listed in the CFGBlock, whereas Visit() causes us to do a recursive walk, adding Stmts to the CFGBlock as necessary. 

Also, this should probably be:

  return Visit(E->getExprOperand())

as 'Block' and the return value of that call are not guaranteed to be the same.  I think leaving 'return Block' at the end is fine.



More information about the cfe-commits mailing list