aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Sema
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2012-01-26 03:00:14 +0000
committerEli Friedman <eli.friedman@gmail.com>2012-01-26 03:00:14 +0000
commit84b007fae6c0cd30fa07074d34fbe2bf61fa44f9 (patch)
tree0dea52c0e79905f26bfa3bd92e6123688142daaa /include/clang/Sema
parent61d679ab2831b161c857cf3f974312fbd4ef1efd (diff)
Refactor to share code for handling return statements between lambda expressions and block literals. As it turns out, almost all the logic can be shared.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149031 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Sema')
-rw-r--r--include/clang/Sema/ScopeInfo.h23
-rw-r--r--include/clang/Sema/Sema.h2
2 files changed, 12 insertions, 13 deletions
diff --git a/include/clang/Sema/ScopeInfo.h b/include/clang/Sema/ScopeInfo.h
index 3b3bc5caf2..7ffc3bcfb9 100644
--- a/include/clang/Sema/ScopeInfo.h
+++ b/include/clang/Sema/ScopeInfo.h
@@ -166,7 +166,8 @@ public:
};
CapturingScopeInfo(DiagnosticsEngine &Diag, ImplicitCaptureStyle Style)
- : FunctionScopeInfo(Diag), ImpCaptureStyle(Style), CXXThisCaptureIndex(0)
+ : FunctionScopeInfo(Diag), ImpCaptureStyle(Style), CXXThisCaptureIndex(0),
+ HasImplicitReturnType(false)
{}
/// CaptureMap - A map of captured variables to (index+1) into Captures.
@@ -179,6 +180,14 @@ public:
/// Captures - The captures.
SmallVector<Capture, 4> Captures;
+ /// \brief - Whether the target type of return statements in this context
+ /// is deduced (e.g. a lambda or block with omitted return type).
+ bool HasImplicitReturnType;
+
+ /// ReturnType - The target type of return statements in this context,
+ /// or null if unknown.
+ QualType ReturnType;
+
void AddCapture(VarDecl *Var, bool isByref, bool isNested, Expr *Cpy) {
Captures.push_back(Capture(Var, isByref, isNested, Cpy));
CaptureMap[Var] = Captures.size();
@@ -204,10 +213,6 @@ public:
/// arguments etc.
Scope *TheScope;
- /// ReturnType - The return type of the block, or null if the block
- /// signature didn't provide an explicit return type.
- QualType ReturnType;
-
/// BlockType - The function type of the block, if one was given.
/// Its return type may be BuiltinType::Dependent.
QualType FunctionType;
@@ -236,15 +241,9 @@ public:
/// explicit captures.
unsigned NumExplicitCaptures;
- /// \brief - Whether the return type of the lambda is implicit
- bool HasImplicitReturnType;
-
- /// ReturnType - The return type of the lambda, or null if unknown.
- QualType ReturnType;
-
LambdaScopeInfo(DiagnosticsEngine &Diag, CXXRecordDecl *Lambda)
: CapturingScopeInfo(Diag, ImpCap_None), Lambda(Lambda),
- NumExplicitCaptures(0), HasImplicitReturnType(false)
+ NumExplicitCaptures(0)
{
Kind = SK_Lambda;
}
diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h
index 12096f5fcb..97e09cfd01 100644
--- a/include/clang/Sema/Sema.h
+++ b/include/clang/Sema/Sema.h
@@ -2137,7 +2137,7 @@ public:
bool AllowFunctionParameters);
StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp);
- StmtResult ActOnBlockReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp);
+ StmtResult ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp);
StmtResult ActOnAsmStmt(SourceLocation AsmLoc,
bool IsSimple, bool IsVolatile,