From cc8990f6294f065d3006614337f3e9e9b9fc464d Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Fri, 16 Nov 2012 08:40:59 +0000 Subject: [PATCH] Store this Decl* as a Decl* instead of a uintptr_t. No functionality change. llvm-svn: 168145 --- clang/include/clang/Sema/Sema.h | 2 +- clang/lib/Sema/SemaTemplateInstantiate.cpp | 40 ++++++++++++-------------- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 4 +-- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 16de280..a67e630 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -5550,7 +5550,7 @@ public: NamedDecl *Template; /// \brief The entity that is being instantiated. - uintptr_t Entity; + Decl *Entity; /// \brief The list of template arguments we are substituting, if they /// are not part of the entity. diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 665dd07..426a74f 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -182,7 +182,7 @@ InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, ActiveTemplateInstantiation Inst; Inst.Kind = ActiveTemplateInstantiation::TemplateInstantiation; Inst.PointOfInstantiation = PointOfInstantiation; - Inst.Entity = reinterpret_cast(Entity); + Inst.Entity = Entity; Inst.TemplateArgs = 0; Inst.NumTemplateArgs = 0; Inst.InstantiationRange = InstantiationRange; @@ -205,7 +205,7 @@ InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, ActiveTemplateInstantiation Inst; Inst.Kind = ActiveTemplateInstantiation::ExceptionSpecInstantiation; Inst.PointOfInstantiation = PointOfInstantiation; - Inst.Entity = reinterpret_cast(Entity); + Inst.Entity = Entity; Inst.TemplateArgs = 0; Inst.NumTemplateArgs = 0; Inst.InstantiationRange = InstantiationRange; @@ -230,7 +230,7 @@ InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, Inst.Kind = ActiveTemplateInstantiation::DefaultTemplateArgumentInstantiation; Inst.PointOfInstantiation = PointOfInstantiation; - Inst.Entity = reinterpret_cast(Template); + Inst.Entity = Template; Inst.TemplateArgs = TemplateArgs.data(); Inst.NumTemplateArgs = TemplateArgs.size(); Inst.InstantiationRange = InstantiationRange; @@ -255,7 +255,7 @@ InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, ActiveTemplateInstantiation Inst; Inst.Kind = Kind; Inst.PointOfInstantiation = PointOfInstantiation; - Inst.Entity = reinterpret_cast(FunctionTemplate); + Inst.Entity = FunctionTemplate; Inst.TemplateArgs = TemplateArgs.data(); Inst.NumTemplateArgs = TemplateArgs.size(); Inst.DeductionInfo = &DeductionInfo; @@ -283,7 +283,7 @@ InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, ActiveTemplateInstantiation Inst; Inst.Kind = ActiveTemplateInstantiation::DeducedTemplateArgumentSubstitution; Inst.PointOfInstantiation = PointOfInstantiation; - Inst.Entity = reinterpret_cast(PartialSpec); + Inst.Entity = PartialSpec; Inst.TemplateArgs = TemplateArgs.data(); Inst.NumTemplateArgs = TemplateArgs.size(); Inst.DeductionInfo = &DeductionInfo; @@ -308,7 +308,7 @@ InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, Inst.Kind = ActiveTemplateInstantiation::DefaultFunctionArgumentInstantiation; Inst.PointOfInstantiation = PointOfInstantiation; - Inst.Entity = reinterpret_cast(Param); + Inst.Entity = Param; Inst.TemplateArgs = TemplateArgs.data(); Inst.NumTemplateArgs = TemplateArgs.size(); Inst.InstantiationRange = InstantiationRange; @@ -332,7 +332,7 @@ InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, Inst.Kind = ActiveTemplateInstantiation::PriorTemplateArgumentSubstitution; Inst.PointOfInstantiation = PointOfInstantiation; Inst.Template = Template; - Inst.Entity = reinterpret_cast(Param); + Inst.Entity = Param; Inst.TemplateArgs = TemplateArgs.data(); Inst.NumTemplateArgs = TemplateArgs.size(); Inst.InstantiationRange = InstantiationRange; @@ -356,7 +356,7 @@ InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, Inst.Kind = ActiveTemplateInstantiation::PriorTemplateArgumentSubstitution; Inst.PointOfInstantiation = PointOfInstantiation; Inst.Template = Template; - Inst.Entity = reinterpret_cast(Param); + Inst.Entity = Param; Inst.TemplateArgs = TemplateArgs.data(); Inst.NumTemplateArgs = TemplateArgs.size(); Inst.InstantiationRange = InstantiationRange; @@ -380,7 +380,7 @@ InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, Inst.Kind = ActiveTemplateInstantiation::DefaultTemplateArgumentChecking; Inst.PointOfInstantiation = PointOfInstantiation; Inst.Template = Template; - Inst.Entity = reinterpret_cast(Param); + Inst.Entity = Param; Inst.TemplateArgs = TemplateArgs.data(); Inst.NumTemplateArgs = TemplateArgs.size(); Inst.InstantiationRange = InstantiationRange; @@ -454,7 +454,7 @@ void Sema::PrintInstantiationStack() { switch (Active->Kind) { case ActiveTemplateInstantiation::TemplateInstantiation: { - Decl *D = reinterpret_cast(Active->Entity); + Decl *D = Active->Entity; if (CXXRecordDecl *Record = dyn_cast(D)) { unsigned DiagID = diag::note_template_member_class_here; if (isa(Record)) @@ -491,7 +491,7 @@ void Sema::PrintInstantiationStack() { } case ActiveTemplateInstantiation::DefaultTemplateArgumentInstantiation: { - TemplateDecl *Template = cast((Decl *)Active->Entity); + TemplateDecl *Template = cast(Active->Entity); std::string TemplateArgsStr = TemplateSpecializationType::PrintTemplateArgumentList( Active->TemplateArgs, @@ -505,8 +505,7 @@ void Sema::PrintInstantiationStack() { } case ActiveTemplateInstantiation::ExplicitTemplateArgumentSubstitution: { - FunctionTemplateDecl *FnTmpl - = cast((Decl *)Active->Entity); + FunctionTemplateDecl *FnTmpl = cast(Active->Entity); Diags.Report(Active->PointOfInstantiation, diag::note_explicit_template_arg_substitution_here) << FnTmpl @@ -518,9 +517,8 @@ void Sema::PrintInstantiationStack() { } case ActiveTemplateInstantiation::DeducedTemplateArgumentSubstitution: - if (ClassTemplatePartialSpecializationDecl *PartialSpec - = dyn_cast( - (Decl *)Active->Entity)) { + if (ClassTemplatePartialSpecializationDecl *PartialSpec = + dyn_cast(Active->Entity)) { Diags.Report(Active->PointOfInstantiation, diag::note_partial_spec_deduct_instantiation_here) << Context.getTypeDeclType(PartialSpec) @@ -531,7 +529,7 @@ void Sema::PrintInstantiationStack() { << Active->InstantiationRange; } else { FunctionTemplateDecl *FnTmpl - = cast((Decl *)Active->Entity); + = cast(Active->Entity); Diags.Report(Active->PointOfInstantiation, diag::note_function_template_deduction_instantiation_here) << FnTmpl @@ -543,7 +541,7 @@ void Sema::PrintInstantiationStack() { break; case ActiveTemplateInstantiation::DefaultFunctionArgumentInstantiation: { - ParmVarDecl *Param = cast((Decl *)Active->Entity); + ParmVarDecl *Param = cast(Active->Entity); FunctionDecl *FD = cast(Param->getDeclContext()); std::string TemplateArgsStr @@ -559,7 +557,7 @@ void Sema::PrintInstantiationStack() { } case ActiveTemplateInstantiation::PriorTemplateArgumentSubstitution: { - NamedDecl *Parm = cast((Decl *)Active->Entity); + NamedDecl *Parm = cast(Active->Entity); std::string Name; if (!Parm->getName().empty()) Name = std::string(" '") + Parm->getName().str() + "'"; @@ -603,7 +601,7 @@ void Sema::PrintInstantiationStack() { case ActiveTemplateInstantiation::ExceptionSpecInstantiation: Diags.Report(Active->PointOfInstantiation, diag::note_template_exception_spec_instantiation_here) - << cast((Decl *)Active->Entity) + << cast(Active->Entity) << Active->InstantiationRange; break; } @@ -624,7 +622,7 @@ llvm::Optional Sema::isSFINAEContext() const { case ActiveTemplateInstantiation::TemplateInstantiation: // An instantiation of an alias template may or may not be a SFINAE // context, depending on what else is on the stack. - if (isa(reinterpret_cast(Active->Entity))) + if (isa(Active->Entity)) break; // Fall through. case ActiveTemplateInstantiation::DefaultFunctionArgumentInstantiation: diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 0267192..46464a1 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -2605,12 +2605,12 @@ TemplateDeclInstantiator::InitFunctionInstantiation(FunctionDecl *New, if (ActiveInst.Kind == ActiveInstType::ExplicitTemplateArgumentSubstitution || ActiveInst.Kind == ActiveInstType::DeducedTemplateArgumentSubstitution) { if (FunctionTemplateDecl *FunTmpl - = dyn_cast((Decl *)ActiveInst.Entity)) { + = dyn_cast(ActiveInst.Entity)) { assert(FunTmpl->getTemplatedDecl() == Tmpl && "Deduction from the wrong function template?"); (void) FunTmpl; ActiveInst.Kind = ActiveInstType::TemplateInstantiation; - ActiveInst.Entity = reinterpret_cast(New); + ActiveInst.Entity = New; } } -- 2.7.4