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. 5
      src/CppParser/Parser.cpp
  2. 6
      src/Parser/Parser.cpp

5
src/CppParser/Parser.cpp

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

6
src/Parser/Parser.cpp

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

Loading…
Cancel
Save