Browse Source

Fixed a crash when checking specialisations of std::vector.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/685/head
Dimitar Dobrev 9 years ago
parent
commit
1dd73afda6
  1. 50
      src/CppParser/Parser.cpp
  2. 3
      src/Generator/Generators/CLI/CLITypePrinter.cs
  3. 12
      src/Generator/Types/Std/Stdlib.cs

50
src/CppParser/Parser.cpp

@ -2562,16 +2562,8 @@ Type* Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, @@ -2562,16 +2562,8 @@ Type* Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
auto UTT = new UnaryTransformType();
auto Loc = TL->getAs<UnaryTransformTypeLoc>().getUnderlyingTInfo()->getTypeLoc();
if (UT->isSugared())
{
UTT->Desugared = GetQualifiedType(UT->desugar(), &Loc);
UTT->BaseType = GetQualifiedType(UT->getBaseType(), &Loc);
}
else
{
UTT->Desugared = GetQualifiedType(UT->getBaseType(), &Loc);
UTT->BaseType = GetQualifiedType(UT->getBaseType(), &Loc);
}
UTT->Desugared = GetQualifiedType(UT->isSugared() ? UT->desugar() : UT->getBaseType(), &Loc);
UTT->BaseType = GetQualifiedType(UT->getBaseType(), &Loc);
Ty = UTT;
break;
@ -2733,6 +2725,27 @@ bool Parser::CanCheckCodeGenInfo(clang::Sema& S, const clang::Type* Ty) @@ -2733,6 +2725,27 @@ bool Parser::CanCheckCodeGenInfo(clang::Sema& S, const clang::Type* Ty)
return true;
}
static clang::TypeLoc DesugarTypeLoc(const clang::TypeLoc& Loc)
{
using namespace clang;
switch (Loc.getTypeLocClass())
{
case TypeLoc::TypeLocClass::Attributed:
{
auto ATL = Loc.getAs<AttributedTypeLoc>();
return ATL.getModifiedLoc();
}
case TypeLoc::TypeLocClass::Paren:
{
auto PTL = Loc.getAs<ParenTypeLoc>();
return PTL.getInnerLoc();
}
}
return Loc;
}
void Parser::WalkFunction(const clang::FunctionDecl* FD, Function* F,
bool IsDependent)
{
@ -2762,22 +2775,7 @@ void Parser::WalkFunction(const clang::FunctionDecl* FD, Function* F, @@ -2762,22 +2775,7 @@ void Parser::WalkFunction(const clang::FunctionDecl* FD, Function* F,
TypeLoc RTL;
if (auto TSI = FD->getTypeSourceInfo())
{
auto Loc = TSI->getTypeLoc();
switch (Loc.getTypeLocClass())
{
case TypeLoc::TypeLocClass::Attributed:
{
auto ATL = Loc.getAs<AttributedTypeLoc>();
Loc = ATL.getModifiedLoc();
break;
}
case TypeLoc::TypeLocClass::Paren:
{
auto PTL = Loc.getAs<ParenTypeLoc>();
Loc = PTL.getInnerLoc();
break;
}
}
auto Loc = DesugarTypeLoc(TSI->getTypeLoc());
auto FTL = Loc.getAs<FunctionTypeLoc>();
if (FTL)
{

3
src/Generator/Generators/CLI/CLITypePrinter.cs

@ -224,6 +224,7 @@ namespace CppSharp.Generators.CLI @@ -224,6 +224,7 @@ namespace CppSharp.Generators.CLI
case PrimitiveType.IntPtr: return "IntPtr";
case PrimitiveType.UIntPtr: return "UIntPtr";
case PrimitiveType.Null: return "void*";
case PrimitiveType.Int128: return "__int128";
}
throw new NotSupportedException();
@ -269,7 +270,7 @@ namespace CppSharp.Generators.CLI @@ -269,7 +270,7 @@ namespace CppSharp.Generators.CLI
return string.Empty;
TypeMap typeMap = null;
if (TypeMapDatabase.FindTypeMap(template, out typeMap))
if (TypeMapDatabase.FindTypeMap(template, out typeMap) && !typeMap.IsIgnored)
{
typeMap.Declaration = decl;
typeMap.Type = template;

12
src/Generator/Types/Std/Stdlib.cs

@ -164,11 +164,15 @@ namespace CppSharp.Types.Std @@ -164,11 +164,15 @@ namespace CppSharp.Types.Std
{
get
{
var type = Type as TemplateSpecializationType;
var pointeeType = type.Arguments[0].Type;
var finalType = Type.GetFinalPointee() ?? Type;
var type = finalType as TemplateSpecializationType;
if (type == null)
{
var injectedClassNameType = (InjectedClassNameType) finalType;
type = (TemplateSpecializationType) injectedClassNameType.InjectedSpecializationType.Type;
}
var checker = new TypeIgnoreChecker(TypeMapDatabase);
pointeeType.Visit(checker);
type.Arguments[0].Type.Visit(checker);
return checker.IsIgnored;
}

Loading…
Cancel
Save