Browse Source

Fixed template parsing issue with processing of type locs.

Fixes https://github.com/mono/CppSharp/issues/964.
pull/966/head
Joao Matos 8 years ago
parent
commit
f21d44af77
  1. 9
      src/CppParser/Parser.cpp
  2. 16
      tests/Native/Templates.h

9
src/CppParser/Parser.cpp

@ -1228,16 +1228,17 @@ Parser::WalkTemplateArgumentList(const clang::TemplateArgumentList* TAL, @@ -1228,16 +1228,17 @@ Parser::WalkTemplateArgumentList(const clang::TemplateArgumentList* TAL,
using namespace clang;
auto params = std::vector<CppSharp::CppParser::TemplateArgument>();
auto typeLocNumArgs = TSTL ? TSTL->getNumArgs() : 0;
for (size_t i = 0, e = TAL->size(); i < e; i++)
{
auto TA = TAL->get(i);
TemplateArgumentLoc TAL;
TemplateArgumentLoc TArgLoc;
TemplateArgumentLoc *ArgLoc = 0;
if (TSTL && TSTL->getTypePtr() && i < TSTL->getNumArgs())
if (TSTL && TSTL->getTypePtr() && i < typeLocNumArgs && e == typeLocNumArgs)
{
TAL = TSTL->getArgLoc(i);
ArgLoc = &TAL;
TArgLoc = TSTL->getArgLoc(i);
ArgLoc = &TArgLoc;
}
auto Arg = WalkTemplateArgument(TA, ArgLoc);
params.push_back(Arg);

16
tests/Native/Templates.h

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
template<typename T, T Value>
struct integral_constant
{
static constexpr T value = Value;
};
template<bool Value>
using bool_constant = integral_constant<bool, Value>;
template<class T>
struct is_integral : integral_constant<bool, false>
{ };
template<typename T>
struct is_arithmetic : bool_constant<is_integral<T>::value>
{ };
Loading…
Cancel
Save