[cfe-commits] r119764 - in /cfe/trunk: include/clang/Sema/ScopeInfo.h lib/Sema/Sema.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Thu Nov 18 16:19:15 PST 2010


Author: akirtzidis
Date: Thu Nov 18 18:19:15 2010
New Revision: 119764

URL: http://llvm.org/viewvc/llvm-project?rev=119764&view=rev
Log:
Refactoring. Get FunctionScopeInfo to use DiagnosticErrorTrap.

Modified:
    cfe/trunk/include/clang/Sema/ScopeInfo.h
    cfe/trunk/lib/Sema/Sema.cpp

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=119764&r1=119763&r2=119764&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Thu Nov 18 18:19:15 2010
@@ -48,9 +48,8 @@
   /// \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 @@
           (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 @@
   /// 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;

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=119764&r1=119763&r2=119764&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Thu Nov 18 18:19:15 2010
@@ -39,7 +39,7 @@
 
 FunctionScopeInfo::~FunctionScopeInfo() { }
 
-void FunctionScopeInfo::Clear(unsigned NumErrors) {
+void FunctionScopeInfo::Clear() {
   HasBranchProtectedScope = false;
   HasBranchIntoScope = false;
   HasIndirectGoto = false;
@@ -47,7 +47,7 @@
   LabelMap.clear();
   SwitchStack.clear();
   Returns.clear();
-  NumErrorsAtStartOfFunction = NumErrors;
+  ErrorTrap.reset();
 }
 
 BlockScopeInfo::~BlockScopeInfo() { }
@@ -154,7 +154,7 @@
   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 @@
   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 @@
 /// \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() {





More information about the cfe-commits mailing list