Cleanup of OpaquePtr. No functionality changes.
- Some documenation were added. - Usages of OpaquePtr<A>.getAsVal<A>() were replaced by OpaquePtr<A>.get(). - Methods getAs and getAsVal were renamed to getPtrTo and getPtrAs respectively. llvm-svn: 189346
This commit is contained in:
@@ -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 <class PtrTy>
|
||||
@@ -49,11 +53,21 @@ namespace clang {
|
||||
|
||||
static OpaquePtr make(PtrTy P) { OpaquePtr OP; OP.set(P); return OP; }
|
||||
|
||||
template <typename T> 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<PointeeT*>.
|
||||
template <typename PointeeT> PointeeT* getPtrTo() const {
|
||||
return get();
|
||||
}
|
||||
|
||||
template <typename T> 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 <typename PtrT> PtrT getPtrAs() const {
|
||||
return get();
|
||||
}
|
||||
|
||||
|
||||
@@ -5670,7 +5670,7 @@ void Sema::CodeCompleteObjCForCollection(Scope *S,
|
||||
Data.ObjCCollection = true;
|
||||
|
||||
if (IterationVar.getAsOpaquePtr()) {
|
||||
DeclGroupRef DG = IterationVar.getAsVal<DeclGroupRef>();
|
||||
DeclGroupRef DG = IterationVar.get();
|
||||
for (DeclGroupRef::iterator I = DG.begin(), End = DG.end(); I != End; ++I) {
|
||||
if (*I)
|
||||
Data.IgnoreDecls.push_back(*I);
|
||||
|
||||
@@ -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>();
|
||||
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)
|
||||
|
||||
@@ -2680,7 +2680,7 @@ Decl *Sema::ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef<Decl *> allMethods,
|
||||
if (isInterfaceDeclKind) {
|
||||
// Reject invalid vardecls.
|
||||
for (unsigned i = 0, e = allTUVars.size(); i != e; i++) {
|
||||
DeclGroupRef DG = allTUVars[i].getAsVal<DeclGroupRef>();
|
||||
DeclGroupRef DG = allTUVars[i].get();
|
||||
for (DeclGroupRef::iterator I = DG.begin(), E = DG.end(); I != E; ++I)
|
||||
if (VarDecl *VDecl = dyn_cast<VarDecl>(*I)) {
|
||||
if (!VDecl->hasExternalStorage())
|
||||
@@ -2691,7 +2691,7 @@ Decl *Sema::ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef<Decl *> allMethods,
|
||||
ActOnObjCContainerFinishDefinition();
|
||||
|
||||
for (unsigned i = 0, e = allTUVars.size(); i != e; i++) {
|
||||
DeclGroupRef DG = allTUVars[i].getAsVal<DeclGroupRef>();
|
||||
DeclGroupRef DG = allTUVars[i].get();
|
||||
for (DeclGroupRef::iterator I = DG.begin(), E = DG.end(); I != E; ++I)
|
||||
(*I)->setTopLevelDeclInObjCContainer();
|
||||
Consumer.HandleTopLevelDeclInObjCContainer(DG);
|
||||
|
||||
@@ -65,7 +65,7 @@ StmtResult Sema::ActOnNullStmt(SourceLocation SemiLoc,
|
||||
|
||||
StmtResult Sema::ActOnDeclStmt(DeclGroupPtrTy dg, SourceLocation StartLoc,
|
||||
SourceLocation EndLoc) {
|
||||
DeclGroupRef DG = dg.getAsVal<DeclGroupRef>();
|
||||
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>();
|
||||
DeclGroupRef DG = dg.get();
|
||||
|
||||
// If we don't have a declaration, or we have an invalid declaration,
|
||||
// just return.
|
||||
|
||||
@@ -2113,7 +2113,7 @@ Sema::ActOnTemplateIdType(CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
|
||||
if (SS.isInvalid())
|
||||
return true;
|
||||
|
||||
TemplateName Template = TemplateD.getAsVal<TemplateName>();
|
||||
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>();
|
||||
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>();
|
||||
TemplateName Name = TemplateD.get();
|
||||
ClassTemplateDecl *ClassTemplate
|
||||
= dyn_cast_or_null<ClassTemplateDecl>(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>();
|
||||
TemplateName Name = TemplateD.get();
|
||||
TemplateDecl *TD = Name.getAsTemplateDecl();
|
||||
// Check that the specialization uses the same tag kind as the
|
||||
// original template.
|
||||
|
||||
@@ -9484,7 +9484,7 @@ TreeTransform<Derived>::RebuildTemplateName(CXXScopeSpec &SS,
|
||||
ParsedType::make(ObjectType),
|
||||
/*EnteringContext=*/false,
|
||||
Template);
|
||||
return Template.template getAsVal<TemplateName>();
|
||||
return Template.get();
|
||||
}
|
||||
|
||||
template<typename Derived>
|
||||
|
||||
Reference in New Issue
Block a user