diff options
author | John McCall <rjmccall@apple.com> | 2010-02-02 09:10:11 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-02-02 09:10:11 +0000 |
commit | 03c4848bf4eab62311d277400afd8807eab05cd3 (patch) | |
tree | 9a84a37b56e69b408816c2359dda7c6d6909aa1f /clang | |
parent | 6781b05a9254f3aaf53126368d23ebda88e02c96 (diff) | |
download | bcm5719-llvm-03c4848bf4eab62311d277400afd8807eab05cd3.tar.gz bcm5719-llvm-03c4848bf4eab62311d277400afd8807eab05cd3.zip |
Mark dtors for parameter variables and eliminate some redundant type munging.
llvm-svn: 95079
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Sema/Sema.h | 4 | ||||
-rw-r--r-- | clang/lib/Sema/SemaAccess.cpp | 9 | ||||
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 5 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 11 |
5 files changed, 15 insertions, 20 deletions
diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h index e49ce733198..d971b9caebf 100644 --- a/clang/lib/Sema/Sema.h +++ b/clang/lib/Sema/Sema.h @@ -1932,7 +1932,7 @@ public: /// FinalizeVarWithDestructor - Prepare for calling destructor on the /// constructed variable. - void FinalizeVarWithDestructor(VarDecl *VD, QualType DeclInitType); + void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType); /// DefineImplicitDefaultConstructor - Checks for feasibility of /// defining this constructor as the default constructor. @@ -2417,7 +2417,7 @@ public: AccessSpecifier Access); bool CheckConstructorAccess(SourceLocation Loc, CXXConstructorDecl *D, AccessSpecifier Access); - bool CheckDestructorAccess(SourceLocation Loc, QualType T); + bool CheckDestructorAccess(SourceLocation Loc, const RecordType *Record); bool CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, NamedDecl *D, AccessSpecifier Access); bool CheckAccess(const LookupResult &R, NamedDecl *D, AccessSpecifier Access); diff --git a/clang/lib/Sema/SemaAccess.cpp b/clang/lib/Sema/SemaAccess.cpp index 98beb610a5e..9e1ab8cefd3 100644 --- a/clang/lib/Sema/SemaAccess.cpp +++ b/clang/lib/Sema/SemaAccess.cpp @@ -306,16 +306,11 @@ bool Sema::CheckUnresolvedMemberAccess(UnresolvedMemberExpr *E, return false; } -bool Sema::CheckDestructorAccess(SourceLocation Loc, - QualType T) { +bool Sema::CheckDestructorAccess(SourceLocation Loc, const RecordType *RT) { if (!getLangOptions().AccessControl) return false; - const RecordType *Record = T->getAs<RecordType>(); - if (!Record) - return false; - - CXXRecordDecl *NamingClass = cast<CXXRecordDecl>(Record->getDecl()); + CXXRecordDecl *NamingClass = cast<CXXRecordDecl>(RT->getDecl()); CXXDestructorDecl *Dtor = NamingClass->getDestructor(Context); AccessSpecifier Access = Dtor->getAccess(); diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 0d9918f6e43..cb0e5fb2181 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -2638,8 +2638,9 @@ bool Sema::CheckParmsForFunctionDef(FunctionDecl *FD) { } } - if (getLangOptions().AccessControl) - CheckDestructorAccess(Param->getLocation(), Param->getType()); + if (getLangOptions().CPlusPlus) + if (const RecordType *RT = Param->getType()->getAs<RecordType>()) + FinalizeVarWithDestructor(Param, RT); } return HasInvalidParm; diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 3798aaa5d18..ea1f2f2bf5d 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -3575,8 +3575,8 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) { QualType InitType = VDecl->getType(); while (const ArrayType *Array = Context.getAsArrayType(InitType)) InitType = Context.getBaseElementType(Array); - if (InitType->isRecordType()) - FinalizeVarWithDestructor(VDecl, InitType); + if (const RecordType *Record = InitType->getAs<RecordType>()) + FinalizeVarWithDestructor(VDecl, Record); } return; @@ -3667,7 +3667,7 @@ void Sema::ActOnUninitializedDecl(DeclPtrTy dcl, else { Var->setInit(Context, MaybeCreateCXXExprWithTemporaries(Init.takeAs<Expr>())); - FinalizeVarWithDestructor(Var, InitType); + FinalizeVarWithDestructor(Var, InitType->getAs<RecordType>()); } } else { Var->setInvalidDecl(); diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 931c058670b..4552d544b9c 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -3982,13 +3982,12 @@ bool Sema::InitializeVarWithConstructor(VarDecl *VD, return false; } -void Sema::FinalizeVarWithDestructor(VarDecl *VD, QualType DeclInitType) { - CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>( - DeclInitType->getAs<RecordType>()->getDecl()); +void Sema::FinalizeVarWithDestructor(VarDecl *VD, const RecordType *Record) { + CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(Record->getDecl()); if (!ClassDecl->hasTrivialDestructor()) { CXXDestructorDecl *Destructor = ClassDecl->getDestructor(Context); MarkDeclarationReferenced(VD->getLocation(), Destructor); - CheckDestructorAccess(VD->getLocation(), VD->getType()); + CheckDestructorAccess(VD->getLocation(), Record); } } @@ -4093,8 +4092,8 @@ void Sema::AddCXXDirectInitializerToDecl(DeclPtrTy Dcl, VDecl->setInit(Context, Result.takeAs<Expr>()); VDecl->setCXXDirectInitializer(true); - if (VDecl->getType()->getAs<RecordType>()) - FinalizeVarWithDestructor(VDecl, DeclInitType); + if (const RecordType *Record = VDecl->getType()->getAs<RecordType>()) + FinalizeVarWithDestructor(VDecl, Record); } /// \brief Add the applicable constructor candidates for an initialization |