diff options
author | Chris Lattner <sabre@nondot.org> | 2011-02-17 07:39:24 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-02-17 07:39:24 +0000 |
commit | ad8dcf4a9df0e24051dc31bf9e6f3cd138a34298 (patch) | |
tree | d937c0c2c2c7d6a5a9ed8efbd45903e4314cba94 /lib/CodeGen/CGStmt.cpp | |
parent | 1aa3d81c6e63959ef149489eca42b1520c521af4 (diff) |
Step #1/N of implementing support for __label__: split labels into
LabelDecl and LabelStmt. There is a 1-1 correspondence between the
two, but this simplifies a bunch of code by itself. This is because
labels are the only place where we previously had references to random
other statements, causing grief for AST serialization and other stuff.
This does cause one regression (attr(unused) doesn't silence unused
label warnings) which I'll address next.
This does fix some minor bugs:
1. "The only valid attribute " diagnostic was capitalized.
2. Various diagnostics printed as ''labelname'' instead of 'labelname'
3. This reduces duplication of label checking between functions and blocks.
Review appreciated, particularly for the cindex and template bits.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125733 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGStmt.cpp')
-rw-r--r-- | lib/CodeGen/CGStmt.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index f782c8004a..f809c009ce 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -208,7 +208,7 @@ RValue CodeGenFunction::EmitCompoundStmt(const CompoundStmt &S, bool GetLast, // emitting them before we evaluate the subexpr. const Stmt *LastStmt = S.body_back(); while (const LabelStmt *LS = dyn_cast<LabelStmt>(LastStmt)) { - EmitLabel(*LS); + EmitLabel(LS->getDecl()); LastStmt = LS->getSubStmt(); } @@ -276,24 +276,24 @@ void CodeGenFunction::EmitBranch(llvm::BasicBlock *Target) { } CodeGenFunction::JumpDest -CodeGenFunction::getJumpDestForLabel(const LabelStmt *S) { - JumpDest &Dest = LabelMap[S]; +CodeGenFunction::getJumpDestForLabel(const LabelDecl *D) { + JumpDest &Dest = LabelMap[D]; if (Dest.isValid()) return Dest; // Create, but don't insert, the new block. - Dest = JumpDest(createBasicBlock(S->getName()), + Dest = JumpDest(createBasicBlock(D->getName()), EHScopeStack::stable_iterator::invalid(), NextCleanupDestIndex++); return Dest; } -void CodeGenFunction::EmitLabel(const LabelStmt &S) { - JumpDest &Dest = LabelMap[&S]; +void CodeGenFunction::EmitLabel(const LabelDecl *D) { + JumpDest &Dest = LabelMap[D]; // If we didn't need a forward reference to this label, just go // ahead and create a destination at the current scope. if (!Dest.isValid()) { - Dest = getJumpDestInCurrentScope(S.getName()); + Dest = getJumpDestInCurrentScope(D->getName()); // Otherwise, we need to give this label a target depth and remove // it from the branch-fixups list. @@ -311,7 +311,7 @@ void CodeGenFunction::EmitLabel(const LabelStmt &S) { void CodeGenFunction::EmitLabelStmt(const LabelStmt &S) { - EmitLabel(S); + EmitLabel(S.getDecl()); EmitStmt(S.getSubStmt()); } @@ -327,7 +327,7 @@ void CodeGenFunction::EmitGotoStmt(const GotoStmt &S) { void CodeGenFunction::EmitIndirectGotoStmt(const IndirectGotoStmt &S) { - if (const LabelStmt *Target = S.getConstantTarget()) { + if (const LabelDecl *Target = S.getConstantTarget()) { EmitBranchThroughCleanup(getJumpDestForLabel(Target)); return; } |