diff options
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 8 | ||||
-rw-r--r-- | clang/lib/Sema/SemaCodeComplete.cpp | 10 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 19 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 13 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExceptionSpec.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Sema/SemaObjCProperty.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaOpenMP.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 26 | ||||
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiate.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Sema/SemaType.cpp | 4 |
14 files changed, 50 insertions, 55 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 8f6fa10dd8f..568ba98020e 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -10985,9 +10985,9 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr, const NamedDecl *ND = nullptr; if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(BaseExpr)) - ND = dyn_cast<NamedDecl>(DRE->getDecl()); + ND = DRE->getDecl(); if (const MemberExpr *ME = dyn_cast<MemberExpr>(BaseExpr)) - ND = dyn_cast<NamedDecl>(ME->getMemberDecl()); + ND = ME->getMemberDecl(); if (index.isUnsigned() || !index.isNegative()) { llvm::APInt size = ArrayTy->getSize(); @@ -11070,9 +11070,9 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr, dyn_cast<ArraySubscriptExpr>(BaseExpr)) BaseExpr = ASE->getBase()->IgnoreParenCasts(); if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(BaseExpr)) - ND = dyn_cast<NamedDecl>(DRE->getDecl()); + ND = DRE->getDecl(); if (const MemberExpr *ME = dyn_cast<MemberExpr>(BaseExpr)) - ND = dyn_cast<NamedDecl>(ME->getMemberDecl()); + ND = ME->getMemberDecl(); } if (ND) diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index 8fffa465ec9..6d4e583868b 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -675,7 +675,7 @@ SimplifiedTypeClass clang::getSimplifiedTypeClass(CanQualType T) { /// \brief Get the type that a given expression will have if this declaration /// is used as an expression in its "typical" code-completion form. QualType clang::getDeclUsageType(ASTContext &C, const NamedDecl *ND) { - ND = cast<NamedDecl>(ND->getUnderlyingDecl()); + ND = ND->getUnderlyingDecl(); if (const TypeDecl *Type = dyn_cast<TypeDecl>(ND)) return C.getTypeDeclType(Type); @@ -1074,7 +1074,7 @@ void ResultBuilder::ExitScope() { /// \brief Determines whether this given declaration will be found by /// ordinary name lookup. bool ResultBuilder::IsOrdinaryName(const NamedDecl *ND) const { - ND = cast<NamedDecl>(ND->getUnderlyingDecl()); + ND = ND->getUnderlyingDecl(); // If name lookup finds a local extern declaration, then we are in a // context where it behaves like an ordinary name. @@ -1092,7 +1092,7 @@ bool ResultBuilder::IsOrdinaryName(const NamedDecl *ND) const { /// \brief Determines whether this given declaration will be found by /// ordinary name lookup but is not a type name. bool ResultBuilder::IsOrdinaryNonTypeName(const NamedDecl *ND) const { - ND = cast<NamedDecl>(ND->getUnderlyingDecl()); + ND = ND->getUnderlyingDecl(); if (isa<TypeDecl>(ND)) return false; // Objective-C interfaces names are not filtered by this method because they @@ -1128,7 +1128,7 @@ bool ResultBuilder::IsIntegralConstantValue(const NamedDecl *ND) const { /// \brief Determines whether this given declaration will be found by /// ordinary name lookup. bool ResultBuilder::IsOrdinaryNonValueName(const NamedDecl *ND) const { - ND = cast<NamedDecl>(ND->getUnderlyingDecl()); + ND = ND->getUnderlyingDecl(); unsigned IDNS = Decl::IDNS_Ordinary | Decl::IDNS_LocalExtern; if (SemaRef.getLangOpts().CPlusPlus) @@ -7453,7 +7453,7 @@ void Sema::CodeCompleteObjCMethodDecl(Scope *S, Optional<bool> IsInstanceMethod, Decl *IDecl = nullptr; if (CurContext->isObjCContainer()) { ObjCContainerDecl *OCD = dyn_cast<ObjCContainerDecl>(CurContext); - IDecl = cast<Decl>(OCD); + IDecl = OCD; } // Determine where we should start searching for methods. ObjCContainerDecl *SearchDecl = nullptr; diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 111d131b480..a176964fc2f 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -1519,9 +1519,7 @@ static bool IsDisallowedCopyOrAssign(const CXXMethodDecl *D) { if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(D)) return CD->isCopyConstructor(); - if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D)) - return Method->isCopyAssignmentOperator(); - return false; + return D->isCopyAssignmentOperator(); } // We need this to handle @@ -6887,9 +6885,9 @@ NamedDecl *Sema::ActOnVariableDeclarator( } if (D.isRedeclaration() && !Previous.empty()) { - checkDLLAttributeRedeclaration( - *this, dyn_cast<NamedDecl>(Previous.getRepresentativeDecl()), NewVD, - IsMemberSpecialization, D.isFunctionDefinition()); + NamedDecl *Prev = Previous.getRepresentativeDecl(); + checkDLLAttributeRedeclaration(*this, Prev, NewVD, IsMemberSpecialization, + D.isFunctionDefinition()); } if (NewTemplate) { @@ -9039,10 +9037,11 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, NewFD->setRangeEnd(D.getSourceRange().getEnd()); if (D.isRedeclaration() && !Previous.empty()) { - checkDLLAttributeRedeclaration( - *this, dyn_cast<NamedDecl>(Previous.getRepresentativeDecl()), NewFD, - isMemberSpecialization || isFunctionTemplateSpecialization, - D.isFunctionDefinition()); + NamedDecl *Prev = Previous.getRepresentativeDecl(); + checkDLLAttributeRedeclaration(*this, Prev, NewFD, + isMemberSpecialization || + isFunctionTemplateSpecialization, + D.isFunctionDefinition()); } if (getLangOpts().CUDA) { diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index b5614cc7081..fe05692f0a5 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -113,7 +113,7 @@ static SourceRange getFunctionOrMethodParamRange(const Decl *D, unsigned Idx) { static QualType getFunctionOrMethodResultType(const Decl *D) { if (const FunctionType *FnTy = D->getFunctionType()) - return cast<FunctionType>(FnTy)->getReturnType(); + return FnTy->getReturnType(); return cast<ObjCMethodDecl>(D)->getReturnType(); } diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 76ef9af73ff..51ba96fb1e8 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -9036,7 +9036,7 @@ Decl *Sema::ActOnUsingDirective(Scope *S, // Find enclosing context containing both using-directive and // nominated namespace. - DeclContext *CommonAncestor = cast<DeclContext>(NS); + DeclContext *CommonAncestor = NS; while (CommonAncestor && !CommonAncestor->Encloses(CurContext)) CommonAncestor = CommonAncestor->getParent(); @@ -14536,7 +14536,7 @@ void Sema::MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, // Try to insert this class into the map. LoadExternalVTableUses(); - Class = cast<CXXRecordDecl>(Class->getCanonicalDecl()); + Class = Class->getCanonicalDecl(); std::pair<llvm::DenseMap<CXXRecordDecl *, bool>::iterator, bool> Pos = VTablesUsed.insert(std::make_pair(Class, DefinitionRequired)); if (!Pos.second) { @@ -14648,7 +14648,7 @@ bool Sema::DefineUsedVTables() { // vtable for this class is required. DefinedAnything = true; MarkVirtualMembersReferenced(Loc, Class); - CXXRecordDecl *Canonical = cast<CXXRecordDecl>(Class->getCanonicalDecl()); + CXXRecordDecl *Canonical = Class->getCanonicalDecl(); if (VTablesUsed[Canonical]) Consumer.HandleVTable(Class); diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index cab6a50629d..748285b73e8 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -3865,9 +3865,9 @@ Decl *Sema::ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef<Decl *> allMethods, assert(AtEnd.isValid() && "Invalid location for '@end'"); - ObjCContainerDecl *OCD = dyn_cast<ObjCContainerDecl>(CurContext); - Decl *ClassDecl = cast<Decl>(OCD); - + auto *OCD = cast<ObjCContainerDecl>(CurContext); + Decl *ClassDecl = OCD; + bool isInterfaceDeclKind = isa<ObjCInterfaceDecl>(ClassDecl) || isa<ObjCCategoryDecl>(ClassDecl) || isa<ObjCProtocolDecl>(ClassDecl); @@ -4521,8 +4521,7 @@ Decl *Sema::ActOnMethodDeclaration( Diag(MethodLoc, diag::err_missing_method_context); return nullptr; } - ObjCContainerDecl *OCD = dyn_cast<ObjCContainerDecl>(CurContext); - Decl *ClassDecl = cast<Decl>(OCD); + Decl *ClassDecl = cast<ObjCContainerDecl>(CurContext); QualType resultDeclType; bool HasRelatedResultType = false; @@ -4771,7 +4770,7 @@ void Sema::ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart, Context.DeepCollectObjCIvars(Class, true, Ivars); // For each ivar, create a fresh ObjCAtDefsFieldDecl. for (unsigned i = 0; i < Ivars.size(); i++) { - const FieldDecl* ID = cast<FieldDecl>(Ivars[i]); + const FieldDecl* ID = Ivars[i]; RecordDecl *Record = dyn_cast<RecordDecl>(TagD); Decl *FD = ObjCAtDefsFieldDecl::Create(Context, Record, /*FIXME: StartL=*/ID->getLocation(), @@ -4786,7 +4785,7 @@ void Sema::ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart, D != Decls.end(); ++D) { FieldDecl *FD = cast<FieldDecl>(*D); if (getLangOpts().CPlusPlus) - PushOnScopeChains(cast<FieldDecl>(FD), S); + PushOnScopeChains(FD, S); else if (RecordDecl *Record = dyn_cast<RecordDecl>(TagD)) Record->addDecl(FD); } diff --git a/clang/lib/Sema/SemaExceptionSpec.cpp b/clang/lib/Sema/SemaExceptionSpec.cpp index ebe93750a79..21ca08f360a 100644 --- a/clang/lib/Sema/SemaExceptionSpec.cpp +++ b/clang/lib/Sema/SemaExceptionSpec.cpp @@ -203,8 +203,8 @@ Sema::UpdateExceptionSpec(FunctionDecl *FD, if (auto *Listener = getASTMutationListener()) Listener->ResolvedExceptionSpec(FD); - for (auto *Redecl : FD->redecls()) - Context.adjustExceptionSpec(cast<FunctionDecl>(Redecl), ESI); + for (FunctionDecl *Redecl : FD->redecls()) + Context.adjustExceptionSpec(Redecl, ESI); } static bool CheckEquivalentExceptionSpecImpl( diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index d885a8420d5..d3ab003a339 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -7341,8 +7341,7 @@ class TransformTypos : public TreeTransform<TransformTypos> { /// suggest the corrections. Otherwise the diagnostics will not suggest /// anything (having been passed an empty TypoCorrection). void EmitAllDiagnostics() { - for (auto E : TypoExprs) { - TypoExpr *TE = cast<TypoExpr>(E); + for (TypoExpr *TE : TypoExprs) { auto &State = SemaRef.getTypoExprState(TE); if (State.DiagHandler) { TypoCorrection TC = State.Consumer->getCurrentCorrection(); diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp index ea5b1da46f3..3b8ad3d7e11 100644 --- a/clang/lib/Sema/SemaObjCProperty.cpp +++ b/clang/lib/Sema/SemaObjCProperty.cpp @@ -618,7 +618,7 @@ ObjCPropertyDecl *Sema::CreatePropertyDecl(Scope *S, TInfo = Context.getTrivialTypeSourceInfo(T, TLoc); } - DeclContext *DC = cast<DeclContext>(CDecl); + DeclContext *DC = CDecl; ObjCPropertyDecl *PDecl = ObjCPropertyDecl::Create(Context, DC, FD.D.getIdentifierLoc(), PropertyId, AtLoc, diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 86b6091ae0e..b8f4f2b6613 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -1591,7 +1591,7 @@ ExprResult Sema::ActOnOpenMPIdExpression(Scope *CurScope, } VarDecl *CanonicalVD = VD->getCanonicalDecl(); - NamedDecl *ND = cast<NamedDecl>(CanonicalVD); + NamedDecl *ND = CanonicalVD; // OpenMP [2.9.2, Restrictions, C/C++, p.2] // A threadprivate directive for file-scope variables must appear outside // any definition or declaration. diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 8dbae9cdcea..2e8a7061d71 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -3526,7 +3526,7 @@ noteNonDeducibleParameters(Sema &S, TemplateParameterList *TemplateParams, const llvm::SmallBitVector &DeducibleParams) { for (unsigned I = 0, N = DeducibleParams.size(); I != N; ++I) { if (!DeducibleParams[I]) { - NamedDecl *Param = cast<NamedDecl>(TemplateParams->getParam(I)); + NamedDecl *Param = TemplateParams->getParam(I); if (Param->getDeclName()) S.Diag(Param->getLocation(), diag::note_non_deducible_parameter) << Param->getDeclName(); @@ -5934,17 +5934,16 @@ static bool CheckTemplateArgumentPointerToMember(Sema &S, } // A constant of pointer-to-member type. else if ((DRE = dyn_cast<DeclRefExpr>(Arg))) { - if (ValueDecl *VD = dyn_cast<ValueDecl>(DRE->getDecl())) { - if (VD->getType()->isMemberPointerType()) { - if (isa<NonTypeTemplateParmDecl>(VD)) { - if (Arg->isTypeDependent() || Arg->isValueDependent()) { - Converted = TemplateArgument(Arg); - } else { - VD = cast<ValueDecl>(VD->getCanonicalDecl()); - Converted = TemplateArgument(VD, ParamType); - } - return Invalid; + ValueDecl *VD = DRE->getDecl(); + if (VD->getType()->isMemberPointerType()) { + if (isa<NonTypeTemplateParmDecl>(VD)) { + if (Arg->isTypeDependent() || Arg->isValueDependent()) { + Converted = TemplateArgument(Arg); + } else { + VD = cast<ValueDecl>(VD->getCanonicalDecl()); + Converted = TemplateArgument(VD, ParamType); } + return Invalid; } } @@ -6635,7 +6634,7 @@ Sema::BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, assert(Arg.getKind() == TemplateArgument::Declaration && "Only declaration template arguments permitted here"); - ValueDecl *VD = cast<ValueDecl>(Arg.getAsDecl()); + ValueDecl *VD = Arg.getAsDecl(); if (VD->getDeclContext()->isRecord() && (isa<CXXMethodDecl>(VD) || isa<FieldDecl>(VD) || @@ -9529,8 +9528,7 @@ static bool isEnableIf(NestedNameSpecifierLoc NNS, const IdentifierInfo &II, EnableIfTy.getAs<TemplateSpecializationTypeLoc>(); if (!EnableIfTSTLoc || EnableIfTSTLoc.getNumArgs() == 0) return false; - const TemplateSpecializationType *EnableIfTST = - cast<TemplateSpecializationType>(EnableIfTSTLoc.getTypePtr()); + const TemplateSpecializationType *EnableIfTST = EnableIfTSTLoc.getTypePtr(); // ... which names a complete class template declaration... const TemplateDecl *EnableIfDecl = diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 2c4f6490789..bcc1e66fb0c 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -1261,7 +1261,7 @@ ExprResult TemplateInstantiator::transformNonTypeTemplateParmRef( arg.getKind() == TemplateArgument::NullPtr) { ValueDecl *VD; if (arg.getKind() == TemplateArgument::Declaration) { - VD = cast<ValueDecl>(arg.getAsDecl()); + VD = arg.getAsDecl(); // Find the instantiation of the template argument. This is // required for nested templates. diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 1ccd0c84c42..d87f9dbbbea 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -2688,9 +2688,9 @@ Decl *TemplateDeclInstantiator::VisitUnresolvedUsingValueDecl( Decl *TemplateDeclInstantiator::VisitUsingPackDecl(UsingPackDecl *D) { SmallVector<NamedDecl*, 8> Expansions; for (auto *UD : D->expansions()) { - if (auto *NewUD = + if (NamedDecl *NewUD = SemaRef.FindInstantiatedDecl(D->getLocation(), UD, TemplateArgs)) - Expansions.push_back(cast<NamedDecl>(NewUD)); + Expansions.push_back(NewUD); else return nullptr; } diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 72ade3b1c1e..9791003f656 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -7877,8 +7877,8 @@ static QualType getDecltypeForExpr(Sema &S, Expr *E) { // // We apply the same rules for Objective-C ivar and property references. if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) { - if (const ValueDecl *VD = dyn_cast<ValueDecl>(DRE->getDecl())) - return VD->getType(); + const ValueDecl *VD = DRE->getDecl(); + return VD->getType(); } else if (const MemberExpr *ME = dyn_cast<MemberExpr>(E)) { if (const ValueDecl *VD = ME->getMemberDecl()) if (isa<FieldDecl>(VD) || isa<VarDecl>(VD)) |