summaryrefslogtreecommitdiffstats
path: root/clang/lib
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
commit09deffa06745ad1920bd36a0011a4eeacdaa7455 (patch)
tree7e3cf82cd222c896afae6c77482d5d6623fc4810 /clang/lib
parent35c7f98734f7ad63d938ef4f0cc1680841d2c68e (diff)
downloadbcm5719-llvm-09deffa06745ad1920bd36a0011a4eeacdaa7455.tar.gz
bcm5719-llvm-09deffa06745ad1920bd36a0011a4eeacdaa7455.zip
Make it possible to compute the type of 'this' without capturing
it. Refactoring to be used in a moment. llvm-svn: 142360
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp14
-rw-r--r--clang/lib/Sema/SemaExprMember.cpp4
2 files changed, 10 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 3300444a1c1..4cd2af1c4ec 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/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));
diff --git a/clang/lib/Sema/SemaExprMember.cpp b/clang/lib/Sema/SemaExprMember.cpp
index 32a5194cec4..16c17fb8909 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -697,7 +697,7 @@ Sema::BuildAnonymousStructUnionMemberReference(const CXXScopeSpec &SS,
// We've found a member of an anonymous struct/union that is
// inside a non-anonymous struct/union, so in a well-formed
// program our base object expression is "this".
- QualType ThisTy = getAndCaptureCurrentThisType();
+ QualType ThisTy = getCurrentThisType();
if (ThisTy.isNull()) {
Diag(loc, diag::err_invalid_member_use_in_static_method)
<< indirectField->getDeclName();
@@ -1569,7 +1569,7 @@ Sema::BuildImplicitMemberExpr(const CXXScopeSpec &SS,
// If this is known to be an instance access, go ahead and build an
// implicit 'this' expression now.
// 'this' expression now.
- QualType ThisTy = getAndCaptureCurrentThisType();
+ QualType ThisTy = getCurrentThisType();
assert(!ThisTy.isNull() && "didn't correctly pre-flight capture of 'this'");
Expr *baseExpr = 0; // null signifies implicit access
OpenPOWER on IntegriCloud