diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-05-11 20:24:17 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-05-11 20:24:17 +0000 |
commit | bbbe074566a8defed299ff676bc65b3631861768 (patch) | |
tree | 8b70d4484b997887ce835dcfe1d4a5239bf15e67 /lib/Sema/SemaExprCXX.cpp | |
parent | 92dd1915842410005c68d32c43bb3b3cf5a4a702 (diff) |
Do not mark the virtual members of an implicitly-instantiated class as
referenced unless we see one of them defined (or the key function
defined, if it as one) or if we need the vtable for something. Fixes
PR7114.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103497 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprCXX.cpp')
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 67ad45d74b..e3ca4355e6 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -287,7 +287,7 @@ Sema::OwningExprResult Sema::BuildCXXTypeId(QualType TypeInfoType, if (T->getAs<RecordType>() && RequireCompleteType(TypeidLoc, T, diag::err_incomplete_typeid)) return ExprError(); - + return Owned(new (Context) CXXTypeidExpr(TypeInfoType.withConst(), Operand, SourceRange(TypeidLoc, RParenLoc))); @@ -314,8 +314,10 @@ Sema::OwningExprResult Sema::BuildCXXTypeId(QualType TypeInfoType, // When typeid is applied to an expression other than an lvalue of a // polymorphic class type [...] [the] expression is an unevaluated // operand. [...] - if (RecordD->isPolymorphic() && E->isLvalue(Context) == Expr::LV_Valid) + if (RecordD->isPolymorphic() && E->isLvalue(Context) == Expr::LV_Valid) { isUnevaluatedOperand = false; + MaybeMarkVirtualMembersReferenced(TypeidLoc, RecordD); + } } // C++ [expr.typeid]p4: @@ -445,6 +447,14 @@ bool Sema::CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *&E) { if (Res.isInvalid()) return true; E = Res.takeAs<Expr>(); + + if (const RecordType *RecordTy = Ty->getAs<RecordType>()) { + // If we're throwing a polymorphic class, we need to make sure + // there is a vtable. + MaybeMarkVirtualMembersReferenced(ThrowLoc, + cast<CXXRecordDecl>(RecordTy->getDecl())); + } + return false; } |