Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--sort=no
--fields=+{signature}
--kinds-C++=+fstz
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
TestUtil input.cpp /^struct TestUtil {$/;" s file:
isNull input.cpp /^ static bool isNull(const T&) { return false; }$/;" f struct:TestUtil typeref:typename:bool file: signature:(const T &)
__anon39cbdfcb010d input.cpp /^ static bool isNull(const T&) { return false; }$/;" z function:TestUtil::isNull typeref:typename:const T & file:
TestUtil input.cpp /^struct TestUtil<T*> {$/;" s file:
isNull input.cpp /^ static bool isNull(T* f) { return 0 == f; }$/;" f struct:TestUtil typeref:typename:bool file: signature:(T * f)
f input.cpp /^ static bool isNull(T* f) { return 0 == f; }$/;" z function:TestUtil::isNull typeref:typename:T * file:
memtype input.cpp /^struct memtype {};$/;" s file:
klass input.cpp /^struct klass {};$/;" s file:
isNull input.cpp /^TestUtil<const memtype klass::*&>::isNull(const memtype klass::* &f)$/;" f class:TestUtil typeref:typename:bool signature:(const memtype klass::* & f)
f input.cpp /^TestUtil<const memtype klass::*&>::isNull(const memtype klass::* &f)$/;" z function:TestUtil::isNull typeref:typename:const memtype klass::* & file:
Handler input.cpp /^struct Handler {$/;" s file:
process input.cpp /^ void process(T value) { }$/;" f struct:Handler typeref:typename:void file: signature:(T value)
value input.cpp /^ void process(T value) { }$/;" z function:Handler::process typeref:typename:T file:
Handler input.cpp /^struct Handler<R (C::*)()> {$/;" s file:
process input.cpp /^ void process(R (C::*method)()) { }$/;" f struct:Handler typeref:typename:void file: signature:(R (C::* method)())
method input.cpp /^ void process(R (C::*method)()) { }$/;" z function:Handler::process typeref:typename:R (C::*)() file:
Handler input.cpp /^struct Handler<R (C::*)(A)> {$/;" s file:
process input.cpp /^ void process(R (C::*method)(A)) { }$/;" f struct:Handler typeref:typename:void file: signature:(R (C::* method)(A))
method input.cpp /^ void process(R (C::*method)(A)) { }$/;" z function:Handler::process typeref:typename:R (C::*)(A) file:
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Derived from #4348 submitted by @gaborbernat.

// C++ template specialization that previously triggered scope management crash
// Test case for issue 4344: assertion failure in cxxScopePushTop
template <class T>
struct TestUtil {
static bool isNull(const T&) { return false; }
};

template <class T>
struct TestUtil<T*> {
static bool isNull(T* f) { return 0 == f; }
};

struct memtype {};
struct klass {};

template <>
inline
bool
TestUtil<const memtype klass::*&>::isNull(const memtype klass::* &f)
{
return 0 == f;
}

// Additional test cases for complex template specializations
template <typename T>
struct Handler {
void process(T value) { }
};

template <typename R, typename C>
struct Handler<R (C::*)()> {
void process(R (C::*method)()) { }
};

template <typename R, typename C, typename A>
struct Handler<R (C::*)(A)> {
void process(R (C::*method)(A)) { }
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cxx11
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sort=no
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Point input.cpp /^struct Point {$/;" s file:
distance input.cpp /^ int distance(void) {$/;" f struct:Point typeref:typename:int file:
NS input.cpp /^namespace NS {$/;" n file:
MyReal input.cpp /^ using MyReal = float;$/;" t namespace:NS typeref:typename:float file:
MyVec input.cpp /^ using MyVec = T[2];$/;" t namespace:NS typeref:typename:T[2] file:
distance input.cpp /^int Point<int>::distance(void) { return 1; }$/;" f class:Point typeref:typename:int
distance input.cpp /^int Point<NS::MyReal>::distance(void) { return 1; }$/;" f class:Point typeref:typename:int
distance input.cpp /^int Point<NS::MyVec<int>>::distance(void) { return 1; }$/;" f class:Point typeref:typename:int
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
template <class T>
struct Point {
int distance(void) {
return 0;
}
};

namespace NS {
using MyReal = float;
template <class T>
using MyVec = T[2];
};

template<>
int Point<int>::distance(void) { return 1; }

template<>
int Point<NS::MyReal>::distance(void) { return 1; }

template<>
int Point<NS::MyVec<int>>::distance(void) { return 1; }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cxx11
33 changes: 30 additions & 3 deletions parsers/cxx/cxx_parser_function.c
Original file line number Diff line number Diff line change
Expand Up @@ -1591,10 +1591,37 @@ int cxxParserEmitFunctionTags(
{
CXXToken * pScopeId = pInfo->pScopeStart;

pInfo->pScopeStart = cxxTokenChainNextTokenOfType(
while (1)
{
pInfo->pScopeStart = cxxTokenChainNextTokenOfType(
pInfo->pScopeStart,
CXXTokenTypeMultipleColons
);
CXXTokenTypeMultipleColons|CXXTokenTypeSmallerThanSign);

CXX_DEBUG_ASSERT(pInfo->pScopeStart,
"We could find neither '::' nor '<'");
if (!pInfo->pScopeStart)
{
pInfo->pScopeStart = pInfo->pIdentifierStart;
break;
}

if (cxxTokenTypeIs(pInfo->pScopeStart, CXXTokenTypeMultipleColons))
break; // Good!

if (cxxTokenTypeIs(pInfo->pScopeStart, CXXTokenTypeSmallerThanSign))
{
// Skip the template arguments.
// Should we add the template arguments to the scope? (FIXME)
pInfo->pScopeStart = cxxTokenChainSkipToEndOfTemplateAngleBracket(pInfo->pScopeStart);
CXX_DEBUG_ASSERT(pInfo->pScopeStart,
"We could not find '>', the end of template argument(s)");
if (!pInfo->pScopeStart)
{
pInfo->pScopeStart = pInfo->pIdentifierStart;
break;
}
}
}

CXX_DEBUG_ASSERT(pInfo->pScopeStart,"We should have found a next token here");

Expand Down
Loading