@@ -2021,7 +2021,34 @@ static PrimitiveType WalkBuiltinType(const clang::BuiltinType* Builtin)
2021
2021
2022
2022
// -----------------------------------//
2023
2023
2024
- clang::TypeLoc ResolveTypeLoc (clang::TypeLoc TL, clang::TypeLoc::TypeLocClass Class)
2024
+ #if DEBUG
2025
+ static void DumpTypeLoc (clang::TypeLoc TL, bool Recurse = false )
2026
+ {
2027
+ if (Recurse)
2028
+ puts (" " );
2029
+
2030
+ switch (TL.getTypeLocClass ())
2031
+ {
2032
+ case clang::TypeLoc::Qualified:
2033
+ printf (" Type: Qualified\n " );
2034
+ break ;
2035
+ #define ABSTRACT_TYPE (Type, Parent )
2036
+ #define TYPE (Type, Parent ) \
2037
+ case clang::TypeLoc::Type: \
2038
+ printf (" Type: %s\n " , #Type); \
2039
+ break ;
2040
+ #include " clang/AST/TypeNodes.def"
2041
+ }
2042
+
2043
+ if (!Recurse) return ;
2044
+
2045
+ clang::TypeLoc Next = TL;
2046
+ while ((Next = Next.getNextTypeLoc ()))
2047
+ DumpTypeLoc (Next);
2048
+ }
2049
+ #endif
2050
+
2051
+ static clang::TypeLoc ResolveTypeLoc (clang::TypeLoc TL, clang::TypeLoc::TypeLocClass Class)
2025
2052
{
2026
2053
using namespace clang ;
2027
2054
@@ -2047,8 +2074,12 @@ clang::TypeLoc ResolveTypeLoc(clang::TypeLoc TL, clang::TypeLoc::TypeLocClass Cl
2047
2074
auto PTL = TL.getAs <ParenTypeLoc>();
2048
2075
TL = PTL.getNextTypeLoc ();
2049
2076
}
2077
+ else
2078
+ {
2079
+ auto Next = TL.getNextTypeLoc ();
2080
+ TL = Next;
2081
+ }
2050
2082
2051
- assert (TL.getTypeLocClass () == Class);
2052
2083
return TL;
2053
2084
}
2054
2085
@@ -2325,7 +2356,7 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL,
2325
2356
A->qualifiedType = GetQualifiedType (ElemTy, &Next);
2326
2357
A->sizeType = ArrayType::ArraySize::Constant;
2327
2358
A->size = AST.getConstantArrayElementCount (AT);
2328
- if (!ElemTy-> isDependentType ( ))
2359
+ if (CanCheckCodeGenInfo (c-> getSema (), ElemTy. getTypePtr () ))
2329
2360
A->elementSize = (long )AST.getTypeSize (ElemTy);
2330
2361
2331
2362
Ty = A;
@@ -2486,17 +2517,10 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL,
2486
2517
2487
2518
if (LocValid)
2488
2519
{
2489
- auto TypeLocClass = TL->getTypeLocClass ();
2490
- if (TypeLocClass == TypeLoc::Qualified)
2520
+ while (TL->getTypeLocClass () != TypeLoc::TemplateSpecialization)
2491
2521
{
2492
- UTL = TL->getUnqualifiedLoc ();
2493
- TL = &UTL;
2494
- }
2495
- else if (TypeLocClass == TypeLoc::Elaborated)
2496
- {
2497
- ETL = TL->getAs <ElaboratedTypeLoc>();
2498
- ITL = ETL.getNextTypeLoc ();
2499
- TL = &ITL;
2522
+ auto RTL = ResolveTypeLoc (*TL, TypeLoc::TemplateSpecialization);
2523
+ TL = &RTL;
2500
2524
}
2501
2525
2502
2526
assert (TL->getTypeLocClass () == TypeLoc::TemplateSpecialization);
@@ -2529,17 +2553,10 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL,
2529
2553
2530
2554
if (LocValid)
2531
2555
{
2532
- auto TypeLocClass = TL->getTypeLocClass ();
2533
- if (TypeLocClass == TypeLoc::Qualified)
2534
- {
2535
- UTL = TL->getUnqualifiedLoc ();
2536
- TL = &UTL;
2537
- }
2538
- else if (TypeLocClass == TypeLoc::Elaborated)
2556
+ while (TL->getTypeLocClass () != TypeLoc::DependentTemplateSpecialization)
2539
2557
{
2540
- ETL = TL->getAs <ElaboratedTypeLoc>();
2541
- ITL = ETL.getNextTypeLoc ();
2542
- TL = &ITL;
2558
+ auto RTL = ResolveTypeLoc (*TL, TypeLoc::DependentTemplateSpecialization);
2559
+ TL = &RTL;
2543
2560
}
2544
2561
2545
2562
assert (TL->getTypeLocClass () == TypeLoc::DependentTemplateSpecialization);
@@ -2573,28 +2590,15 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL,
2573
2590
2574
2591
if (LocValid)
2575
2592
{
2576
- auto TypeLocClass = TL->getTypeLocClass ();
2577
- if (TypeLocClass == TypeLoc::Qualified)
2593
+ while (TL->getTypeLocClass () != TypeLoc::TemplateTypeParm)
2578
2594
{
2579
- UTL = TL->getUnqualifiedLoc ();
2580
- TL = &UTL;
2581
- }
2582
- else if (TypeLocClass == TypeLoc::Elaborated)
2583
- {
2584
- ETL = TL->getAs <ElaboratedTypeLoc>();
2585
- ITL = ETL.getNextTypeLoc ();
2586
- TL = &ITL;
2587
- }
2588
-
2589
- while (TL->getTypeLocClass () != TypeLoc::TemplateTypeParm)
2590
- {
2591
- Next = TL->getNextTypeLoc ();
2592
- TL = &Next;
2595
+ auto RTL = ResolveTypeLoc (*TL, TypeLoc::TemplateTypeParm);
2596
+ TL = &RTL;
2593
2597
}
2594
2598
2595
2599
assert (TL->getTypeLocClass () == TypeLoc::TemplateTypeParm);
2596
- auto TTTL = TL->getAs <TemplateTypeParmTypeLoc>();
2597
2600
2601
+ auto TTTL = TL->getAs <TemplateTypeParmTypeLoc>();
2598
2602
TPT->parameter = WalkTypeTemplateParameter (TTTL.getDecl ());
2599
2603
}
2600
2604
else if (TP->getDecl ())
@@ -4368,7 +4372,7 @@ ParserResult* Parser::ParseLibrary(const std::string& File)
4368
4372
break ;
4369
4373
}
4370
4374
4371
- if (FileEntry.empty ())
4375
+ if (FileEntry.empty () || ! llvm::sys::fs::exists (FileEntry) )
4372
4376
{
4373
4377
res->kind = ParserResultKind::FileNotFound;
4374
4378
return res;
0 commit comments