Start detangling the BlockSemaInfo/Sema mess. No functionality change.

llvm-svn: 97494
This commit is contained in:
Douglas Gregor
2010-03-01 20:44:28 +00:00
parent aaecdaeb5d
commit 4f13beb8b6
2 changed files with 37 additions and 22 deletions

View File

@@ -108,9 +108,30 @@ namespace clang {
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 @@ struct BlockSemaInfo {
/// 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 @@ public:
/// 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.

View File

@@ -393,10 +393,10 @@ Sema::ActOnStringLiteral(const Token *StringToks, unsigned NumStringToks) {
/// 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 @@ static bool ShouldSnapshotBlockValueReference(BlockSemaInfo *CurBlock,
// 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 @@ Sema::OwningExprResult Sema::ActOnChooseExpr(SourceLocation BuiltinLoc,
/// 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 @@ void Sema::ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) {
/// 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 @@ Sema::OwningExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
Diag(CaretLoc, diag::err_blocks_disable);
// Ensure that CurBlock is deleted.
llvm::OwningPtr<BlockSemaInfo> BSI(CurBlock);
llvm::OwningPtr<BlockScopeInfo> BSI(CurBlock);
PopDeclContext();