data: Remove Template Argument reference kind and edge
This commit is contained in:
committed by
Eberhard Graether
parent
583046c291
commit
fc0e652ae0
@@ -2677,7 +2677,7 @@ void GraphController::createLegendGraph()
|
||||
Node* templateSpecializationNode = addNode(NodeType::NODE_TYPE, L"TemplateType<ArgumentType>", Vec2i(x, y + dy * ++i), DEFINITION_IMPLICIT);
|
||||
Node* argumentNode = addNode(NodeType::NODE_TYPE, L"ArgumentType", Vec2i(x + 270, y + dy * i));
|
||||
addEdge(Edge::EDGE_TEMPLATE_SPECIALIZATION, templateSpecializationNode, templateNode);
|
||||
addEdge(Edge::EDGE_TEMPLATE_ARGUMENT, templateSpecializationNode, argumentNode);
|
||||
addEdge(Edge::EDGE_TYPE_USAGE, templateSpecializationNode, argumentNode);
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -28,8 +28,6 @@ Edge::EdgeType Edge::intToType(int value)
|
||||
return EDGE_INHERITANCE;
|
||||
case EDGE_OVERRIDE:
|
||||
return EDGE_OVERRIDE;
|
||||
case EDGE_TEMPLATE_ARGUMENT:
|
||||
return EDGE_TEMPLATE_ARGUMENT;
|
||||
case EDGE_TYPE_ARGUMENT:
|
||||
return EDGE_TYPE_ARGUMENT;
|
||||
case EDGE_TEMPLATE_SPECIALIZATION:
|
||||
@@ -141,8 +139,6 @@ std::wstring Edge::getReadableTypeString(EdgeType type)
|
||||
return L"inheritance";
|
||||
case EDGE_OVERRIDE:
|
||||
return L"override";
|
||||
case EDGE_TEMPLATE_ARGUMENT:
|
||||
return L"template argument";
|
||||
case EDGE_TYPE_ARGUMENT:
|
||||
return L"type argument";
|
||||
case EDGE_TEMPLATE_SPECIALIZATION:
|
||||
|
||||
@@ -22,7 +22,6 @@ public:
|
||||
EDGE_CALL = 1 << 3,
|
||||
EDGE_INHERITANCE = 1 << 4,
|
||||
EDGE_OVERRIDE = 1 << 5,
|
||||
EDGE_TEMPLATE_ARGUMENT = 1 << 6,
|
||||
EDGE_TYPE_ARGUMENT = 1 << 7,
|
||||
EDGE_TEMPLATE_SPECIALIZATION = 1 << 9,
|
||||
EDGE_TEMPLATE_MEMBER_SPECIALIZATION = 1 << 10,
|
||||
|
||||
@@ -166,8 +166,6 @@ Edge::EdgeType ParserClientImpl::referenceKindToEdgeType(ReferenceKind reference
|
||||
return Edge::EDGE_INHERITANCE;
|
||||
case REFERENCE_OVERRIDE:
|
||||
return Edge::EDGE_OVERRIDE;
|
||||
case REFERENCE_TEMPLATE_ARGUMENT:
|
||||
return Edge::EDGE_TEMPLATE_ARGUMENT;
|
||||
case REFERENCE_TYPE_ARGUMENT:
|
||||
return Edge::EDGE_TYPE_ARGUMENT;
|
||||
case REFERENCE_TEMPLATE_SPECIALIZATION:
|
||||
|
||||
@@ -14,8 +14,6 @@ ReferenceKind intToReferenceKind(int v)
|
||||
return REFERENCE_INHERITANCE;
|
||||
case REFERENCE_OVERRIDE:
|
||||
return REFERENCE_OVERRIDE;
|
||||
case REFERENCE_TEMPLATE_ARGUMENT:
|
||||
return REFERENCE_TEMPLATE_ARGUMENT;
|
||||
case REFERENCE_TYPE_ARGUMENT:
|
||||
return REFERENCE_TYPE_ARGUMENT;
|
||||
case REFERENCE_TEMPLATE_SPECIALIZATION:
|
||||
|
||||
@@ -9,7 +9,6 @@ enum ReferenceKind
|
||||
REFERENCE_CALL = 3,
|
||||
REFERENCE_INHERITANCE = 4,
|
||||
REFERENCE_OVERRIDE = 5,
|
||||
REFERENCE_TEMPLATE_ARGUMENT = 6,
|
||||
REFERENCE_TYPE_ARGUMENT = 7,
|
||||
REFERENCE_TEMPLATE_SPECIALIZATION = 9,
|
||||
REFERENCE_TEMPLATE_MEMBER_SPECIALIZATION = 10,
|
||||
|
||||
@@ -7,12 +7,19 @@ CxxAstVisitorComponentContext::CxxAstVisitorComponentContext(CxxAstVisitor* astV
|
||||
{
|
||||
}
|
||||
|
||||
const clang::NamedDecl* CxxAstVisitorComponentContext::getTopmostContextDecl() const
|
||||
const clang::NamedDecl* CxxAstVisitorComponentContext::getTopmostContextDecl(const size_t skip) const
|
||||
{
|
||||
size_t skipped = 0;
|
||||
|
||||
for (auto it = m_contextStack.rbegin(); it != m_contextStack.rend(); it++)
|
||||
{
|
||||
if (*it)
|
||||
{
|
||||
if (skipped < skip)
|
||||
{
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
const clang::NamedDecl* decl = (*it)->getDecl();
|
||||
if (decl)
|
||||
{
|
||||
@@ -23,7 +30,7 @@ const clang::NamedDecl* CxxAstVisitorComponentContext::getTopmostContextDecl() c
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const CxxContext* CxxAstVisitorComponentContext::getContext(const size_t skip)
|
||||
const CxxContext* CxxAstVisitorComponentContext::getContext(const size_t skip) const
|
||||
{
|
||||
size_t skipped = 0;
|
||||
|
||||
@@ -31,14 +38,12 @@ const CxxContext* CxxAstVisitorComponentContext::getContext(const size_t skip)
|
||||
{
|
||||
if (*it)
|
||||
{
|
||||
if (skipped >= skip)
|
||||
{
|
||||
return it->get();
|
||||
}
|
||||
else
|
||||
if (skipped < skip)
|
||||
{
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
return it->get();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
@@ -155,7 +160,7 @@ void CxxAstVisitorComponentContext::endTraverseClassTemplatePartialSpecializatio
|
||||
|
||||
void CxxAstVisitorComponentContext::beginTraverseDeclRefExpr(clang::DeclRefExpr* s)
|
||||
{
|
||||
m_templateArgumentContext.push_back(std::make_shared<CxxContextDecl>(s->getDecl()));
|
||||
m_templateArgumentContext.push_back(std::make_shared<CxxContextDecl>(s->getDecl())); // e.g. used for recording usage of template arguments within function calls
|
||||
}
|
||||
|
||||
void CxxAstVisitorComponentContext::endTraverseDeclRefExpr(clang::DeclRefExpr* s)
|
||||
|
||||
@@ -13,8 +13,8 @@ class CxxAstVisitorComponentContext
|
||||
public:
|
||||
CxxAstVisitorComponentContext(CxxAstVisitor* astVisitor);
|
||||
|
||||
const clang::NamedDecl* getTopmostContextDecl() const;
|
||||
const CxxContext* getContext(const size_t skip = 0);
|
||||
const clang::NamedDecl* getTopmostContextDecl(const size_t skip = 0) const;
|
||||
const CxxContext* getContext(const size_t skip = 0) const;
|
||||
|
||||
void beginTraverseDecl(clang::Decl* d);
|
||||
void endTraverseDecl(clang::Decl* d);
|
||||
|
||||
@@ -100,14 +100,14 @@ void CxxAstVisitorComponentIndexer::beginTraverseTemplateArgumentLoc(const clang
|
||||
const ParseLocation parseLocation = getParseLocation(loc.getLocation());
|
||||
|
||||
m_client->recordReference(
|
||||
getAstVisitor()->getComponent<CxxAstVisitorComponentTypeRefKind>()->getReferenceKind(),
|
||||
REFERENCE_TYPE_USAGE,
|
||||
symbolId,
|
||||
getOrCreateSymbolId(getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getContext()),
|
||||
parseLocation
|
||||
);
|
||||
|
||||
{
|
||||
const clang::NamedDecl* namedContextDecl = getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getTopmostContextDecl();
|
||||
const clang::NamedDecl* namedContextDecl = getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getTopmostContextDecl(1);
|
||||
if (namedContextDecl)
|
||||
{
|
||||
m_client->recordReference(
|
||||
@@ -502,6 +502,7 @@ void CxxAstVisitorComponentIndexer::visitTypeLoc(clang::TypeLoc tl)
|
||||
if ((getAstVisitor()->shouldVisitReference(tl.getBeginLoc())) &&
|
||||
(!getAstVisitor()->checkIgnoresTypeLoc(tl)))
|
||||
{
|
||||
clang::TypeLoc::TypeLocClass tlcc = tl.getTypeLocClass();
|
||||
if (!tl.getAs<clang::TemplateTypeParmTypeLoc>().isNull())
|
||||
{
|
||||
const clang::TemplateTypeParmTypeLoc& ttptl = tl.castAs<clang::TemplateTypeParmTypeLoc>();
|
||||
@@ -544,18 +545,18 @@ void CxxAstVisitorComponentIndexer::visitTypeLoc(clang::TypeLoc tl)
|
||||
const ParseLocation parseLocation = getParseLocation(loc);
|
||||
|
||||
m_client->recordReference(
|
||||
getAstVisitor()->getComponent<CxxAstVisitorComponentTypeRefKind>()->getReferenceKind(),
|
||||
getAstVisitor()->getComponent<CxxAstVisitorComponentTypeRefKind>()->isTraversingInheritance() ? REFERENCE_INHERITANCE : REFERENCE_TYPE_USAGE,
|
||||
symbolId,
|
||||
getOrCreateSymbolId(getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getContext(1)), // we skip the last element because it refers to this typeloc.
|
||||
parseLocation
|
||||
);
|
||||
|
||||
if (getAstVisitor()->getComponent<CxxAstVisitorComponentTypeRefKind>()->getReferenceKind() == REFERENCE_TEMPLATE_ARGUMENT)
|
||||
if (getAstVisitor()->getComponent<CxxAstVisitorComponentTypeRefKind>()->isTraversingTemplateArgument())
|
||||
{
|
||||
m_client->recordReference(
|
||||
REFERENCE_TYPE_USAGE,
|
||||
symbolId,
|
||||
getOrCreateSymbolId(getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getTopmostContextDecl()), // we use the closest named decl here
|
||||
getOrCreateSymbolId(getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getTopmostContextDecl(2)), // we use the closest named decl here
|
||||
parseLocation
|
||||
);
|
||||
}
|
||||
@@ -834,15 +835,16 @@ ReferenceKind CxxAstVisitorComponentIndexer::consumeDeclRefContextKind()
|
||||
ReferenceKind refKind = REFERENCE_UNDEFINED;
|
||||
|
||||
CxxAstVisitorComponentTypeRefKind* typeRefKindComponent = getAstVisitor()->getComponent<CxxAstVisitorComponentTypeRefKind>();
|
||||
if (typeRefKindComponent->getReferenceKind() == REFERENCE_TYPE_USAGE)
|
||||
if (typeRefKindComponent->isTraversingInheritance())
|
||||
{
|
||||
refKind = getAstVisitor()->getComponent<CxxAstVisitorComponentDeclRefKind>()->getReferenceKind();
|
||||
return REFERENCE_INHERITANCE;
|
||||
}
|
||||
else
|
||||
else if (typeRefKindComponent->isTraversingTemplateArgument())
|
||||
{
|
||||
refKind = typeRefKindComponent->getReferenceKind();
|
||||
return REFERENCE_TYPE_USAGE;
|
||||
}
|
||||
return refKind;
|
||||
|
||||
return getAstVisitor()->getComponent<CxxAstVisitorComponentDeclRefKind>()->getReferenceKind();
|
||||
}
|
||||
|
||||
Id CxxAstVisitorComponentIndexer::getOrCreateSymbolId(const clang::NamedDecl* decl)
|
||||
|
||||
@@ -5,44 +5,42 @@ CxxAstVisitorComponentTypeRefKind::CxxAstVisitorComponentTypeRefKind(CxxAstVisit
|
||||
{
|
||||
}
|
||||
|
||||
ReferenceKind CxxAstVisitorComponentTypeRefKind::getReferenceKind() const
|
||||
bool CxxAstVisitorComponentTypeRefKind::isTraversingInheritance() const
|
||||
{
|
||||
for (auto it = m_refKindStack.rbegin(); it != m_refKindStack.rend(); it++)
|
||||
{
|
||||
if ((*it) != REFERENCE_UNDEFINED)
|
||||
{
|
||||
return (*it);
|
||||
}
|
||||
}
|
||||
return REFERENCE_TYPE_USAGE;
|
||||
return (!m_stateKindStack.empty() && m_stateKindStack.back() == STATE_INHERITANCE);
|
||||
}
|
||||
|
||||
bool CxxAstVisitorComponentTypeRefKind::isTraversingTemplateArgument() const
|
||||
{
|
||||
return (!m_stateKindStack.empty() && m_stateKindStack.back() == STATE_TEMPLATE_ARGUMENT);
|
||||
}
|
||||
|
||||
void CxxAstVisitorComponentTypeRefKind::beginTraverseCXXBaseSpecifier()
|
||||
{
|
||||
m_refKindStack.push_back(REFERENCE_INHERITANCE);
|
||||
m_stateKindStack.push_back(STATE_INHERITANCE);
|
||||
}
|
||||
|
||||
void CxxAstVisitorComponentTypeRefKind::endTraverseCXXBaseSpecifier()
|
||||
{
|
||||
m_refKindStack.pop_back();
|
||||
m_stateKindStack.pop_back();
|
||||
}
|
||||
|
||||
void CxxAstVisitorComponentTypeRefKind::beginTraverseTemplateDefaultArgumentLoc()
|
||||
{
|
||||
m_refKindStack.push_back(REFERENCE_TYPE_USAGE);
|
||||
m_stateKindStack.push_back(STATE_USAGE);
|
||||
}
|
||||
|
||||
void CxxAstVisitorComponentTypeRefKind::endTraverseTemplateDefaultArgumentLoc()
|
||||
{
|
||||
m_refKindStack.pop_back();
|
||||
m_stateKindStack.pop_back();
|
||||
}
|
||||
|
||||
void CxxAstVisitorComponentTypeRefKind::beginTraverseTemplateArgumentLoc(const clang::TemplateArgumentLoc& loc)
|
||||
{
|
||||
m_refKindStack.push_back(REFERENCE_TEMPLATE_ARGUMENT);
|
||||
m_stateKindStack.push_back(STATE_TEMPLATE_ARGUMENT);
|
||||
}
|
||||
|
||||
void CxxAstVisitorComponentTypeRefKind::endTraverseTemplateArgumentLoc(const clang::TemplateArgumentLoc& loc)
|
||||
{
|
||||
m_refKindStack.pop_back();
|
||||
m_stateKindStack.pop_back();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ class CxxAstVisitorComponentTypeRefKind
|
||||
public:
|
||||
CxxAstVisitorComponentTypeRefKind(CxxAstVisitor* astVisitor);
|
||||
|
||||
ReferenceKind getReferenceKind() const;
|
||||
bool isTraversingInheritance() const;
|
||||
bool isTraversingTemplateArgument() const;
|
||||
|
||||
void beginTraverseCXXBaseSpecifier();
|
||||
void endTraverseCXXBaseSpecifier();
|
||||
@@ -27,7 +28,14 @@ public:
|
||||
void endTraverseTemplateArgumentLoc(const clang::TemplateArgumentLoc& loc);
|
||||
|
||||
private:
|
||||
std::vector<ReferenceKind> m_refKindStack;
|
||||
enum StateKind
|
||||
{
|
||||
STATE_USAGE,
|
||||
STATE_INHERITANCE,
|
||||
STATE_TEMPLATE_ARGUMENT
|
||||
};
|
||||
|
||||
std::vector<StateKind> m_stateKindStack;
|
||||
};
|
||||
|
||||
#endif // CXX_AST_VISITOR_COMPONENT_TYPE_REF_KIND_H
|
||||
|
||||
@@ -621,11 +621,7 @@ Edge::TypeMask QtCustomTrailView::getCheckedEdgeTypes() const
|
||||
|
||||
edgeTypes |= type;
|
||||
|
||||
if (type == Edge::EDGE_TYPE_USAGE)
|
||||
{
|
||||
edgeTypes |= Edge::EDGE_TEMPLATE_ARGUMENT;
|
||||
}
|
||||
else if (type == Edge::EDGE_TEMPLATE_SPECIALIZATION)
|
||||
if (type == Edge::EDGE_TEMPLATE_SPECIALIZATION)
|
||||
{
|
||||
edgeTypes |= Edge::EDGE_TEMPLATE_MEMBER_SPECIALIZATION;
|
||||
}
|
||||
|
||||
@@ -3000,7 +3000,7 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->templateArgumentTypes, L"A<int> -> int <7:4 7:6>"
|
||||
client->typeUses, L"A<int> -> int <7:4 7:6>"
|
||||
));
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->typeUses, L"int main() -> int <7:4 7:6>"
|
||||
@@ -3021,7 +3021,10 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->templateArgumentTypes, L"A<int()> -> int <7:4 7:6>"
|
||||
client->typeUses, L"A<int()> -> int <7:4 7:6>"
|
||||
));
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->typeUses, L"void foo() -> int <7:4 7:6>"
|
||||
));
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->typeUses, L"void foo() -> int <7:4 7:6>"
|
||||
@@ -3042,10 +3045,16 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->templateArgumentTypes, L"A<<int, float>> -> int <7:6 7:8>"
|
||||
client->typeUses, L"A<<int, float>> -> int <7:6 7:8>"
|
||||
));
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->templateArgumentTypes, L"A<<int, float>> -> float <7:11 7:15>"
|
||||
client->typeUses, L"A<<int, float>> -> float <7:11 7:15>"
|
||||
));
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->typeUses, L"int main() -> int <7:6 7:8>"
|
||||
));
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->typeUses, L"int main() -> float <7:11 7:15>"
|
||||
));
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->typeUses, L"int main() -> int <7:6 7:8>"
|
||||
@@ -3071,7 +3080,10 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->templateArgumentTypes, L"A<int> -> int <9:4 9:6>"
|
||||
client->typeUses, L"A<int> -> int <9:4 9:6>"
|
||||
));
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->typeUses, L"int main() -> int <9:4 9:6>"
|
||||
));
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->typeUses, L"int main() -> int <9:4 9:6>"
|
||||
@@ -3094,7 +3106,10 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->templateArgumentTypes, L"A<int> -> int <9:4 9:6>"
|
||||
client->typeUses, L"A<int> -> int <9:4 9:6>"
|
||||
));
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->typeUses, L"int main() -> int <9:4 9:6>"
|
||||
));
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->typeUses, L"int main() -> int <9:4 9:6>"
|
||||
@@ -3117,7 +3132,10 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->templateArgumentTypes, L"A<int> -> int <9:8 9:10>"
|
||||
client->typeUses, L"A<int> -> int <9:8 9:10>"
|
||||
));
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->typeUses, L"int main() -> int <9:8 9:10>"
|
||||
));
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->typeUses, L"int main() -> int <9:8 9:10>"
|
||||
@@ -3127,35 +3145,35 @@ public:
|
||||
void test_cxx_parser_finds_no_template_argument_for_builtin_non_type_int_template_parameter_of_explicit_template_instantiation()
|
||||
{
|
||||
std::shared_ptr<TestIntermediateStorage> client = parseCode(
|
||||
"template <int T>\n"
|
||||
"template <int T>\n" // use of "int"
|
||||
"class A\n"
|
||||
"{\n"
|
||||
"};\n"
|
||||
"int main()\n"
|
||||
"int main()\n" // use of "int"
|
||||
"{\n"
|
||||
" A<1> a;\n"
|
||||
" A<1> a;\n" // use of "A"
|
||||
" return 0;\n"
|
||||
"}\n"
|
||||
);
|
||||
|
||||
TS_ASSERT_EQUALS(client->templateArgumentTypes.size(), 0);
|
||||
TS_ASSERT_EQUALS(client->typeUses.size(), 3);
|
||||
}
|
||||
|
||||
void test_cxx_parser_finds_no_template_argument_for_builtin_non_type_bool_template_parameter_of_explicit_template_instantiation()
|
||||
{
|
||||
std::shared_ptr<TestIntermediateStorage> client = parseCode(
|
||||
"template <bool T>\n"
|
||||
"template <bool T>\n" // use of "bool"
|
||||
"class A\n"
|
||||
"{\n"
|
||||
"};\n"
|
||||
"int main()\n"
|
||||
"int main()\n" // use of "int"
|
||||
"{\n"
|
||||
" A<true> a;\n"
|
||||
" A<true> a;\n" // use of "A"
|
||||
" return 0;\n"
|
||||
"}\n"
|
||||
);
|
||||
|
||||
TS_ASSERT_EQUALS(client->templateArgumentTypes.size(), 0);
|
||||
TS_ASSERT_EQUALS(client->typeUses.size(), 3);
|
||||
}
|
||||
|
||||
void test_cxx_parser_finds_non_type_custom_pointer_template_argument_of_implicit_template_instantiation()
|
||||
@@ -3174,7 +3192,7 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->templateArgumentTypes, L"A<&g_p> -> P g_p <9:5 9:7>"
|
||||
client->typeUses, L"A<&g_p> -> P g_p <9:5 9:7>"
|
||||
));
|
||||
}
|
||||
|
||||
@@ -3194,24 +3212,24 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->templateArgumentTypes, L"A<&g_p> -> P g_p <9:4 9:6>"
|
||||
client->typeUses, L"A<&g_p> -> P g_p <9:4 9:6>"
|
||||
));
|
||||
}
|
||||
|
||||
void test_cxx_parser_finds_no_template_argument_for_builtin_non_type_int_template_parameter_pack_of_explicit_template_instantiation()
|
||||
{
|
||||
std::shared_ptr<TestIntermediateStorage> client = parseCode(
|
||||
"template <int... T>\n"
|
||||
"template <int... T>\n" // use of "int"
|
||||
"class A\n"
|
||||
"{\n"
|
||||
"};\n"
|
||||
"int main()\n"
|
||||
"int main()\n" // use of "int"
|
||||
"{\n"
|
||||
" A<1, 2, 33>();\n"
|
||||
" A<1, 2, 33>();\n" // use of "A"
|
||||
"}\n"
|
||||
);
|
||||
|
||||
TS_ASSERT_EQUALS(client->templateArgumentTypes.size(), 0);
|
||||
TS_ASSERT_EQUALS(client->typeUses.size(), 3);
|
||||
}
|
||||
|
||||
void test_cxx_parser_finds_template_template_argument_of_explicit_template_instantiation()
|
||||
@@ -3230,11 +3248,11 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->templateArgumentTypes, L"B<A> -> A<typename T> <9:4 9:4>"
|
||||
client->typeUses, L"B<A> -> A<typename T> <9:4 9:4>"
|
||||
));
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->typeUses, L"int main() -> A<typename T> <9:4 9:4>"
|
||||
));
|
||||
)); // TODO: this is caused by beginTraverseTemplateArgumentLoc which is great!
|
||||
}
|
||||
|
||||
void test_cxx_parser_finds_template_template_argument_for_parameter_pack_of_explicit_template_instantiation()
|
||||
@@ -3255,16 +3273,35 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->templateArgumentTypes, L"B<<A, A>> -> A<typename T> <11:4 11:4>"
|
||||
client->typeUses, L"B<<A, A>> -> A<typename T> <11:4 11:4>"
|
||||
));
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->templateArgumentTypes, L"B<<A, A>> -> A<typename T> <11:7 11:7>"
|
||||
client->typeUses, L"B<<A, A>> -> A<typename T> <11:7 11:7>"
|
||||
));
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->typeUses, L"int main() -> A<typename T> <11:4 11:4>"
|
||||
));
|
||||
)); // TODO: this is caused by beginTraverseTemplateArgumentLoc which is great!
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->typeUses, L"int main() -> A<typename T> <11:7 11:7>"
|
||||
)); // TODO: this is caused by beginTraverseTemplateArgumentLoc which is great!
|
||||
}
|
||||
|
||||
void test_cxx_parser_finds_template_argument_for_implicit_specialization_of_global_template_variable()
|
||||
{
|
||||
std::shared_ptr<TestIntermediateStorage> client = parseCode(
|
||||
"template <typename T>\n"
|
||||
"T v;\n"
|
||||
"void test()\n"
|
||||
"{\n"
|
||||
" v<int> = 9;\n"
|
||||
"}\n"
|
||||
);
|
||||
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->typeUses, L"int v<int> -> int <5:4 5:6>"
|
||||
));
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->typeUses, L"void test() -> int <5:4 5:6>"
|
||||
));
|
||||
}
|
||||
|
||||
@@ -3385,14 +3422,14 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->templateArgumentTypes, L"A<int> -> int <6:9 6:11>"
|
||||
client->typeUses, L"A<int> -> int <6:9 6:11>"
|
||||
));
|
||||
}
|
||||
|
||||
void test_cxx_parser_finds_no_template_argument_for_builtin_non_type_int_template_parameter_of_explicit_template_specialization()
|
||||
{
|
||||
std::shared_ptr<TestIntermediateStorage> client = parseCode(
|
||||
"template <int T>\n"
|
||||
"template <int T>\n" // use of "int"
|
||||
"class A\n"
|
||||
"{\n"
|
||||
"};\n"
|
||||
@@ -3402,14 +3439,14 @@ public:
|
||||
"};\n"
|
||||
);
|
||||
|
||||
TS_ASSERT_EQUALS(client->templateArgumentTypes.size(), 0);
|
||||
TS_ASSERT_EQUALS(client->typeUses.size(), 2); // TODO: this should be 1, so fix the bug where explicit specialization records a typeuse on self
|
||||
// TODO: FIXME: type uses: L"A<1> -> A<1> <6:7 6:7>"
|
||||
}
|
||||
|
||||
void test_cxx_parser_finds_no_template_argument_for_builtin_non_type_bool_template_parameter_of_explicit_template_specialization()
|
||||
{
|
||||
std::shared_ptr<TestIntermediateStorage> client = parseCode(
|
||||
"template <bool T>\n"
|
||||
"template <bool T>\n" // use of "bool"
|
||||
"class A\n"
|
||||
"{\n"
|
||||
"};\n"
|
||||
@@ -3419,7 +3456,7 @@ public:
|
||||
"};\n"
|
||||
);
|
||||
|
||||
TS_ASSERT_EQUALS(client->templateArgumentTypes.size(), 0);
|
||||
TS_ASSERT_EQUALS(client->typeUses.size(), 2); // TODO: this should be 1, so fix the bug where explicit specialization records a typeuse on self
|
||||
}
|
||||
|
||||
void test_cxx_parser_finds_non_type_custom_pointer_template_argument_of_explicit_template_specialization()
|
||||
@@ -3438,7 +3475,7 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->templateArgumentTypes, L"A<&g_p> -> P g_p <8:10 8:12>"
|
||||
client->typeUses, L"A<&g_p> -> P g_p <8:10 8:12>"
|
||||
));
|
||||
}
|
||||
|
||||
@@ -3458,7 +3495,7 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->templateArgumentTypes, L"A<&g_p> -> P g_p <8:9 8:11>"
|
||||
client->typeUses, L"A<&g_p> -> P g_p <8:9 8:11>"
|
||||
));
|
||||
}
|
||||
|
||||
@@ -3478,7 +3515,7 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->templateArgumentTypes, L"B<A> -> A<typename T> <8:9 8:9>"
|
||||
client->typeUses, L"B<A> -> A<typename T> <8:9 8:9>"
|
||||
));
|
||||
}
|
||||
|
||||
@@ -3498,8 +3535,8 @@ public:
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->localSymbols, L"input.cc<5:20> <6:9 6:9>"
|
||||
));
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->templateArgumentTypes, L"A<typename T, int> -> int <6:12 6:14>"
|
||||
TS_ASSERT(utility::containsElement<std::wstring>( // TODO: change to type usage
|
||||
client->typeUses, L"A<typename T, int> -> int <6:12 6:14>"
|
||||
));
|
||||
}
|
||||
|
||||
@@ -3555,7 +3592,7 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->templateArgumentTypes, L"A<&g_p, P * q> -> P g_p <8:10 8:12>" //TODO this is completely wrong? should be a normal usage
|
||||
client->typeUses, L"A<&g_p, P * q> -> P g_p <8:10 8:12>" //TODO this is completely wrong? should be a normal usage
|
||||
));
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->localSymbols, L"input.cc<7:14> <8:15 8:15>"
|
||||
@@ -3578,7 +3615,7 @@ public:
|
||||
);
|
||||
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->templateArgumentTypes, L"A<&g_p, P & q> -> P g_p <8:9 8:11>"
|
||||
client->typeUses, L"A<&g_p, P & q> -> P g_p <8:9 8:11>"
|
||||
));
|
||||
TS_ASSERT(utility::containsElement<std::wstring>(
|
||||
client->localSymbols, L"input.cc<7:14> <8:14 8:14>"
|
||||
|
||||
@@ -315,7 +315,6 @@ public:
|
||||
std::vector<std::wstring> typeUses; // for types
|
||||
std::vector<std::wstring> macroUses;
|
||||
std::vector<std::wstring> annotationUses;
|
||||
std::vector<std::wstring> templateArgumentTypes;
|
||||
std::vector<std::wstring> typeArguments;
|
||||
std::vector<std::wstring> templateSpecializations;
|
||||
std::vector<std::wstring> templateMemberSpecializations;
|
||||
@@ -385,8 +384,6 @@ private:
|
||||
return L"REFERENCE_INHERITANCE";
|
||||
case Edge::EDGE_OVERRIDE:
|
||||
return L"REFERENCE_OVERRIDE";
|
||||
case Edge::EDGE_TEMPLATE_ARGUMENT:
|
||||
return L"REFERENCE_TEMPLATE_ARGUMENT";
|
||||
case Edge::EDGE_TYPE_ARGUMENT:
|
||||
return L"REFERENCE_TYPE_ARGUMENT";
|
||||
case Edge::EDGE_TEMPLATE_SPECIALIZATION:
|
||||
@@ -469,8 +466,6 @@ private:
|
||||
return &inheritances;
|
||||
case Edge::EDGE_OVERRIDE:
|
||||
return &overrides;
|
||||
case Edge::EDGE_TEMPLATE_ARGUMENT:
|
||||
return &templateArgumentTypes;
|
||||
case Edge::EDGE_TYPE_ARGUMENT:
|
||||
return &typeArguments;
|
||||
case Edge::EDGE_TEMPLATE_SPECIALIZATION:
|
||||
|
||||
Reference in New Issue
Block a user