aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExprCXX.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-10-18 16:47:30 +0000
committerDouglas Gregor <dgregor@apple.com>2011-10-18 16:47:30 +0000
commit341350ee62abd1ad818e1e3d926cd718960e439b (patch)
tree5a0762b6ec2cb734e5de95f456f2759e49fc7f76 /lib/Sema/SemaExprCXX.cpp
parenta50216cdd5c4102b051d5837c239ec0bb5bde6e5 (diff)
Make it possible to compute the type of 'this' without capturing
it. Refactoring to be used in a moment. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142360 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprCXX.cpp')
-rw-r--r--lib/Sema/SemaExprCXX.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 3300444a1c..4cd2af1c4e 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -636,7 +636,7 @@ ExprResult Sema::CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *E,
return Owned(E);
}
-QualType Sema::getAndCaptureCurrentThisType() {
+QualType Sema::getCurrentThisType(bool Capture) {
// Ignore block scopes: we can capture through them.
// Ignore nested enum scopes: we'll diagnose non-constant expressions
// where they're invalid, and other uses are legitimate.
@@ -666,11 +666,13 @@ QualType Sema::getAndCaptureCurrentThisType() {
ThisTy = Context.getPointerType(Context.getRecordType(RD));
}
+ if (!Capture || ThisTy.isNull())
+ return ThisTy;
+
// Mark that we're closing on 'this' in all the block scopes we ignored.
- if (!ThisTy.isNull())
- for (unsigned idx = FunctionScopes.size() - 1;
- NumBlocks; --idx, --NumBlocks)
- cast<BlockScopeInfo>(FunctionScopes[idx])->CapturesCXXThis = true;
+ for (unsigned idx = FunctionScopes.size() - 1;
+ NumBlocks; --idx, --NumBlocks)
+ cast<BlockScopeInfo>(FunctionScopes[idx])->CapturesCXXThis = true;
return ThisTy;
}
@@ -680,7 +682,7 @@ ExprResult Sema::ActOnCXXThis(SourceLocation Loc) {
/// is a non-lvalue expression whose value is the address of the object for
/// which the function is called.
- QualType ThisTy = getAndCaptureCurrentThisType();
+ QualType ThisTy = getCurrentThisType();
if (ThisTy.isNull()) return Diag(Loc, diag::err_invalid_this_use);
return Owned(new (Context) CXXThisExpr(Loc, ThisTy, /*isImplicit=*/false));