Simplify template instantiation for C++ exception declarations,
eliminating an unnecessary use of TemporaryBase in the process. llvm-svn: 113500
This commit is contained in:
parent
a08318acb2
commit
9f0e1aa0f2
|
@ -1609,11 +1609,10 @@ public:
|
||||||
Expr *SynchExpr,
|
Expr *SynchExpr,
|
||||||
Stmt *SynchBody);
|
Stmt *SynchBody);
|
||||||
|
|
||||||
VarDecl *BuildExceptionDeclaration(Scope *S, QualType ExDeclType,
|
VarDecl *BuildExceptionDeclaration(Scope *S,
|
||||||
TypeSourceInfo *TInfo,
|
TypeSourceInfo *TInfo,
|
||||||
IdentifierInfo *Name,
|
IdentifierInfo *Name,
|
||||||
SourceLocation Loc,
|
SourceLocation Loc);
|
||||||
SourceRange Range);
|
|
||||||
Decl *ActOnExceptionDeclarator(Scope *S, Declarator &D);
|
Decl *ActOnExceptionDeclarator(Scope *S, Declarator &D);
|
||||||
|
|
||||||
StmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc,
|
StmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc,
|
||||||
|
|
|
@ -6077,12 +6077,12 @@ Decl *Sema::ActOnFinishLinkageSpecification(Scope *S,
|
||||||
/// \brief Perform semantic analysis for the variable declaration that
|
/// \brief Perform semantic analysis for the variable declaration that
|
||||||
/// occurs within a C++ catch clause, returning the newly-created
|
/// occurs within a C++ catch clause, returning the newly-created
|
||||||
/// variable.
|
/// variable.
|
||||||
VarDecl *Sema::BuildExceptionDeclaration(Scope *S, QualType ExDeclType,
|
VarDecl *Sema::BuildExceptionDeclaration(Scope *S,
|
||||||
TypeSourceInfo *TInfo,
|
TypeSourceInfo *TInfo,
|
||||||
IdentifierInfo *Name,
|
IdentifierInfo *Name,
|
||||||
SourceLocation Loc,
|
SourceLocation Loc) {
|
||||||
SourceRange Range) {
|
|
||||||
bool Invalid = false;
|
bool Invalid = false;
|
||||||
|
QualType ExDeclType = TInfo->getType();
|
||||||
|
|
||||||
// Arrays and functions decay.
|
// Arrays and functions decay.
|
||||||
if (ExDeclType->isArrayType())
|
if (ExDeclType->isArrayType())
|
||||||
|
@ -6095,7 +6095,7 @@ VarDecl *Sema::BuildExceptionDeclaration(Scope *S, QualType ExDeclType,
|
||||||
// incomplete type, other than [cv] void*.
|
// incomplete type, other than [cv] void*.
|
||||||
// N2844 forbids rvalue references.
|
// N2844 forbids rvalue references.
|
||||||
if (!ExDeclType->isDependentType() && ExDeclType->isRValueReferenceType()) {
|
if (!ExDeclType->isDependentType() && ExDeclType->isRValueReferenceType()) {
|
||||||
Diag(Loc, diag::err_catch_rvalue_ref) << Range;
|
Diag(Loc, diag::err_catch_rvalue_ref);
|
||||||
Invalid = true;
|
Invalid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6213,10 +6213,9 @@ Decl *Sema::ActOnExceptionDeclarator(Scope *S, Declarator &D) {
|
||||||
Invalid = true;
|
Invalid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
VarDecl *ExDecl = BuildExceptionDeclaration(S, ExDeclType, TInfo,
|
VarDecl *ExDecl = BuildExceptionDeclaration(S, TInfo,
|
||||||
D.getIdentifier(),
|
D.getIdentifier(),
|
||||||
D.getIdentifierLoc(),
|
D.getIdentifierLoc());
|
||||||
D.getDeclSpec().getSourceRange());
|
|
||||||
|
|
||||||
if (Invalid)
|
if (Invalid)
|
||||||
ExDecl->setInvalidDecl();
|
ExDecl->setInvalidDecl();
|
||||||
|
|
|
@ -602,10 +602,10 @@ namespace {
|
||||||
|
|
||||||
/// \brief Rebuild the exception declaration and register the declaration
|
/// \brief Rebuild the exception declaration and register the declaration
|
||||||
/// as an instantiated local.
|
/// as an instantiated local.
|
||||||
VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl, QualType T,
|
VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl,
|
||||||
TypeSourceInfo *Declarator,
|
TypeSourceInfo *Declarator,
|
||||||
IdentifierInfo *Name,
|
IdentifierInfo *Name,
|
||||||
SourceLocation Loc, SourceRange TypeRange);
|
SourceLocation Loc);
|
||||||
|
|
||||||
/// \brief Rebuild the Objective-C exception declaration and register the
|
/// \brief Rebuild the Objective-C exception declaration and register the
|
||||||
/// declaration as an instantiated local.
|
/// declaration as an instantiated local.
|
||||||
|
@ -719,13 +719,11 @@ TemplateInstantiator::TransformFirstQualifierInScope(NamedDecl *D,
|
||||||
|
|
||||||
VarDecl *
|
VarDecl *
|
||||||
TemplateInstantiator::RebuildExceptionDecl(VarDecl *ExceptionDecl,
|
TemplateInstantiator::RebuildExceptionDecl(VarDecl *ExceptionDecl,
|
||||||
QualType T,
|
|
||||||
TypeSourceInfo *Declarator,
|
TypeSourceInfo *Declarator,
|
||||||
IdentifierInfo *Name,
|
IdentifierInfo *Name,
|
||||||
SourceLocation Loc,
|
SourceLocation Loc) {
|
||||||
SourceRange TypeRange) {
|
VarDecl *Var = inherited::RebuildExceptionDecl(ExceptionDecl, Declarator,
|
||||||
VarDecl *Var = inherited::RebuildExceptionDecl(ExceptionDecl, T, Declarator,
|
Name, Loc);
|
||||||
Name, Loc, TypeRange);
|
|
||||||
if (Var)
|
if (Var)
|
||||||
getSema().CurrentInstantiationScope->InstantiatedLocal(ExceptionDecl, Var);
|
getSema().CurrentInstantiationScope->InstantiatedLocal(ExceptionDecl, Var);
|
||||||
return Var;
|
return Var;
|
||||||
|
|
|
@ -980,13 +980,11 @@ public:
|
||||||
///
|
///
|
||||||
/// By default, performs semantic analysis to build the new decaration.
|
/// By default, performs semantic analysis to build the new decaration.
|
||||||
/// Subclasses may override this routine to provide different behavior.
|
/// Subclasses may override this routine to provide different behavior.
|
||||||
VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl, QualType T,
|
VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl,
|
||||||
TypeSourceInfo *Declarator,
|
TypeSourceInfo *Declarator,
|
||||||
IdentifierInfo *Name,
|
IdentifierInfo *Name,
|
||||||
SourceLocation Loc,
|
SourceLocation Loc) {
|
||||||
SourceRange TypeRange) {
|
return getSema().BuildExceptionDeclaration(0, Declarator, Name, Loc);
|
||||||
return getSema().BuildExceptionDeclaration(0, T, Declarator, Name, Loc,
|
|
||||||
TypeRange);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Build a new C++ catch statement.
|
/// \brief Build a new C++ catch statement.
|
||||||
|
@ -4127,20 +4125,14 @@ TreeTransform<Derived>::TransformCXXCatchStmt(CXXCatchStmt *S) {
|
||||||
VarDecl *Var = 0;
|
VarDecl *Var = 0;
|
||||||
if (S->getExceptionDecl()) {
|
if (S->getExceptionDecl()) {
|
||||||
VarDecl *ExceptionDecl = S->getExceptionDecl();
|
VarDecl *ExceptionDecl = S->getExceptionDecl();
|
||||||
TemporaryBase Rebase(*this, ExceptionDecl->getLocation(),
|
TypeSourceInfo *T = getDerived().TransformType(
|
||||||
ExceptionDecl->getDeclName());
|
ExceptionDecl->getTypeSourceInfo());
|
||||||
|
if (!T)
|
||||||
QualType T = getDerived().TransformType(ExceptionDecl->getType());
|
|
||||||
if (T.isNull())
|
|
||||||
return StmtError();
|
return StmtError();
|
||||||
|
|
||||||
Var = getDerived().RebuildExceptionDecl(ExceptionDecl,
|
Var = getDerived().RebuildExceptionDecl(ExceptionDecl, T,
|
||||||
T,
|
|
||||||
ExceptionDecl->getTypeSourceInfo(),
|
|
||||||
ExceptionDecl->getIdentifier(),
|
ExceptionDecl->getIdentifier(),
|
||||||
ExceptionDecl->getLocation(),
|
ExceptionDecl->getLocation());
|
||||||
/*FIXME: Inaccurate*/
|
|
||||||
SourceRange(ExceptionDecl->getLocation()));
|
|
||||||
if (!Var || Var->isInvalidDecl())
|
if (!Var || Var->isInvalidDecl())
|
||||||
return StmtError();
|
return StmtError();
|
||||||
}
|
}
|
||||||
|
|
|
@ -312,8 +312,6 @@ public:
|
||||||
bool VisitObjCImplDecl(ObjCImplDecl *D);
|
bool VisitObjCImplDecl(ObjCImplDecl *D);
|
||||||
bool VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D);
|
bool VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D);
|
||||||
bool VisitObjCImplementationDecl(ObjCImplementationDecl *D);
|
bool VisitObjCImplementationDecl(ObjCImplementationDecl *D);
|
||||||
// FIXME: ObjCPropertyDecl requires TypeSourceInfo, getter/setter locations,
|
|
||||||
// etc.
|
|
||||||
// FIXME: ObjCCompatibleAliasDecl requires aliased-class locations.
|
// FIXME: ObjCCompatibleAliasDecl requires aliased-class locations.
|
||||||
bool VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D);
|
bool VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D);
|
||||||
bool VisitObjCClassDecl(ObjCClassDecl *D);
|
bool VisitObjCClassDecl(ObjCClassDecl *D);
|
||||||
|
@ -846,7 +844,7 @@ bool CursorVisitor::VisitObjCProtocolDecl(ObjCProtocolDecl *PID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CursorVisitor::VisitObjCPropertyDecl(ObjCPropertyDecl *PD) {
|
bool CursorVisitor::VisitObjCPropertyDecl(ObjCPropertyDecl *PD) {
|
||||||
if (Visit(PD->getTypeSourceInfo()->getTypeLoc()))
|
if (PD->getTypeSourceInfo() && Visit(PD->getTypeSourceInfo()->getTypeLoc()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// FIXME: This implements a workaround with @property declarations also being
|
// FIXME: This implements a workaround with @property declarations also being
|
||||||
|
|
Loading…
Reference in New Issue