Browse Source

Added more robust parsing for type locs when parsing functions.

(last commit test should also trigger this)
pull/131/head
triton 12 years ago
parent
commit
7b30906cd6
  1. 13
      src/CppParser/Parser.cpp
  2. 14
      src/Parser/Parser.cpp

13
src/CppParser/Parser.cpp

@ -1656,14 +1656,17 @@ void Parser::WalkFunction(clang::FunctionDecl* FD, Function* F,
if (FTSI) if (FTSI)
{ {
auto FTL = FTSI->getTypeLoc(); auto FTL = FTSI->getTypeLoc();
while (!FTL.getAs<FunctionTypeLoc>()) while (FTL && !FTL.getAs<FunctionTypeLoc>())
FTL = FTL.getNextTypeLoc(); FTL = FTL.getNextTypeLoc();
auto FTInfo = FTL.castAs<FunctionTypeLoc>(); if (FTL)
assert (!FTInfo.isNull()); {
auto FTInfo = FTL.castAs<FunctionTypeLoc>();
assert (!FTInfo.isNull());
ParamStartLoc = FTInfo.getRParenLoc(); ParamStartLoc = FTInfo.getRParenLoc();
ResultLoc = FTInfo.getResultLoc().getLocStart(); ResultLoc = FTInfo.getResultLoc().getLocStart();
}
} }
clang::SourceRange Range(FD->getLocStart(), ParamStartLoc); clang::SourceRange Range(FD->getLocStart(), ParamStartLoc);

14
src/Parser/Parser.cpp

@ -1712,6 +1712,7 @@ static bool CanCheckCodeGenInfo(const clang::Type* Ty)
return CheckCodeGenInfo; return CheckCodeGenInfo;
} }
void Parser::WalkFunction(clang::FunctionDecl* FD, CppSharp::AST::Function^ F, void Parser::WalkFunction(clang::FunctionDecl* FD, CppSharp::AST::Function^ F,
bool IsDependent) bool IsDependent)
{ {
@ -1770,14 +1771,17 @@ void Parser::WalkFunction(clang::FunctionDecl* FD, CppSharp::AST::Function^ F,
if (FTSI) if (FTSI)
{ {
auto FTL = FTSI->getTypeLoc(); auto FTL = FTSI->getTypeLoc();
while (!FTL.getAs<FunctionTypeLoc>()) while (FTL && !FTL.getAs<FunctionTypeLoc>())
FTL = FTL.getNextTypeLoc(); FTL = FTL.getNextTypeLoc();
auto FTInfo = FTL.castAs<FunctionTypeLoc>(); if (FTL)
assert (!FTInfo.isNull()); {
auto FTInfo = FTL.castAs<FunctionTypeLoc>();
assert (!FTInfo.isNull());
ParamStartLoc = FTInfo.getRParenLoc(); ParamStartLoc = FTInfo.getRParenLoc();
ResultLoc = FTInfo.getResultLoc().getLocStart(); ResultLoc = FTInfo.getResultLoc().getLocStart();
}
} }
clang::SourceRange Range(FD->getLocStart(), ParamStartLoc); clang::SourceRange Range(FD->getLocStart(), ParamStartLoc);

Loading…
Cancel
Save