[cfe-commits] r97494 - in /cfe/trunk/lib/Sema: Sema.h SemaExpr.cpp
Douglas Gregor
dgregor at apple.com
Mon Mar 1 12:44:28 PST 2010
Author: dgregor
Date: Mon Mar 1 14:44:28 2010
New Revision: 97494
URL: http://llvm.org/viewvc/llvm-project?rev=97494&view=rev
Log:
Start detangling the BlockSemaInfo/Sema mess. No functionality change.
Modified:
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=97494&r1=97493&r2=97494&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Mon Mar 1 14:44:28 2010
@@ -108,9 +108,30 @@
class TargetAttributesSema;
class ADLResult;
-/// BlockSemaInfo - When a block is being parsed, this contains information
-/// about the block. It is pointed to from Sema::CurBlock.
-struct BlockSemaInfo {
+/// \brief Retains information about a function, method, or block that is
+/// currently being parsed.
+struct FunctionScopeInfo {
+ /// LabelMap - This is a mapping from label identifiers to the LabelStmt for
+ /// it (which acts like the label decl in some ways). Forward referenced
+ /// labels have a LabelStmt created for them with a null location & SubStmt.
+ llvm::DenseMap<IdentifierInfo*, LabelStmt*> LabelMap;
+
+ /// SwitchStack - This is the current set of active switch statements in the
+ /// block.
+ llvm::SmallVector<SwitchStmt*, 8> SwitchStack;
+
+ /// \brief Whether this scope information structure defined information for
+ /// a block.
+ bool IsBlockInfo;
+
+ FunctionScopeInfo() : IsBlockInfo(false) { }
+
+ static bool classof(const FunctionScopeInfo *FSI) { return true; }
+};
+
+
+/// \brief Retains information about a block that is currently being parsed.
+struct BlockScopeInfo : FunctionScopeInfo {
llvm::SmallVector<ParmVarDecl*, 8> Params;
bool hasPrototype;
bool isVariadic;
@@ -126,22 +147,16 @@
/// return types, if any, in the block body.
QualType ReturnType;
- /// LabelMap - This is a mapping from label identifiers to the LabelStmt for
- /// it (which acts like the label decl in some ways). Forward referenced
- /// labels have a LabelStmt created for them with a null location & SubStmt.
- llvm::DenseMap<IdentifierInfo*, LabelStmt*> LabelMap;
-
- /// SwitchStack - This is the current set of active switch statements in the
- /// block.
- llvm::SmallVector<SwitchStmt*, 8> SwitchStack;
-
/// SavedFunctionNeedsScopeChecking - This is the value of
/// CurFunctionNeedsScopeChecking at the point when the block started.
bool SavedFunctionNeedsScopeChecking;
- /// PrevBlockInfo - If this is nested inside another block, this points
- /// to the outer block.
- BlockSemaInfo *PrevBlockInfo;
+ BlockScopeInfo *PrevBlockInfo;
+
+ BlockScopeInfo() : FunctionScopeInfo() { IsBlockInfo = true; }
+
+ static bool classof(const FunctionScopeInfo *FSI) { return FSI->IsBlockInfo; }
+ static bool classof(const BlockScopeInfo *BSI) { return true; }
};
/// \brief Holds a QualType and a TypeSourceInfo* that came out of a declarator
@@ -202,7 +217,7 @@
/// CurBlock - If inside of a block definition, this contains a pointer to
/// the active block object that represents it.
- BlockSemaInfo *CurBlock;
+ BlockScopeInfo *CurBlock;
/// PackContext - Manages the stack for #pragma pack. An alignment
/// of 0 indicates default alignment.
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=97494&r1=97493&r2=97494&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Mar 1 14:44:28 2010
@@ -393,10 +393,10 @@
/// variables defined outside the block) or false if this is not needed (e.g.
/// for values inside the block or for globals).
///
-/// This also keeps the 'hasBlockDeclRefExprs' in the BlockSemaInfo records
+/// This also keeps the 'hasBlockDeclRefExprs' in the BlockScopeInfo records
/// up-to-date.
///
-static bool ShouldSnapshotBlockValueReference(BlockSemaInfo *CurBlock,
+static bool ShouldSnapshotBlockValueReference(BlockScopeInfo *CurBlock,
ValueDecl *VD) {
// If the value is defined inside the block, we couldn't snapshot it even if
// we wanted to.
@@ -421,7 +421,7 @@
// which case that outer block doesn't get "hasBlockDeclRefExprs") or it may
// be defined outside all of the current blocks (in which case the blocks do
// all get the bit). Walk the nesting chain.
- for (BlockSemaInfo *NextBlock = CurBlock->PrevBlockInfo; NextBlock;
+ for (BlockScopeInfo *NextBlock = CurBlock->PrevBlockInfo; NextBlock;
NextBlock = NextBlock->PrevBlockInfo) {
// If we found the defining block for the variable, don't mark the block as
// having a reference outside it.
@@ -6723,7 +6723,7 @@
/// ActOnBlockStart - This callback is invoked when a block literal is started.
void Sema::ActOnBlockStart(SourceLocation CaretLoc, Scope *BlockScope) {
// Analyze block parameters.
- BlockSemaInfo *BSI = new BlockSemaInfo();
+ BlockScopeInfo *BSI = new BlockScopeInfo();
// Add BSI to CurBlock.
BSI->PrevBlockInfo = CurBlock;
@@ -6846,7 +6846,7 @@
/// is invoked to pop the information about the block from the action impl.
void Sema::ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope) {
// Ensure that CurBlock is deleted.
- llvm::OwningPtr<BlockSemaInfo> CC(CurBlock);
+ llvm::OwningPtr<BlockScopeInfo> CC(CurBlock);
CurFunctionNeedsScopeChecking = CurBlock->SavedFunctionNeedsScopeChecking;
@@ -6865,7 +6865,7 @@
Diag(CaretLoc, diag::err_blocks_disable);
// Ensure that CurBlock is deleted.
- llvm::OwningPtr<BlockSemaInfo> BSI(CurBlock);
+ llvm::OwningPtr<BlockScopeInfo> BSI(CurBlock);
PopDeclContext();
More information about the cfe-commits
mailing list