@@ -91,9 +91,6 @@ class RemoveNamespaceRewriteVisitor : public
91
91
bool VisitTemplateSpecializationTypeLoc (
92
92
TemplateSpecializationTypeLoc TSPLoc);
93
93
94
- bool VisitClassTemplatePartialSpecializationDecl (
95
- ClassTemplatePartialSpecializationDecl *D);
96
-
97
94
bool VisitDependentTemplateSpecializationTypeLoc (
98
95
DependentTemplateSpecializationTypeLoc DTSLoc);
99
96
@@ -132,14 +129,25 @@ bool RemoveNamespaceASTVisitor::VisitNamespaceDecl(NamespaceDecl *ND)
132
129
bool RemoveNamespaceRewriteVisitor::VisitClassTemplateSpecializationDecl (
133
130
ClassTemplateSpecializationDecl *TSD)
134
131
{
135
- if (!TSD->isExplicitSpecialization () || !TSD-> isCompleteDefinition ())
132
+ if (!TSD->isExplicitInstantiationOrSpecialization ())
136
133
return true ;
137
134
138
- for (CXXRecordDecl::base_class_const_iterator I = TSD->bases_begin (),
139
- E = TSD->bases_end (); I != E; ++I) {
140
- TypeSourceInfo *TSI = (*I).getTypeSourceInfo ();
141
- TransAssert (TSI && " Bad TypeSourceInfo!" );
142
- TraverseTypeLoc (TSI->getTypeLoc ());
135
+ const CXXRecordDecl *CXXRD = TSD->getSpecializedTemplate ()->getTemplatedDecl ();
136
+ std::string Name;
137
+ if (ConsumerInstance->getNewName (CXXRD, Name)) {
138
+ SourceLocation LocStart = TSD->getLocation ();
139
+ TransAssert (LocStart.isValid () && " Invalid Location!" );
140
+ ConsumerInstance->TheRewriter .ReplaceText (
141
+ LocStart, CXXRD->getNameAsString ().size (), Name);
142
+ }
143
+
144
+ if (TSD->isExplicitSpecialization () && TSD->isCompleteDefinition ()) {
145
+ for (CXXRecordDecl::base_class_const_iterator I = TSD->bases_begin (),
146
+ E = TSD->bases_end (); I != E; ++I) {
147
+ TypeSourceInfo *TSI = (*I).getTypeSourceInfo ();
148
+ TransAssert (TSI && " Bad TypeSourceInfo!" );
149
+ TraverseTypeLoc (TSI->getTypeLoc ());
150
+ }
143
151
}
144
152
return true ;
145
153
}
@@ -419,34 +427,6 @@ bool RemoveNamespaceRewriteVisitor::VisitTemplateSpecializationTypeLoc(
419
427
return true ;
420
428
}
421
429
422
- bool RemoveNamespaceRewriteVisitor::VisitClassTemplatePartialSpecializationDecl (
423
- ClassTemplatePartialSpecializationDecl *D)
424
- {
425
- const Type *Ty = D->getInjectedSpecializationType ().getTypePtr ();
426
- TransAssert (Ty && " Bad TypePtr!" );
427
- const TemplateSpecializationType *TST =
428
- dyn_cast<TemplateSpecializationType>(Ty);
429
- TransAssert (TST && " Bad TemplateSpecializationType!" );
430
-
431
- TemplateName TplName = TST->getTemplateName ();
432
- const TemplateDecl *TplD = TplName.getAsTemplateDecl ();
433
- TransAssert (TplD && " Invalid TemplateDecl!" );
434
- NamedDecl *ND = TplD->getTemplatedDecl ();
435
- TransAssert (ND && " Invalid NamedDecl!" );
436
-
437
- const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(ND);
438
- TransAssert (CXXRD && " Invalid CXXRecordDecl!" );
439
-
440
- std::string Name;
441
- if (ConsumerInstance->getNewName (CXXRD, Name)) {
442
- SourceLocation LocStart = D->getLocation ();
443
- TransAssert (LocStart.isValid () && " Invalid Location!" );
444
- ConsumerInstance->TheRewriter .ReplaceText (
445
- LocStart, CXXRD->getNameAsString ().size (), Name);
446
- }
447
- return true ;
448
- }
449
-
450
430
// handle the case where a template specialization type cannot be resolved, e.g.
451
431
// template <class T> struct Base {};
452
432
// template <class T> struct Derived: public Base<T> {
0 commit comments