Browse Source

Fixed handling of template methods processing.

pull/16/merge
triton 13 years ago
parent
commit
463730baeb
  1. 31
      src/Parser/Parser.cpp

31
src/Parser/Parser.cpp

@ -580,6 +580,11 @@ CppSharp::AST::Class^ Parser::WalkRecordCXX(clang::CXXRecordDecl* Record)
{ {
auto MD = cast<CXXMethodDecl>(D); auto MD = cast<CXXMethodDecl>(D);
auto Method = WalkMethodCXX(MD); auto Method = WalkMethodCXX(MD);
// Some implicit class template methods do not seem to provide type source
// information which causes us to not be able to properly walk through the
// qualified return type. In this case, do not add them to the AST.
if (!Method->ReturnType.Type)
continue;
Method->AccessDecl = AccessDecl; Method->AccessDecl = AccessDecl;
RC->Methods->Add(Method); RC->Methods->Add(Method);
HandleComments(MD, Method); HandleComments(MD, Method);
@ -1465,20 +1470,32 @@ void Parser::WalkFunction(clang::FunctionDecl* FD, CppSharp::AST::Function^ F,
TypeLoc RTL; TypeLoc RTL;
if (auto TSI = FD->getTypeSourceInfo()) if (auto TSI = FD->getTypeSourceInfo())
{ {
auto TL = TSI->getTypeLoc();
if (!TL)
TL.isNull();
FunctionTypeLoc FTL = TSI->getTypeLoc().getAs<FunctionTypeLoc>(); FunctionTypeLoc FTL = TSI->getTypeLoc().getAs<FunctionTypeLoc>();
RTL = FTL.getResultLoc(); if (FTL)
RTL = FTL.getResultLoc();
auto &SM = C->getSourceManager(); auto &SM = C->getSourceManager();
auto headStartLoc = GetDeclStartLocation(C.get(), FD); auto headStartLoc = GetDeclStartLocation(C.get(), FD);
auto headEndLoc = SM.getExpansionLoc(FTL.getLParenLoc()); if (FTL)
auto headRange = clang::SourceRange(headStartLoc, headEndLoc); {
auto headEndLoc = SM.getExpansionLoc(FTL.getLParenLoc());
auto headRange = clang::SourceRange(headStartLoc, headEndLoc);
HandlePreprocessedEntities(F, headRange, CppSharp::AST::MacroLocation::FunctionHead); HandlePreprocessedEntities(F, headRange, CppSharp::AST::MacroLocation::FunctionHead);
HandlePreprocessedEntities(F, FTL.getParensRange(), CppSharp::AST::MacroLocation::FunctionParameters); HandlePreprocessedEntities(F, FTL.getParensRange(), CppSharp::AST::MacroLocation::FunctionParameters);
//auto bodyRange = clang::SourceRange(FTL.getRParenLoc(), FD->getLocEnd()); //auto bodyRange = clang::SourceRange(FTL.getRParenLoc(), FD->getLocEnd());
//HandlePreprocessedEntities(F, bodyRange, CppSharp::AST::MacroLocation::FunctionBody); //HandlePreprocessedEntities(F, bodyRange, CppSharp::AST::MacroLocation::FunctionBody);
}
} }
// See processing of CXXMethod in WalkRecordCXX for why this is needed.
if (!RTL)
return;
F->ReturnType = GetQualifiedType(FD->getResultType(), F->ReturnType = GetQualifiedType(FD->getResultType(),
WalkType(FD->getResultType(), &RTL)); WalkType(FD->getResultType(), &RTL));

Loading…
Cancel
Save