@@ -2162,34 +2162,46 @@ static PrimitiveType WalkBuiltinType(const clang::BuiltinType* Builtin)
2162
2162
2163
2163
// -----------------------------------//
2164
2164
2165
- clang::TypeLoc ResolveTypeLoc (clang::TypeLoc TL, clang::TypeLoc::TypeLocClass Class )
2165
+ clang::TypeLoc ResolveTypeLoc (clang::TypeLoc TL, bool isRecursive = true , const std::vector< clang::TypeLoc::TypeLocClass>& Classes = {} )
2166
2166
{
2167
2167
using namespace clang ;
2168
2168
2169
2169
auto TypeLocClass = TL.getTypeLocClass ();
2170
2170
2171
- if (TypeLocClass == Class )
2171
+ if (std::find (Classes. begin (), Classes. end (), TypeLocClass) != Classes. end () )
2172
2172
{
2173
2173
return TL;
2174
2174
}
2175
- if (TypeLocClass == TypeLoc::Qualified)
2175
+ else if (TypeLocClass == TypeLoc::Qualified)
2176
2176
{
2177
2177
auto UTL = TL.getUnqualifiedLoc ();
2178
2178
TL = UTL;
2179
+ if (isRecursive)
2180
+ {
2181
+ return ResolveTypeLoc (TL, isRecursive, Classes);
2182
+ }
2179
2183
}
2180
2184
else if (TypeLocClass == TypeLoc::Elaborated)
2181
2185
{
2182
2186
auto ETL = TL.getAs <ElaboratedTypeLoc>();
2183
2187
auto ITL = ETL.getNextTypeLoc ();
2184
2188
TL = ITL;
2189
+ if (isRecursive)
2190
+ {
2191
+ return ResolveTypeLoc (TL, isRecursive, Classes);
2192
+ }
2185
2193
}
2186
- else if (TypeLocClass == TypeLoc::Paren )
2194
+ else if (!Classes. empty () )
2187
2195
{
2188
- auto PTL = TL.getAs <ParenTypeLoc>();
2189
- TL = PTL.getNextTypeLoc ();
2196
+ auto ITL = TL.getNextTypeLoc ();
2197
+ TL = ITL;
2198
+ if (isRecursive)
2199
+ {
2200
+ return ResolveTypeLoc (TL, isRecursive, Classes);
2201
+ }
2190
2202
}
2191
2203
2192
- assert (TL.getTypeLocClass () == Class );
2204
+ assert (Classes. empty () || std::find (Classes. begin (), Classes. end (), TL.getTypeLocClass ()) != Classes. end () );
2193
2205
return TL;
2194
2206
}
2195
2207
@@ -2642,28 +2654,16 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL,
2642
2654
2643
2655
if (LocValid)
2644
2656
{
2645
- TypeLoc UTL, ETL, ITL;
2646
- auto TypeLocClass = TL->getTypeLocClass ();
2647
- if (TypeLocClass == TypeLoc::Qualified)
2648
- {
2649
- UTL = TL->getUnqualifiedLoc ();
2650
- TL = &UTL;
2651
- }
2652
- else if (TypeLocClass == TypeLoc::Elaborated)
2653
- {
2654
- ETL = TL->getAs <ElaboratedTypeLoc>();
2655
- ITL = ETL.getNextTypeLoc ();
2656
- TL = &ITL;
2657
- }
2657
+ TypeLoc resolvedTypeLoc = ResolveTypeLoc (*TL, true , { TypeLoc::TemplateSpecialization , TypeLoc::DependentTemplateSpecialization });
2658
2658
2659
- if (TL-> getTypeLocClass () == TypeLoc::DependentTemplateSpecialization)
2659
+ if (resolvedTypeLoc. getTypeLocClass () == TypeLoc::DependentTemplateSpecialization)
2660
2660
{
2661
- DependentTemplateSpecializationTypeLoc TSpecTL = TL-> getAs <DependentTemplateSpecializationTypeLoc>();
2661
+ DependentTemplateSpecializationTypeLoc TSpecTL = resolvedTypeLoc. getAs <DependentTemplateSpecializationTypeLoc>();
2662
2662
TST->Arguments = WalkTemplateArgumentList (&TArgs, &TSpecTL);
2663
2663
}
2664
- else if (TL-> getTypeLocClass () == TypeLoc::TemplateSpecialization)
2664
+ else if (resolvedTypeLoc. getTypeLocClass () == TypeLoc::TemplateSpecialization)
2665
2665
{
2666
- TemplateSpecializationTypeLoc TSpecTL = TL-> getAs <TemplateSpecializationTypeLoc>();
2666
+ TemplateSpecializationTypeLoc TSpecTL = resolvedTypeLoc. getAs <TemplateSpecializationTypeLoc>();
2667
2667
TST->Arguments = WalkTemplateArgumentList (&TArgs, &TSpecTL);
2668
2668
}
2669
2669
else
@@ -2691,28 +2691,16 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL,
2691
2691
2692
2692
if (LocValid)
2693
2693
{
2694
- TypeLoc UTL, ETL, ITL;
2695
- auto TypeLocClass = TL->getTypeLocClass ();
2696
- if (TypeLocClass == TypeLoc::Qualified)
2697
- {
2698
- UTL = TL->getUnqualifiedLoc ();
2699
- TL = &UTL;
2700
- }
2701
- else if (TypeLocClass == TypeLoc::Elaborated)
2702
- {
2703
- ETL = TL->getAs <ElaboratedTypeLoc>();
2704
- ITL = ETL.getNextTypeLoc ();
2705
- TL = &ITL;
2706
- }
2694
+ TypeLoc resolvedTypeLoc = ResolveTypeLoc (*TL, true , { TypeLoc::TemplateSpecialization , TypeLoc::DependentTemplateSpecialization });
2707
2695
2708
- if (TL-> getTypeLocClass () == TypeLoc::DependentTemplateSpecialization)
2696
+ if (resolvedTypeLoc. getTypeLocClass () == TypeLoc::DependentTemplateSpecialization)
2709
2697
{
2710
- DependentTemplateSpecializationTypeLoc TSpecTL = TL-> getAs <DependentTemplateSpecializationTypeLoc>();
2698
+ DependentTemplateSpecializationTypeLoc TSpecTL = resolvedTypeLoc. getAs <DependentTemplateSpecializationTypeLoc>();
2711
2699
TST->Arguments = WalkTemplateArgumentList (&TArgs, &TSpecTL);
2712
2700
}
2713
- else if (TL-> getTypeLocClass () == TypeLoc::TemplateSpecialization)
2701
+ else if (resolvedTypeLoc. getTypeLocClass () == TypeLoc::TemplateSpecialization)
2714
2702
{
2715
- TemplateSpecializationTypeLoc TSpecTL = TL-> getAs <TemplateSpecializationTypeLoc>();
2703
+ TemplateSpecializationTypeLoc TSpecTL = resolvedTypeLoc. getAs <TemplateSpecializationTypeLoc>();
2716
2704
TST->Arguments = WalkTemplateArgumentList (&TArgs, &TSpecTL);
2717
2705
}
2718
2706
else
@@ -2741,27 +2729,10 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL,
2741
2729
2742
2730
if (LocValid)
2743
2731
{
2744
- auto TypeLocClass = TL->getTypeLocClass ();
2745
- if (TypeLocClass == TypeLoc::Qualified)
2746
- {
2747
- UTL = TL->getUnqualifiedLoc ();
2748
- TL = &UTL;
2749
- }
2750
- else if (TypeLocClass == TypeLoc::Elaborated)
2751
- {
2752
- ETL = TL->getAs <ElaboratedTypeLoc>();
2753
- ITL = ETL.getNextTypeLoc ();
2754
- TL = &ITL;
2755
- }
2756
-
2757
- while (TL->getTypeLocClass () != TypeLoc::TemplateTypeParm)
2758
- {
2759
- Next = TL->getNextTypeLoc ();
2760
- TL = &Next;
2761
- }
2732
+ TypeLoc resolvedTypeLoc = ResolveTypeLoc (*TL, true , { TypeLoc::TemplateTypeParm });
2762
2733
2763
- assert (TL-> getTypeLocClass () == TypeLoc::TemplateTypeParm);
2764
- auto TTTL = TL-> getAs <TemplateTypeParmTypeLoc>();
2734
+ assert (resolvedTypeLoc. getTypeLocClass () == TypeLoc::TemplateTypeParm);
2735
+ auto TTTL = resolvedTypeLoc. getAs <TemplateTypeParmTypeLoc>();
2765
2736
2766
2737
TPT->parameter = WalkTypeTemplateParameter (TTTL.getDecl ());
2767
2738
}
0 commit comments