diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-05-24 01:35:07 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-05-24 01:35:07 +0000 |
commit | 8458c9ef42390b3042765c33b09b4ade0e9c22fc (patch) | |
tree | 9c9a4e9bebc65078ddc4e3173b22f4356997d906 /clang/lib/Sema/SemaExprCXX.cpp | |
parent | 1293de8b1733e85d13960c150b86a1fe3813ae3f (diff) | |
download | bcm5719-llvm-8458c9ef42390b3042765c33b09b4ade0e9c22fc.tar.gz bcm5719-llvm-8458c9ef42390b3042765c33b09b4ade0e9c22fc.zip |
Factor out repeated code to build 'this' expressions and mark them
referenced.
llvm-svn: 361588
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 455a71bd0ac..e3286e8943f 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1298,10 +1298,20 @@ ExprResult Sema::ActOnCXXThis(SourceLocation Loc) { /// which the function is called. QualType ThisTy = getCurrentThisType(); - if (ThisTy.isNull()) return Diag(Loc, diag::err_invalid_this_use); + if (ThisTy.isNull()) + return Diag(Loc, diag::err_invalid_this_use); + return BuildCXXThisExpr(Loc, ThisTy, /*isImplicit=*/false); +} + +Expr *Sema::BuildCXXThisExpr(SourceLocation Loc, QualType Type, + bool IsImplicit) { + auto *This = new (Context) CXXThisExpr(Loc, Type, IsImplicit); + MarkThisReferenced(This); + return This; +} - CheckCXXThisCapture(Loc); - return new (Context) CXXThisExpr(Loc, ThisTy, /*isImplicit=*/false); +void Sema::MarkThisReferenced(CXXThisExpr *This) { + CheckCXXThisCapture(This->getExprLoc()); } bool Sema::isThisOutsideMemberFunctionBody(QualType BaseType) { |