forked from OSchip/llvm-project
make scope checking be static functions instead of sema methods.
llvm-svn: 69429
This commit is contained in:
parent
c2e868fd14
commit
40cc0044e7
|
@ -492,18 +492,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RecursiveCalcJumpScopes(llvm::DenseMap<Stmt*, void*>& LabelScopeMap,
|
|
||||||
llvm::DenseMap<void*, Stmt*>& PopScopeMap,
|
|
||||||
llvm::DenseMap<Stmt*, void*>& GotoScopeMap,
|
|
||||||
std::vector<void*>& ScopeStack,
|
|
||||||
Stmt* CurStmt);
|
|
||||||
|
|
||||||
void RecursiveCalcLabelScopes(llvm::DenseMap<Stmt*, void*>& LabelScopeMap,
|
|
||||||
llvm::DenseMap<void*, Stmt*>& PopScopeMap,
|
|
||||||
std::vector<void*>& ScopeStack,
|
|
||||||
Stmt* CurStmt,
|
|
||||||
Stmt* ParentCompoundStmt);
|
|
||||||
|
|
||||||
/// Subroutines of ActOnDeclarator().
|
/// Subroutines of ActOnDeclarator().
|
||||||
TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, QualType T);
|
TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, QualType T);
|
||||||
bool MergeTypeDefDecl(TypedefDecl *New, Decl *Old);
|
bool MergeTypeDefDecl(TypedefDecl *New, Decl *Old);
|
||||||
|
|
|
@ -2924,11 +2924,11 @@ static bool StatementCreatesScope(Stmt* S) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Sema::RecursiveCalcLabelScopes(llvm::DenseMap<Stmt*, void*>& LabelScopeMap,
|
static void RecursiveCalcLabelScopes(llvm::DenseMap<Stmt*, void*>& LabelScopeMap,
|
||||||
llvm::DenseMap<void*, Stmt*>& PopScopeMap,
|
llvm::DenseMap<void*, Stmt*>& PopScopeMap,
|
||||||
std::vector<void*>& ScopeStack,
|
std::vector<void*>& ScopeStack,
|
||||||
Stmt* CurStmt,
|
Stmt* CurStmt,
|
||||||
Stmt* ParentCompoundStmt) {
|
Stmt* ParentCompoundStmt, Sema &S) {
|
||||||
for (Stmt::child_iterator i = CurStmt->child_begin();
|
for (Stmt::child_iterator i = CurStmt->child_begin();
|
||||||
i != CurStmt->child_end(); ++i) {
|
i != CurStmt->child_end(); ++i) {
|
||||||
if (!*i) continue;
|
if (!*i) continue;
|
||||||
|
@ -2948,28 +2948,28 @@ void Sema::RecursiveCalcLabelScopes(llvm::DenseMap<Stmt*, void*>& LabelScopeMap,
|
||||||
LabelScopeMap[CurStmt] = ScopeStack.size() ? ScopeStack.back() : 0;
|
LabelScopeMap[CurStmt] = ScopeStack.size() ? ScopeStack.back() : 0;
|
||||||
}
|
}
|
||||||
if (isa<DeclStmt>(*i)) continue;
|
if (isa<DeclStmt>(*i)) continue;
|
||||||
Stmt* CurCompound = isa<CompoundStmt>(*i) ? *i : ParentCompoundStmt;
|
|
||||||
|
Stmt *CurCompound = isa<CompoundStmt>(*i) ? *i : ParentCompoundStmt;
|
||||||
RecursiveCalcLabelScopes(LabelScopeMap, PopScopeMap, ScopeStack,
|
RecursiveCalcLabelScopes(LabelScopeMap, PopScopeMap, ScopeStack,
|
||||||
*i, CurCompound);
|
*i, CurCompound, S);
|
||||||
}
|
}
|
||||||
while (ScopeStack.size() && PopScopeMap[ScopeStack.back()] == CurStmt) {
|
|
||||||
|
while (ScopeStack.size() && PopScopeMap[ScopeStack.back()] == CurStmt)
|
||||||
ScopeStack.pop_back();
|
ScopeStack.pop_back();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sema::RecursiveCalcJumpScopes(llvm::DenseMap<Stmt*, void*>& LabelScopeMap,
|
static void RecursiveCalcJumpScopes(llvm::DenseMap<Stmt*, void*>& LabelScopeMap,
|
||||||
llvm::DenseMap<void*, Stmt*>& PopScopeMap,
|
llvm::DenseMap<void*, Stmt*>& PopScopeMap,
|
||||||
llvm::DenseMap<Stmt*, void*>& GotoScopeMap,
|
llvm::DenseMap<Stmt*, void*>& GotoScopeMap,
|
||||||
std::vector<void*>& ScopeStack,
|
std::vector<void*>& ScopeStack,
|
||||||
Stmt* CurStmt) {
|
Stmt *CurStmt, Sema &S) {
|
||||||
for (Stmt::child_iterator i = CurStmt->child_begin();
|
for (Stmt::child_iterator i = CurStmt->child_begin();
|
||||||
i != CurStmt->child_end(); ++i) {
|
i != CurStmt->child_end(); ++i) {
|
||||||
if (!*i) continue;
|
if (!*i) continue;
|
||||||
if (StatementCreatesScope(*i)) {
|
if (StatementCreatesScope(*i)) {
|
||||||
ScopeStack.push_back(*i);
|
ScopeStack.push_back(*i);
|
||||||
} else if (GotoStmt* GS = dyn_cast<GotoStmt>(*i)) {
|
} else if (GotoStmt* GS = dyn_cast<GotoStmt>(*i)) {
|
||||||
void* LScope = LabelScopeMap[GS->getLabel()];
|
if (void *LScope = LabelScopeMap[GS->getLabel()]) {
|
||||||
if (LScope) {
|
|
||||||
bool foundScopeInStack = false;
|
bool foundScopeInStack = false;
|
||||||
for (unsigned i = ScopeStack.size(); i > 0; --i) {
|
for (unsigned i = ScopeStack.size(); i > 0; --i) {
|
||||||
if (LScope == ScopeStack[i-1]) {
|
if (LScope == ScopeStack[i-1]) {
|
||||||
|
@ -2977,18 +2977,16 @@ void Sema::RecursiveCalcJumpScopes(llvm::DenseMap<Stmt*, void*>& LabelScopeMap,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!foundScopeInStack) {
|
if (!foundScopeInStack)
|
||||||
Diag(GS->getSourceRange().getBegin(), diag::err_goto_into_scope);
|
S.Diag(GS->getSourceRange().getBegin(), diag::err_goto_into_scope);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isa<DeclStmt>(*i)) continue;
|
if (isa<DeclStmt>(*i)) continue;
|
||||||
RecursiveCalcJumpScopes(LabelScopeMap, PopScopeMap, GotoScopeMap,
|
RecursiveCalcJumpScopes(LabelScopeMap, PopScopeMap, GotoScopeMap,
|
||||||
ScopeStack, *i);
|
ScopeStack, *i, S);
|
||||||
}
|
}
|
||||||
while (ScopeStack.size() && PopScopeMap[ScopeStack.back()] == CurStmt) {
|
while (ScopeStack.size() && PopScopeMap[ScopeStack.back()] == CurStmt)
|
||||||
ScopeStack.pop_back();
|
ScopeStack.pop_back();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg) {
|
Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg) {
|
||||||
|
@ -3046,8 +3044,10 @@ Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg) {
|
||||||
llvm::DenseMap<void*, Stmt*> PopScopeMap;
|
llvm::DenseMap<void*, Stmt*> PopScopeMap;
|
||||||
llvm::DenseMap<Stmt*, void*> GotoScopeMap;
|
llvm::DenseMap<Stmt*, void*> GotoScopeMap;
|
||||||
std::vector<void*> ScopeStack;
|
std::vector<void*> ScopeStack;
|
||||||
RecursiveCalcLabelScopes(LabelScopeMap, PopScopeMap, ScopeStack, Body, Body);
|
RecursiveCalcLabelScopes(LabelScopeMap, PopScopeMap, ScopeStack, Body, Body,
|
||||||
RecursiveCalcJumpScopes(LabelScopeMap, PopScopeMap, GotoScopeMap, ScopeStack, Body);
|
*this);
|
||||||
|
RecursiveCalcJumpScopes(LabelScopeMap, PopScopeMap, GotoScopeMap,
|
||||||
|
ScopeStack, Body, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return D;
|
return D;
|
||||||
|
|
Loading…
Reference in New Issue