[cfe-commits] r41258 - in /cfe/trunk: AST/CFG.cpp include/clang/AST/CFG.h

Chris Lattner clattner at apple.com
Tue Aug 21 22:43:41 PDT 2007


> URL: http://llvm.org/viewvc/llvm-project?rev=41258&view=rev
> Log:
> Added CFG support for gotos and labels.

Nice Ted!

> +  typedef std::list<CFGBlock*> BackpatchBlocksTy;
> +  BackpatchBlocksTy BackpatchBlocks;

Please switch this to std::vector instead of std::list.  std::list is  
inefficient for small objects like pointers.

> +      // Backpatch the gotos whose label -> block mappings we  
> didn't know
> +      // when we encountered them.
> +      for (BackpatchBlocksTy::iterator I = BackpatchBlocks.begin(),
> +           E = BackpatchBlocks.end(); I != E; ++I ) {
> +
> +        CFGBlock* B = *I;
> +        GotoStmt* G = cast<GotoStmt>(B->getTerminator());
> +        LabelMapTy::iterator LI = LabelMap.find(G->getLabel());
> +
> +        if (LI == LabelMap.end())
> +          return NULL; // No matching label.  Bad CFG.

This should be an assert.  The CFG should only be built for valid ASTs.

-Chris



More information about the cfe-commits mailing list