diff options
author | Steve Naroff <snaroff@apple.com> | 2009-02-28 16:48:43 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2009-02-28 16:48:43 +0000 |
commit | d123bd05cab62bb3c641d0c2343fd94e6a96235e (patch) | |
tree | 710a9706402f096e1bed6df64d28b5e65dccab2c /clang/lib/Sema/SemaExpr.cpp | |
parent | 638b836aab3e6df7a568913fad46fd70225a1d21 (diff) | |
download | bcm5719-llvm-d123bd05cab62bb3c641d0c2343fd94e6a96235e.tar.gz bcm5719-llvm-d123bd05cab62bb3c641d0c2343fd94e6a96235e.zip |
Fix <rdar://problem/6451399> problems with labels and blocks.
- Move the 'LabelMap' from Sema to Scope. To avoid layering problems, the second element is now a 'StmtTy *', which makes the LabelMap a bit more verbose to deal with.
- Add 'ActiveScope' to Sema. Managed by ActOnStartOfFunctionDef(), ObjCActOnStartOfMethodDef(), ActOnBlockStmtExpr().
- Changed ActOnLabelStmt(), ActOnGotoStmt(), ActOnAddrLabel(), and ActOnFinishFunctionBody() to use the new ActiveScope.
- Added FIXME to workaround in ActOnFinishFunctionBody() (for dealing with C++ nested functions).
llvm-svn: 65694
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 8604670d6ed..e34a22e039b 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -4204,13 +4204,20 @@ Sema::ExprResult Sema::ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, IdentifierInfo *LabelII) { // Look up the record for this label identifier. - LabelStmt *&LabelDecl = LabelMap[LabelII]; + llvm::DenseMap<IdentifierInfo*, Action::StmtTy*>::iterator I = + ActiveScope->LabelMap.find(LabelII); + LabelStmt *LabelDecl; + // If we haven't seen this label yet, create a forward reference. It // will be validated and/or cleaned up in ActOnFinishFunctionBody. - if (LabelDecl == 0) + if (I == ActiveScope->LabelMap.end()) { LabelDecl = new (Context) LabelStmt(LabLoc, LabelII, 0); + ActiveScope->LabelMap.insert(std::make_pair(LabelII, LabelDecl)); + } else + LabelDecl = static_cast<LabelStmt *>(I->second); + // Create the AST node. The address of a label always has type 'void*'. return new (Context) AddrLabelExpr(OpLoc, LabLoc, LabelDecl, Context.getPointerType(Context.VoidTy)); @@ -4397,7 +4404,9 @@ void Sema::ActOnBlockStart(SourceLocation CaretLoc, Scope *BlockScope) { // Add BSI to CurBlock. BSI->PrevBlockInfo = CurBlock; + BSI->PrevFunctionScope = ActiveScope; CurBlock = BSI; + ActiveScope = BlockScope; BSI->ReturnType = 0; BSI->TheScope = BlockScope; @@ -4492,6 +4501,8 @@ Sema::ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, StmtTy *body, PopDeclContext(); + ActiveScope = CurBlock->PrevFunctionScope; + // Pop off CurBlock, handle nested blocks. CurBlock = CurBlock->PrevBlockInfo; |