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, @@ -1656,14 +1656,17 @@ 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();
auto FTInfo = FTL.castAs<FunctionTypeLoc>();
assert (!FTInfo.isNull());
if (FTL)
{
auto FTInfo = FTL.castAs<FunctionTypeLoc>();
assert (!FTInfo.isNull());
ParamStartLoc = FTInfo.getRParenLoc();
ResultLoc = FTInfo.getResultLoc().getLocStart();
ParamStartLoc = FTInfo.getRParenLoc();
ResultLoc = FTInfo.getResultLoc().getLocStart();
}
}
clang::SourceRange Range(FD->getLocStart(), ParamStartLoc);

14
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,14 +1771,17 @@ void Parser::WalkFunction(clang::FunctionDecl* FD, CppSharp::AST::Function^ F, @@ -1770,14 +1771,17 @@ 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();
auto FTInfo = FTL.castAs<FunctionTypeLoc>();
assert (!FTInfo.isNull());
if (FTL)
{
auto FTInfo = FTL.castAs<FunctionTypeLoc>();
assert (!FTInfo.isNull());
ParamStartLoc = FTInfo.getRParenLoc();
ResultLoc = FTInfo.getResultLoc().getLocStart();
ParamStartLoc = FTInfo.getRParenLoc();
ResultLoc = FTInfo.getResultLoc().getLocStart();
}
}
clang::SourceRange Range(FD->getLocStart(), ParamStartLoc);

Loading…
Cancel
Save