From 18062394db459158942ab491a88b9d52a5c0ab0d Mon Sep 17 00:00:00 2001 From: Serge Pavlov Date: Tue, 27 Aug 2013 13:15:56 +0000 Subject: [PATCH] Cleanup of OpaquePtr. No functionality changes. - Some documenation were added. - Usages of OpaquePtr.getAsVal() were replaced by OpaquePtr.get(). - Methods getAs and getAsVal were renamed to getPtrTo and getPtrAs respectively. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189346 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Sema/Ownership.h | 22 ++++++++++++++++++---- lib/Sema/SemaCodeComplete.cpp | 2 +- lib/Sema/SemaDecl.cpp | 2 +- lib/Sema/SemaDeclObjC.cpp | 4 ++-- lib/Sema/SemaStmt.cpp | 4 ++-- lib/Sema/SemaTemplate.cpp | 8 ++++---- lib/Sema/TreeTransform.h | 2 +- 7 files changed, 29 insertions(+), 15 deletions(-) diff --git a/include/clang/Sema/Ownership.h b/include/clang/Sema/Ownership.h index 92c486db36..b7d7710eb1 100644 --- a/include/clang/Sema/Ownership.h +++ b/include/clang/Sema/Ownership.h @@ -33,8 +33,12 @@ namespace clang { class TemplateName; class TemplateParameterList; - /// OpaquePtr - This is a very simple POD type that wraps a pointer that the - /// Parser doesn't know about but that Sema or another client does. The UID + /// \brief Wrapper for void* pointer. + /// \tparam PtrTy Either a pointer type like 'T*' or a type that behaves like + /// a pointer. + /// + /// This is a very simple POD type that wraps a pointer that the Parser + /// doesn't know about but that Sema or another client does. The PtrTy /// template argument is used to make sure that "Decl" pointers are not /// compatible with "Type" pointers for example. template @@ -49,11 +53,21 @@ namespace clang { static OpaquePtr make(PtrTy P) { OpaquePtr OP; OP.set(P); return OP; } - template T* getAs() const { + /// \brief Returns plain pointer to the entity pointed by this wrapper. + /// \tparam PointeeT Type of pointed entity. + /// + /// It is identical to getPtrAs. + template PointeeT* getPtrTo() const { return get(); } - template T getAsVal() const { + /// \brief Returns pointer converted to the specified type. + /// \tparam PtrT Result pointer type. There must be implicit conversion + /// from PtrTy to PtrT. + /// + /// In contrast to getPtrTo, this method allows the return type to be + /// a smart pointer. + template PtrT getPtrAs() const { return get(); } diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index aa60a28423..5e084eb5d4 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -5670,7 +5670,7 @@ void Sema::CodeCompleteObjCForCollection(Scope *S, Data.ObjCCollection = true; if (IterationVar.getAsOpaquePtr()) { - DeclGroupRef DG = IterationVar.getAsVal(); + DeclGroupRef DG = IterationVar.get(); for (DeclGroupRef::iterator I = DG.begin(), End = DG.end(); I != End; ++I) { if (*I) Data.IgnoreDecls.push_back(*I); diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 80863e35e2..d831c70619 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -442,7 +442,7 @@ bool Sema::DiagnoseUnknownTypeName(IdentifierInfo *&II, if (isTemplateName(S, SS ? *SS : EmptySS, /*hasTemplateKeyword=*/false, Name, ParsedType(), true, TemplateResult, MemberOfUnknownSpecialization) == TNK_Type_template) { - TemplateName TplName = TemplateResult.getAsVal(); + TemplateName TplName = TemplateResult.get(); Diag(IILoc, diag::err_template_missing_args) << TplName; if (TemplateDecl *TplDecl = TplName.getAsTemplateDecl()) { Diag(TplDecl->getLocation(), diag::note_template_decl_here) diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index b4fcce7fa7..b938bd6f8b 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -2680,7 +2680,7 @@ Decl *Sema::ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef allMethods, if (isInterfaceDeclKind) { // Reject invalid vardecls. for (unsigned i = 0, e = allTUVars.size(); i != e; i++) { - DeclGroupRef DG = allTUVars[i].getAsVal(); + DeclGroupRef DG = allTUVars[i].get(); for (DeclGroupRef::iterator I = DG.begin(), E = DG.end(); I != E; ++I) if (VarDecl *VDecl = dyn_cast(*I)) { if (!VDecl->hasExternalStorage()) @@ -2691,7 +2691,7 @@ Decl *Sema::ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef allMethods, ActOnObjCContainerFinishDefinition(); for (unsigned i = 0, e = allTUVars.size(); i != e; i++) { - DeclGroupRef DG = allTUVars[i].getAsVal(); + DeclGroupRef DG = allTUVars[i].get(); for (DeclGroupRef::iterator I = DG.begin(), E = DG.end(); I != E; ++I) (*I)->setTopLevelDeclInObjCContainer(); Consumer.HandleTopLevelDeclInObjCContainer(DG); diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 8f907460c4..861c1c8bd0 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -65,7 +65,7 @@ StmtResult Sema::ActOnNullStmt(SourceLocation SemiLoc, StmtResult Sema::ActOnDeclStmt(DeclGroupPtrTy dg, SourceLocation StartLoc, SourceLocation EndLoc) { - DeclGroupRef DG = dg.getAsVal(); + DeclGroupRef DG = dg.get(); // If we have an invalid decl, just return an error. if (DG.isNull()) return StmtError(); @@ -74,7 +74,7 @@ StmtResult Sema::ActOnDeclStmt(DeclGroupPtrTy dg, SourceLocation StartLoc, } void Sema::ActOnForEachDeclStmt(DeclGroupPtrTy dg) { - DeclGroupRef DG = dg.getAsVal(); + DeclGroupRef DG = dg.get(); // If we don't have a declaration, or we have an invalid declaration, // just return. diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 8170fb9a50..4268aa24e3 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -2113,7 +2113,7 @@ Sema::ActOnTemplateIdType(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, if (SS.isInvalid()) return true; - TemplateName Template = TemplateD.getAsVal(); + TemplateName Template = TemplateD.get(); // Translate the parser's template argument list in our AST format. TemplateArgumentListInfo TemplateArgs(LAngleLoc, RAngleLoc); @@ -2180,7 +2180,7 @@ TypeResult Sema::ActOnTagTemplateIdType(TagUseKind TUK, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc) { - TemplateName Template = TemplateD.getAsVal(); + TemplateName Template = TemplateD.get(); // Translate the parser's template argument list in our AST format. TemplateArgumentListInfo TemplateArgs(LAngleLoc, RAngleLoc); @@ -5680,7 +5680,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, ? TemplateParameterLists[0]->getTemplateLoc() : SourceLocation(); // Find the class template we're specializing - TemplateName Name = TemplateD.getAsVal(); + TemplateName Name = TemplateD.get(); ClassTemplateDecl *ClassTemplate = dyn_cast_or_null(Name.getAsTemplateDecl()); @@ -6793,7 +6793,7 @@ Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation RAngleLoc, AttributeList *Attr) { // Find the class template we're specializing - TemplateName Name = TemplateD.getAsVal(); + TemplateName Name = TemplateD.get(); TemplateDecl *TD = Name.getAsTemplateDecl(); // Check that the specialization uses the same tag kind as the // original template. diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index a627944ef4..0d0603f2d8 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -9484,7 +9484,7 @@ TreeTransform::RebuildTemplateName(CXXScopeSpec &SS, ParsedType::make(ObjectType), /*EnteringContext=*/false, Template); - return Template.template getAsVal(); + return Template.get(); } template -- 2.40.0