summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/Sema/ScopeInfo.h15
-rw-r--r--clang/lib/Sema/Sema.cpp16
2 files changed, 14 insertions, 17 deletions
diff --git a/clang/include/clang/Sema/ScopeInfo.h b/clang/include/clang/Sema/ScopeInfo.h
index 50cfa9bb567..15d17306c9f 100644
--- a/clang/include/clang/Sema/ScopeInfo.h
+++ b/clang/include/clang/Sema/ScopeInfo.h
@@ -48,9 +48,8 @@ public:
/// \brief Whether this function contains any indirect gotos.
bool HasIndirectGoto;
- /// \brief The number of errors that had occurred before starting this
- /// function or block.
- unsigned NumErrorsAtStartOfFunction;
+ /// \brief Used to determine if errors occurred in this function or block.
+ DiagnosticErrorTrap ErrorTrap;
/// LabelMap - This is a mapping from label identifiers to the LabelStmt for
/// it (which acts like the label decl in some ways). Forward referenced
@@ -83,18 +82,18 @@ public:
(HasBranchProtectedScope && HasBranchIntoScope);
}
- FunctionScopeInfo(unsigned NumErrors)
+ FunctionScopeInfo(Diagnostic &Diag)
: IsBlockInfo(false),
HasBranchProtectedScope(false),
HasBranchIntoScope(false),
HasIndirectGoto(false),
- NumErrorsAtStartOfFunction(NumErrors) { }
+ ErrorTrap(Diag) { }
virtual ~FunctionScopeInfo();
/// \brief Clear out the information in this function scope, making it
/// suitable for reuse.
- void Clear(unsigned NumErrors);
+ void Clear();
static bool classof(const FunctionScopeInfo *FSI) { return true; }
};
@@ -118,8 +117,8 @@ public:
/// Its return type may be BuiltinType::Dependent.
QualType FunctionType;
- BlockScopeInfo(unsigned NumErrors, Scope *BlockScope, BlockDecl *Block)
- : FunctionScopeInfo(NumErrors), hasBlockDeclRefExprs(false),
+ BlockScopeInfo(Diagnostic &Diag, Scope *BlockScope, BlockDecl *Block)
+ : FunctionScopeInfo(Diag), hasBlockDeclRefExprs(false),
TheDecl(Block), TheScope(BlockScope)
{
IsBlockInfo = true;
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 8c1d5f449c6..ec7b61d32a3 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -39,7 +39,7 @@ using namespace sema;
FunctionScopeInfo::~FunctionScopeInfo() { }
-void FunctionScopeInfo::Clear(unsigned NumErrors) {
+void FunctionScopeInfo::Clear() {
HasBranchProtectedScope = false;
HasBranchIntoScope = false;
HasIndirectGoto = false;
@@ -47,7 +47,7 @@ void FunctionScopeInfo::Clear(unsigned NumErrors) {
LabelMap.clear();
SwitchStack.clear();
Returns.clear();
- NumErrorsAtStartOfFunction = NumErrors;
+ ErrorTrap.reset();
}
BlockScopeInfo::~BlockScopeInfo() { }
@@ -154,7 +154,7 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
ExprEvalContexts.push_back(
ExpressionEvaluationContextRecord(PotentiallyEvaluated, 0));
- FunctionScopes.push_back(new FunctionScopeInfo(Diags.getNumErrors()));
+ FunctionScopes.push_back(new FunctionScopeInfo(Diags));
}
void Sema::Initialize() {
@@ -535,17 +535,16 @@ void Sema::PushFunctionScope() {
if (FunctionScopes.size() == 1) {
// Use the "top" function scope rather than having to allocate
// memory for a new scope.
- FunctionScopes.back()->Clear(getDiagnostics().getNumErrors());
+ FunctionScopes.back()->Clear();
FunctionScopes.push_back(FunctionScopes.back());
return;
}
- FunctionScopes.push_back(
- new FunctionScopeInfo(getDiagnostics().getNumErrors()));
+ FunctionScopes.push_back(new FunctionScopeInfo(getDiagnostics()));
}
void Sema::PushBlockScope(Scope *BlockScope, BlockDecl *Block) {
- FunctionScopes.push_back(new BlockScopeInfo(getDiagnostics().getNumErrors(),
+ FunctionScopes.push_back(new BlockScopeInfo(getDiagnostics(),
BlockScope, Block));
}
@@ -559,8 +558,7 @@ void Sema::PopFunctionOrBlockScope() {
/// \brief Determine whether any errors occurred within this function/method/
/// block.
bool Sema::hasAnyErrorsInThisFunction() const {
- return getCurFunction()->NumErrorsAtStartOfFunction
- != getDiagnostics().getNumErrors();
+ return getCurFunction()->ErrorTrap.hasErrorOccurred();
}
BlockScopeInfo *Sema::getCurBlock() {
OpenPOWER on IntegriCloud