diff options
author | Chris Lattner <sabre@nondot.org> | 2011-02-18 01:27:55 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-02-18 01:27:55 +0000 |
commit | 337e550218128e7d922c09bb354fbc71de90c568 (patch) | |
tree | ad1699cd2931e9dcb944ffe6ee620db7727c8ccc /lib/Sema/Sema.cpp | |
parent | 380ebecb32993bf0426e25519eb78d7816b74b12 (diff) |
Switch labels over to using normal name lookup, instead of their
own weird little DenseMap. Hey look, we now emit unused label
warnings deterministically, amazing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125813 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/Sema.cpp')
-rw-r--r-- | lib/Sema/Sema.cpp | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index be78024031..7eb1c57412 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -45,60 +45,11 @@ void FunctionScopeInfo::Clear() { HasBranchIntoScope = false; HasIndirectGoto = false; - LabelMap.clear(); SwitchStack.clear(); Returns.clear(); ErrorTrap.reset(); } -bool FunctionScopeInfo::checkLabelUse(Stmt *Body, Sema &S) { - bool AnyErrors = false; - // FIXME: The iteration order of this (and thus, the order of errors and - // warnings produced) is nondeterminstic. - for (llvm::DenseMap<IdentifierInfo*, LabelDecl*>::iterator - I = LabelMap.begin(), E = LabelMap.end(); I != E; ++I) { - LabelDecl *L = I->second; - - // Verify that we have no forward references left. If so, there was a goto - // or address of a label taken, but no definition of it. Label fwd - // definitions are indicated with a null substmt. - if (L->getStmt() != 0) { - S.DiagnoseUnusedDecl(L); - continue; - } - - AnyErrors = true; - - // Emit error. - S.Diag(L->getLocation(), diag::err_undeclared_label_use) << L->getDeclName(); - - // At this point, we have gotos that use the bogus label. Stitch it into - // the function body so that the AST is well formed. - if (Body == 0) { - // The whole function wasn't parsed correctly. - continue; - } - - // Otherwise, the body is valid: we want to stitch the label decl into the - // function somewhere so that it is properly owned and so that the goto - // has a valid target. Do this by creating LabelStmt and adding it to the - // end of the outer CompoundStmt. - LabelStmt *LS = new (S.Context) LabelStmt(L->getLocation(), L, - new (S.Context) NullStmt(L->getLocation())); - - CompoundStmt *Compound = isa<CXXTryStmt>(Body) ? - cast<CXXTryStmt>(Body)->getTryBlock() : - cast<CompoundStmt>(Body); - llvm::SmallVector<Stmt*, 64> Elements(Compound->body_begin(), - Compound->body_end()); - Elements.push_back(LS); - Compound->setStmts(S.Context, Elements.data(), Elements.size()); - } - return AnyErrors; -} - - - BlockScopeInfo::~BlockScopeInfo() { } void Sema::ActOnTranslationUnitScope(Scope *S) { |