[cfe-commits] r96772 - /cfe/trunk/lib/Analysis/CFG.cpp

Daniel Dunbar daniel at zuster.org
Sun Feb 21 23:13:55 PST 2010


Hi Zhongxing,

On Sun, Feb 21, 2010 at 6:59 PM, Zhongxing Xu <xuzhongxing at gmail.com> wrote:
> Author: zhongxingxu
> Date: Sun Feb 21 20:59:27 2010
> New Revision: 96772
>
> URL: http://llvm.org/viewvc/llvm-project?rev=96772&view=rev
> Log:
> Simplify code: Succ is guaranteed to be not NULL.

This turns out not to be true, here is a test case:
--
ddunbar at giles:tmp$ cat t.m
@interface I0 @end
@implementation I0
- (id) im0 {
  @synchronized(self) {
    @try {}
    @catch (...) {}
  }
}
@end
ddunbar at giles:tmp$ clang -c t.m
Assertion failed: (B), function buildCFG, file
/Volumes/Data/Users/ddunbar/llvm/tools/clang/lib/Analysis/CFG.cpp,
line 267.
0  clang             0x0000000101338cd2 PrintStackTrace(void*) + 34
1  clang             0x000000010133955c SignalHandler(int) + 652
2  libSystem.B.dylib 0x00007fff881f4eaa _sigtramp + 26
3  libSystem.B.dylib 0x00007fff88199bea tiny_malloc_from_free_list + 1196
4  libSystem.B.dylib 0x00007fff88270e74 __pthread_markcancel + 0
5  clang             0x0000000100518b8d (anonymous
namespace)::CFGBuilder::buildCFG(clang::Decl const*, clang::Stmt*,
clang::ASTContext*, bool, bool) + 1245
6  clang             0x0000000100518e0b
clang::CFG::buildCFG(clang::Decl const*, clang::Stmt*,
clang::ASTContext*, bool, bool) + 523
7  clang             0x000000010050c94d clang::AnalysisContext::getCFG() + 93
8  clang             0x000000010028490f
clang::Sema::CheckFallThrough(clang::AnalysisContext&) + 31
9  clang             0x000000010028babe
clang::Sema::CheckFallThroughForFunctionDef(clang::Decl*,
clang::Stmt*, clang::AnalysisContext&) + 382
10 clang             0x00000001002b29a9
clang::Sema::ActOnFinishFunctionBody(clang::OpaquePtr<0>,
clang::ASTOwningResult<&(clang::ActionBase::DeleteStmt(void*))>, bool)
+ 377
11 clang             0x00000001002b3483
clang::Sema::ActOnFinishFunctionBody(clang::OpaquePtr<0>,
clang::ASTOwningResult<&(clang::ActionBase::DeleteStmt(void*))>) + 67
12 clang             0x0000000100638b73
clang::Parser::ParseObjCMethodDefinition() + 899
13 clang             0x0000000100656543
clang::Parser::ParseExternalDeclaration(clang::CXX0XAttributeList) +
2211
14 clang             0x0000000100656758
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<1>&) + 104
15 clang             0x0000000100270d4b
clang::ParseAST(clang::Preprocessor&, clang::ASTConsumer*,
clang::ASTContext&, bool, bool, clang::CodeCompleteConsumer*) + 251
16 clang             0x0000000100052659
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 393
17 clang             0x000000010003793e cc1_main(char const**, char
const**, char const*, void*) + 2062
18 clang             0x000000010003a89d main + 2077
19 clang             0x00000001000354c8 start + 52
20 clang             0x000000000000001d start + 4294749065
Stack dump:
0.	Program arguments:
/Volumes/Data/Users/ddunbar/llvm.obj.64/Release/bin/clang -cc1 -triple
x86_64-apple-darwin10.0.0 -S -disable-free -main-file-name t.m
-pic-level 1 -mdisable-fp-elim -munwind-tables -target-cpu core2
-resource-dir /Volumes/Data/Users/ddunbar/llvm.obj.64/Release/lib/clang/1.1
-fmessage-length 88 -stack-protector 1 -fblocks -fexceptions
-fobjc-nonfragile-abi -fdiagnostics-show-option -o
/var/folders/DQ/DQ8GT3++HESEzT1obWBynE+++TI/-Tmp-/cc-JnPFgL.s -x
objective-c t.m
1.	t.m:9:1: current parser token '@'
2.	t.m:3:12: parsing Objective-C method 'I0::im0'
clang: error: compiler command failed due to signal 6 (use -v to see invocation)
--

 - Daniel

> 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=96772&r1=96771&r2=96772&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Analysis/CFG.cpp (original)
> +++ cfe/trunk/lib/Analysis/CFG.cpp Sun Feb 21 20:59:27 2010
> @@ -264,44 +264,44 @@
>   if (!B)
>     B = Succ;
>
> -  if (B) {
> -    // Finalize the last constructed block.  This usually involves reversing the
> -    // order of the statements in the block.
> -    if (Block) FinishBlock(B);
> -
> -    // Backpatch the gotos whose label -> block mappings we didn't know when we
> -    // encountered them.
> -    for (BackpatchBlocksTy::iterator I = BackpatchBlocks.begin(),
> +  assert(B);
> +
> +  // Finalize the last constructed block.  This usually involves reversing the
> +  // order of the statements in the block.
> +  FinishBlock(B);
> +
> +  // 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());
> +    CFGBlock* B = *I;
> +    GotoStmt* G = cast<GotoStmt>(B->getTerminator());
> +    LabelMapTy::iterator LI = LabelMap.find(G->getLabel());
>
> -      // If there is no target for the goto, then we are looking at an
> -      // incomplete AST.  Handle this by not registering a successor.
> -      if (LI == LabelMap.end()) continue;
> +    // If there is no target for the goto, then we are looking at an
> +    // incomplete AST.  Handle this by not registering a successor.
> +    if (LI == LabelMap.end()) continue;
>
> -      AddSuccessor(B, LI->second);
> -    }
> +    AddSuccessor(B, LI->second);
> +  }
>
> -    // Add successors to the Indirect Goto Dispatch block (if we have one).
> -    if (CFGBlock* B = cfg->getIndirectGotoBlock())
> -      for (LabelSetTy::iterator I = AddressTakenLabels.begin(),
> +  // Add successors to the Indirect Goto Dispatch block (if we have one).
> +  if (CFGBlock* B = cfg->getIndirectGotoBlock())
> +    for (LabelSetTy::iterator I = AddressTakenLabels.begin(),
>            E = AddressTakenLabels.end(); I != E; ++I ) {
>
> -        // Lookup the target block.
> -        LabelMapTy::iterator LI = LabelMap.find(*I);
> +      // Lookup the target block.
> +      LabelMapTy::iterator LI = LabelMap.find(*I);
>
> -        // If there is no target block that contains label, then we are looking
> -        // at an incomplete AST.  Handle this by not registering a successor.
> -        if (LI == LabelMap.end()) continue;
> +      // If there is no target block that contains label, then we are looking
> +      // at an incomplete AST.  Handle this by not registering a successor.
> +      if (LI == LabelMap.end()) continue;
>
> -        AddSuccessor(B, LI->second);
> -      }
> +      AddSuccessor(B, LI->second);
> +    }
>
> -    Succ = B;
> -  }
> +  Succ = B;
>
>   // Create an empty entry block that has no predecessors.
>   cfg->setEntry(createBlock());
>
>
> _______________________________________________
> 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