From c54c405dd1f8a3148d2638ea003b991aac0e94df Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Tue, 2 Dec 2014 00:55:57 +0100 Subject: [PATCH] logic: fixed warnings, tests and bugs * fixed clang warnings * fixed cxxparser tests * added missing checks for valid location in ASTVisitor callbacks for templates * removed warning when statusbar view is removed * made font of activated classes bold * fixed search box not responding to autocompletion tab or enter press * fixed search box not updated when active token changes --- bin/test/data/log/test_log.txt | 38 ++--- src/app/qt/element/QtAutocompletionList.cpp | 7 +- src/app/qt/element/QtSmartSearchBox.cpp | 6 +- src/app/qt/view/QtMainView.cpp | 4 +- src/app/qt/view/graphElements/QtGraphNode.cpp | 6 + src/lib/component/ComponentFactory.cpp | 2 - .../component/controller/GraphController.cpp | 1 + .../component/controller/SearchController.cpp | 18 ++- .../component/controller/SearchController.h | 3 + src/lib/component/view/View.h | 2 - src/lib/data/Storage.cpp | 8 +- src/lib/data/graph/Edge.cpp | 18 ++- src/lib/data/parser/cxx/ASTVisitor.cpp | 144 ++++++++++-------- src/lib/data/parser/cxx/utilityCxx.cpp | 4 +- src/test/CxxParserTestSuite.h | 10 +- 15 files changed, 158 insertions(+), 113 deletions(-) diff --git a/bin/test/data/log/test_log.txt b/bin/test/data/log/test_log.txt index bc9d566a..3e822d83 100644 --- a/bin/test/data/log/test_log.txt +++ b/bin/test/data/log/test_log.txt @@ -1,4 +1,22 @@ ConfigManager.cpp ERROR: value path/to/nowhere is not present in config. +Token.cpp ERROR: Location Id was not referenced by this Token. +Node.cpp WARNING: Cannot change NodeType after it was already set from namespace to class +Edge.cpp ERROR: Nodes are not plain copies. +Storage.cpp INFO: class: A +Storage.cpp INFO: method: A::A +Storage.cpp INFO: global usage: A::A -> A::count +Storage.cpp INFO: method: A::getCount +Storage.cpp INFO: global usage: A::getCount -> A::count +Storage.cpp INFO: method: A::process +Storage.cpp INFO: field: A::count +Storage.cpp INFO: class: B +Storage.cpp INFO: inheritance: B : A +Storage.cpp INFO: method: B::process +Storage.cpp INFO: type usage: B::process -> int +Storage.cpp INFO: function: main +Storage.cpp INFO: type usage: main -> B +Storage.cpp INFO: call: main -> B::B +Storage.cpp INFO: call: main -> A::getCount Storage.cpp INFO: class: A Storage.cpp INFO: method: A::A Storage.cpp INFO: global usage: A::A -> A::count @@ -31,24 +49,6 @@ SearchMatch.cpp INFO: 237 A::A ^^^^ -Storage.cpp INFO: class: A -Storage.cpp INFO: method: A::A -Storage.cpp INFO: global usage: A::A -> A::count -Storage.cpp INFO: method: A::getCount -Storage.cpp INFO: global usage: A::getCount -> A::count -Storage.cpp INFO: method: A::process -Storage.cpp INFO: field: A::count -Storage.cpp INFO: class: B -Storage.cpp INFO: inheritance: B : A -Storage.cpp INFO: method: B::process -Storage.cpp INFO: type usage: B::process -> int -Storage.cpp INFO: function: main -Storage.cpp INFO: type usage: main -> B -Storage.cpp INFO: call: main -> B::B -Storage.cpp INFO: call: main -> A::getCount -Token.cpp ERROR: Location Id was not referenced by this Token. -Node.cpp WARNING: Cannot change NodeType after it was already set from namespace to class -Edge.cpp ERROR: Nodes are not plain copies. Settings.cpp WARNING: File for Settings not found. ConfigManager.cpp ERROR: value Bool is not present in config. ConfigManager.cpp ERROR: value Int is not present in config. @@ -64,7 +64,6 @@ ConfigManager.cpp ERROR: value Int is not present in config. ConfigManager.cpp ERROR: value Float is not present in config. ConfigManager.cpp ERROR: value String is not present in config. ConfigManager.cpp ERROR: value NewBool is not present in config. -Graph.cpp ERROR: Can't remove member edge, without removing the child node. Storage.cpp INFO: typedef: type -> int Storage.cpp INFO: class: Class Storage.cpp INFO: struct: Struct @@ -104,6 +103,7 @@ Storage.cpp INFO: global usage: isTrue -> global Storage.cpp INFO: function: isTrue Storage.cpp INFO: struct: Struct Storage.cpp INFO: type usage: isTrue -> Struct +Graph.cpp ERROR: Can't remove member edge, without removing the child node. TextAccess.cpp WARNING: Index 'firstLine' has to be lower or equal index 'lastLine', is 3 > 2 TextAccess.cpp WARNING: Tried to access index 10. Maximum index is 8 TextAccess.cpp WARNING: Tried to access index 10. Maximum index is 8 diff --git a/src/app/qt/element/QtAutocompletionList.cpp b/src/app/qt/element/QtAutocompletionList.cpp index 66a82d0b..05619934 100644 --- a/src/app/qt/element/QtAutocompletionList.cpp +++ b/src/app/qt/element/QtAutocompletionList.cpp @@ -166,9 +166,6 @@ QtAutocompletionList::QtAutocompletionList(QWidget* parent) setCaseSensitivity(Qt::CaseInsensitive); // setCompletionMode(QCompleter::UnfilteredPopupCompletion); - - connect(this, SIGNAL(highlighted(const QModelIndex&)), this, SLOT(onHighlighted(const QModelIndex&)), Qt::DirectConnection); - connect(this, SIGNAL(activated(const QModelIndex&)), this, SLOT(onActivated(const QModelIndex&)), Qt::DirectConnection); } QtAutocompletionList::~QtAutocompletionList() @@ -202,6 +199,10 @@ void QtAutocompletionList::completeAt(const QPoint& pos, const std::vectorverticalScrollBar()->setValue(list->verticalScrollBar()->minimum()); list->setCurrentIndex(index); // must be set again to avoid flickering + + disconnect(); // must be done because of a bug where signals are no longer received by QtSmartSearchBox + connect(this, SIGNAL(highlighted(const QModelIndex&)), this, SLOT(onHighlighted(const QModelIndex&)), Qt::DirectConnection); + connect(this, SIGNAL(activated(const QModelIndex&)), this, SLOT(onActivated(const QModelIndex&)), Qt::DirectConnection); } const SearchMatch* QtAutocompletionList::getSearchMatchAt(int idx) const diff --git a/src/app/qt/element/QtSmartSearchBox.cpp b/src/app/qt/element/QtSmartSearchBox.cpp index 66841ecd..56a9bc45 100644 --- a/src/app/qt/element/QtSmartSearchBox.cpp +++ b/src/app/qt/element/QtSmartSearchBox.cpp @@ -52,9 +52,6 @@ QtSmartSearchBox::QtSmartSearchBox(QWidget* parent) QCompleter* completer = new QtAutocompletionList(this); setCompleter(completer); - connect(completer, SIGNAL(matchHighlighted(const SearchMatch&)), this, SLOT(onAutocompletionHighlighted(const SearchMatch&)), Qt::DirectConnection); - connect(completer, SIGNAL(matchActivated(const SearchMatch&)), this, SLOT(onAutocompletionActivated(const SearchMatch&)), Qt::DirectConnection); - updatePlaceholder(); } @@ -66,6 +63,9 @@ void QtSmartSearchBox::setAutocompletionList(const std::vector& aut { QtAutocompletionList* completer = dynamic_cast(this->completer()); completer->completeAt(QPoint(textMargins().left() + 3, height() + 3), autocompletionList); + + connect(completer, SIGNAL(matchHighlighted(const SearchMatch&)), this, SLOT(onAutocompletionHighlighted(const SearchMatch&)), Qt::DirectConnection); + connect(completer, SIGNAL(matchActivated(const SearchMatch&)), this, SLOT(onAutocompletionActivated(const SearchMatch&)), Qt::DirectConnection); } void QtSmartSearchBox::setQuery(const std::string& text) diff --git a/src/app/qt/view/QtMainView.cpp b/src/app/qt/view/QtMainView.cpp index 2ace9a9f..405cfcb2 100644 --- a/src/app/qt/view/QtMainView.cpp +++ b/src/app/qt/view/QtMainView.cpp @@ -1,8 +1,9 @@ #include "qt/view/QtMainView.h" -#include "qt/element/QtMainWindow.h" #include "utility/logging/logging.h" +#include "qt/element/QtMainWindow.h" + QtMainView::QtMainView() { m_window = std::make_shared(); @@ -24,7 +25,6 @@ void QtMainView::removeView(View* view) std::vector::iterator it = std::find(m_views.begin(), m_views.end(), view); if (it == m_views.end()) { - LOG_ERROR("View was not found."); return; } diff --git a/src/app/qt/view/graphElements/QtGraphNode.cpp b/src/app/qt/view/graphElements/QtGraphNode.cpp index 60baa7f6..8420007f 100644 --- a/src/app/qt/view/graphElements/QtGraphNode.cpp +++ b/src/app/qt/view/graphElements/QtGraphNode.cpp @@ -28,6 +28,7 @@ QFont QtGraphNode::getFontForNodeType(Node::NodeType type) case Node::NODE_CLASS: case Node::NODE_ENUM: case Node::NODE_TYPEDEF: + case Node::NODE_TEMPLATE_PARAMETER_TYPE: font.setPixelSize(14); break; @@ -284,6 +285,11 @@ void QtGraphNode::setStyle() case Node::NODE_ENUM: case Node::NODE_TYPEDEF: case Node::NODE_TEMPLATE_PARAMETER_TYPE: + if (m_isActive) + { + font.setWeight(QFont::Bold); + } + if (m_isHovering) { m_rect->setShadow(QColor(0, 0, 0, 255), 5); diff --git a/src/lib/component/ComponentFactory.cpp b/src/lib/component/ComponentFactory.cpp index 7d345d31..be93b665 100644 --- a/src/lib/component/ComponentFactory.cpp +++ b/src/lib/component/ComponentFactory.cpp @@ -63,8 +63,6 @@ std::shared_ptr ComponentFactory::createStatusBarComponent() return component; } - - ComponentFactory::ComponentFactory() { } diff --git a/src/lib/component/controller/GraphController.cpp b/src/lib/component/controller/GraphController.cpp index 5ecde805..0e5d0fd3 100644 --- a/src/lib/component/controller/GraphController.cpp +++ b/src/lib/component/controller/GraphController.cpp @@ -356,6 +356,7 @@ GraphController::Margins GraphController::getMarginsForDummyNode(DummyNode& node case Node::NODE_CLASS: case Node::NODE_ENUM: case Node::NODE_TYPEDEF: + case Node::NODE_TEMPLATE_PARAMETER_TYPE: if (node.subNodes.size()) { margins.left = margins.right = 15; diff --git a/src/lib/component/controller/SearchController.cpp b/src/lib/component/controller/SearchController.cpp index 03cc2676..06d9bdaa 100644 --- a/src/lib/component/controller/SearchController.cpp +++ b/src/lib/component/controller/SearchController.cpp @@ -2,7 +2,6 @@ #include "component/view/SearchView.h" #include "data/access/GraphAccess.h" -#include "utility/messaging/type/MessageActivateTokens.h" SearchController::SearchController(GraphAccess* graphAccess) : m_graphAccess(graphAccess) @@ -28,6 +27,15 @@ void SearchController::handleMessage(MessageActivateToken* message) m_ignoreNextMessageActivateToken = false; } +void SearchController::handleMessage(MessageActivateTokens* message) +{ + if (message->tokenIds.size()) + { + MessageActivateToken tokenMessage(message->tokenIds[0]); + handleMessage(&tokenMessage); + } +} + void SearchController::handleMessage(MessageFind* message) { getView()->setFocus(); @@ -47,14 +55,12 @@ void SearchController::handleMessage(MessageSearch* message) m_ignoreNextMessageActivateToken = true; std::vector ids = m_graphAccess->getTokenIdsForQuery(query); - if (ids.size()) + if (!ids.size()) { - MessageActivateTokens(ids).dispatch(); - return; + ids.push_back(m_graphAccess->getIdForNodeWithName(query)); } - Id nodeId = m_graphAccess->getIdForNodeWithName(query); - MessageActivateToken(nodeId).dispatch(); + MessageActivateTokens(ids).dispatch(); } void SearchController::handleMessage(MessageSearchAutocomplete* message) diff --git a/src/lib/component/controller/SearchController.h b/src/lib/component/controller/SearchController.h index 3fc22b3c..52a6c52c 100644 --- a/src/lib/component/controller/SearchController.h +++ b/src/lib/component/controller/SearchController.h @@ -6,6 +6,7 @@ #include "component/controller/Controller.h" #include "utility/messaging/MessageListener.h" #include "utility/messaging/type/MessageActivateToken.h" +#include "utility/messaging/type/MessageActivateTokens.h" #include "utility/messaging/type/MessageFind.h" #include "utility/messaging/type/MessageRefresh.h" #include "utility/messaging/type/MessageSearch.h" @@ -17,6 +18,7 @@ class SearchView; class SearchController : public Controller , public MessageListener + , public MessageListener , public MessageListener , public MessageListener , public MessageListener @@ -28,6 +30,7 @@ public: private: virtual void handleMessage(MessageActivateToken* message); + virtual void handleMessage(MessageActivateTokens* message); virtual void handleMessage(MessageFind* message); virtual void handleMessage(MessageRefresh* message); virtual void handleMessage(MessageSearch* message); diff --git a/src/lib/component/view/View.h b/src/lib/component/view/View.h index 4ad3b0f7..8a280435 100644 --- a/src/lib/component/view/View.h +++ b/src/lib/component/view/View.h @@ -71,8 +71,6 @@ std::shared_ptr View::createAndDontAddToLayout(ViewLayout* viewLayout) ptr->createWidgetWrapper(); ptr->initView(); - //viewLayout->addView(ptr.get()); - return ptr; } diff --git a/src/lib/data/Storage.cpp b/src/lib/data/Storage.cpp index bebef18e..5e27e82a 100644 --- a/src/lib/data/Storage.cpp +++ b/src/lib/data/Storage.cpp @@ -338,7 +338,6 @@ Id Storage::onTemplateRecordParameterTypeParsed( Edge* edge = m_graph.createEdge(Edge::EDGE_TEMPLATE_PARAMETER_OF, templateParameterNode, templateRecordNode); //addTokenLocation(edge, location); - return 0; } @@ -356,6 +355,7 @@ Id Storage::onTemplateRecordSpecializationParsed( Node* specializedRecordNode = addNodeHierarchy(specializedRecordNodeType, specializedRecordNameHierarchy); Node* templateRecordNode = addNodeHierarchy(Node::NODE_UNDEFINED_TYPE, templateRecordNameHierarchy); + Edge* edge = m_graph.createEdge(Edge::EDGE_TEMPLATE_SPECIALIZATION_OF, specializedRecordNode, templateRecordNode); //addTokenLocation(edge, location); @@ -388,6 +388,7 @@ Id Storage::onTemplateFunctionSpecializationParsed( Node* specializedFunctionNode = addNodeHierarchyWithDistinctSignature(Node::NODE_UNDEFINED_FUNCTION, specializedFunction); Node* templateFunctionNode = addNodeHierarchyWithDistinctSignature(Node::NODE_UNDEFINED_FUNCTION, templateFunction); + Edge* edge = m_graph.createEdge(Edge::EDGE_TEMPLATE_SPECIALIZATION_OF, specializedFunctionNode, templateFunctionNode); return 0; @@ -763,6 +764,11 @@ Edge* Storage::addTypeEdge(Node* node, Edge::EdgeType edgeType, const ParseTypeU } Node* typeNode = addNodeHierarchy(Node::NODE_UNDEFINED_TYPE, typeUsage.dataType.getTypeNameHierarchy()); + if (!typeNode) + { + return nullptr; + } + Edge* edge = m_graph.createEdge(edgeType, node, typeNode); addTokenLocation(edge, typeUsage.location); diff --git a/src/lib/data/graph/Edge.cpp b/src/lib/data/graph/Edge.cpp index d8f66d76..0cf2b5a0 100644 --- a/src/lib/data/graph/Edge.cpp +++ b/src/lib/data/graph/Edge.cpp @@ -157,8 +157,8 @@ bool Edge::checkType() const switch (m_type) { case EDGE_MEMBER: - if (!m_from->isType(Node::NODE_UNDEFINED | Node::NODE_CLASS | Node::NODE_STRUCT | Node::NODE_NAMESPACE | Node::NODE_ENUM) || - (m_to->isType(Node::NODE_NAMESPACE) && !m_from->isType(Node::NODE_UNDEFINED | Node::NODE_NAMESPACE)) || + if (!m_from->isType(typeMask | Node::NODE_NAMESPACE) || + (!m_from->isType(Node::NODE_UNDEFINED | Node::NODE_NAMESPACE) && m_to->isType(Node::NODE_NAMESPACE)) || (m_from->isType(Node::NODE_ENUM) && !m_to->isType(Node::NODE_FIELD))) { break; @@ -208,6 +208,20 @@ bool Edge::checkType() const break; } return true; + + case EDGE_TEMPLATE_PARAMETER_OF: + if (!m_from->isType(Node::NODE_TEMPLATE_PARAMETER_TYPE) || !m_to->isType(typeMask | functionMask)) + { + break; + } + return true; + + case EDGE_TEMPLATE_SPECIALIZATION_OF: + if (!m_from->isType(typeMask | functionMask) || !m_to->isType(typeMask | functionMask)) + { + break; + } + return true; } LOG_ERROR_STREAM( diff --git a/src/lib/data/parser/cxx/ASTVisitor.cpp b/src/lib/data/parser/cxx/ASTVisitor.cpp index 30ae5d87..bbfcbd2b 100644 --- a/src/lib/data/parser/cxx/ASTVisitor.cpp +++ b/src/lib/data/parser/cxx/ASTVisitor.cpp @@ -269,98 +269,110 @@ bool ASTVisitor::VisitEnumConstantDecl(clang::EnumConstantDecl* declaration) bool ASTVisitor::VisitClassTemplateDecl(clang::ClassTemplateDecl* declaration) { - std::vector templateRecordNameHierarchy = utility::getDeclNameHierarchy(declaration); - - clang::TemplateParameterList* parameterList = declaration->getTemplateParameters(); - for (int i = 0; i < parameterList->size(); i++) + if (hasValidLocation(declaration)) { - clang::NamedDecl* namedDecl = parameterList->getParam(i); + std::vector templateRecordNameHierarchy = utility::getDeclNameHierarchy(declaration); - if (hasValidLocation(namedDecl)) + clang::TemplateParameterList* parameterList = declaration->getTemplateParameters(); + for (size_t i = 0; i < parameterList->size(); i++) { - std::string templateParameterTypeName = namedDecl->getNameAsString(); + clang::NamedDecl* namedDecl = parameterList->getParam(i); - m_client->onTemplateRecordParameterTypeParsed( - getParseLocationForNamedDecl(namedDecl), - templateParameterTypeName, - templateRecordNameHierarchy + if (hasValidLocation(namedDecl)) + { + std::string templateParameterTypeName = namedDecl->getNameAsString(); + + m_client->onTemplateRecordParameterTypeParsed( + getParseLocationForNamedDecl(namedDecl), + templateParameterTypeName, + templateRecordNameHierarchy + ); + } + } + + for (clang::ClassTemplateDecl::spec_iterator it = declaration->specializations().begin(); // template argument as parameter does not work + it != declaration->specializations().end(); it++ + ) + { + ParserClient::RecordType specializedRecordType = it->isStruct() ? ParserClient::RECORD_STRUCT : ParserClient::RECORD_CLASS; + std::vector specializedRecordNameHierarchy = utility::getDeclNameHierarchy(*(it)); + m_client->onTemplateRecordSpecializationParsed( + getParseLocationForNamedDecl(*it), specializedRecordNameHierarchy, specializedRecordType, templateRecordNameHierarchy ); } } - for (clang::ClassTemplateDecl::spec_iterator it = declaration->specializations().begin(); // template argument as parameter does not work - it != declaration->specializations().end(); it++ - ) - { - ParserClient::RecordType specializedRecordType = it->isStruct() ? ParserClient::RECORD_STRUCT : ParserClient::RECORD_CLASS; - std::vector specializedRecordNameHierarchy = utility::getDeclNameHierarchy(*(it)); - m_client->onTemplateRecordSpecializationParsed( - getParseLocationForNamedDecl(*it), specializedRecordNameHierarchy, specializedRecordType, templateRecordNameHierarchy - ); - } return true; } bool ASTVisitor::VisitClassTemplatePartialSpecializationDecl(clang::ClassTemplatePartialSpecializationDecl* declaration) { - //std::vector templateRecordNameHierarchy = utility::splitToVector( - // declaration->getQualifiedNameAsString(), "::" - //); + if (hasValidLocation(declaration)) + { + //std::vector templateRecordNameHierarchy = utility::splitToVector( + // declaration->getQualifiedNameAsString(), "::" + //); - //clang::ClassTemplateDecl* baseTemplateDecl = declaration->getSpecializedTemplate(); + //clang::ClassTemplateDecl* baseTemplateDecl = declaration->getSpecializedTemplate(); - //std::string specializedParameterNamePart = "<"; - //const clang::TemplateArgumentList& templateArgumentList = declaration->getTemplateArgs(); - //for (int i = 0; i < templateArgumentList.size(); i++) - //{ - // DataType datatype = utility::qualTypeToDataType(templateArgumentList.get(i).getAsType()); - // if (datatype.isTemplateParameterType()) - // { - // specializedParameterNamePart += baseTemplateDecl->getTemplateParameters()->getParam(i)->getNameAsString(); - // } - // else - // { - // specializedParameterNamePart += datatype.getFullTypeName(); - // } - // specializedParameterNamePart += (i < templateArgumentList.size() - 1) ? ", " : ""; - //} - //specializedParameterNamePart += ">"; + //std::string specializedParameterNamePart = "<"; + //const clang::TemplateArgumentList& templateArgumentList = declaration->getTemplateArgs(); + //for (int i = 0; i < templateArgumentList.size(); i++) + //{ + // DataType datatype = utility::qualTypeToDataType(templateArgumentList.get(i).getAsType()); + // if (datatype.isTemplateParameterType()) + // { + // specializedParameterNamePart += baseTemplateDecl->getTemplateParameters()->getParam(i)->getNameAsString(); + // } + // else + // { + // specializedParameterNamePart += datatype.getFullTypeName(); + // } + // specializedParameterNamePart += (i < templateArgumentList.size() - 1) ? ", " : ""; + //} + //specializedParameterNamePart += ">"; - //int foo = 0; + //int foo = 0; + } return true; } bool ASTVisitor::VisitFunctionTemplateDecl(clang::FunctionTemplateDecl *declaration) { - const ParseFunction templateFunction = getParseFunction(declaration->getTemplatedDecl()); - for (clang::FunctionTemplateDecl::spec_iterator it = declaration->specializations().begin(); it != declaration->specializations().end(); it++) + if (hasValidLocation(declaration)) { - ParseLocation specializedFunctionLocation = getParseLocationForNamedDecl(*(it)); - ParseFunction specializedFunction = getParseFunction(*(it)); - m_client->onTemplateFunctionSpecializationParsed( - specializedFunctionLocation, - specializedFunction, - templateFunction); - - m_client->onFunctionParsed(specializedFunctionLocation, specializedFunction, getParseLocationOfFunctionBody(*(it))); - } - clang::TemplateParameterList* parameterList = declaration->getTemplateParameters(); - for (int i = 0; i < parameterList->size(); i++) - { - clang::NamedDecl* namedDecl = parameterList->getParam(i); - - if (hasValidLocation(namedDecl)) + const ParseFunction templateFunction = getParseFunction(declaration->getTemplatedDecl()); + for (clang::FunctionTemplateDecl::spec_iterator it = declaration->specializations().begin(); it != declaration->specializations().end(); it++) { - std::string templateParameterTypeName = namedDecl->getNameAsString(); + ParseLocation specializedFunctionLocation = getParseLocationForNamedDecl(*(it)); + ParseFunction specializedFunction = getParseFunction(*(it)); + m_client->onTemplateFunctionSpecializationParsed( + specializedFunctionLocation, + specializedFunction, + templateFunction); - m_client->onTemplateFunctionParameterTypeParsed( - getParseLocationForNamedDecl(namedDecl), - templateParameterTypeName, - templateFunction - ); + m_client->onFunctionParsed(specializedFunctionLocation, specializedFunction, getParseLocationOfFunctionBody(*(it))); + } + + clang::TemplateParameterList* parameterList = declaration->getTemplateParameters(); + for (size_t i = 0; i < parameterList->size(); i++) + { + clang::NamedDecl* namedDecl = parameterList->getParam(i); + + if (hasValidLocation(namedDecl)) + { + std::string templateParameterTypeName = namedDecl->getNameAsString(); + + m_client->onTemplateFunctionParameterTypeParsed( + getParseLocationForNamedDecl(namedDecl), + templateParameterTypeName, + templateFunction + ); + } } } + return true; } @@ -600,7 +612,7 @@ std::vector ASTVisitor::getParameters(clang::FunctionDecl* decla ParseVariable ASTVisitor::getParseVariable(clang::DeclaratorDecl* declaration) const { - bool isStatic; + bool isStatic = false; std::vector hameHierarchy = utility::getDeclNameHierarchy(declaration); if (clang::isa(declaration)) { diff --git a/src/lib/data/parser/cxx/utilityCxx.cpp b/src/lib/data/parser/cxx/utilityCxx.cpp index 9e24d24c..e4fd956f 100644 --- a/src/lib/data/parser/cxx/utilityCxx.cpp +++ b/src/lib/data/parser/cxx/utilityCxx.cpp @@ -152,7 +152,7 @@ namespace utility { std::string specializedParameterNamePart = "<"; const clang::TemplateArgumentList& templateArgumentList = clang::dyn_cast(declaration)->getTemplateArgs(); - for (int i = 0; i < templateArgumentList.size(); i++) + for (size_t i = 0; i < templateArgumentList.size(); i++) { DataType datatype = utility::qualTypeToDataType(templateArgumentList.get(i).getAsType()); specializedParameterNamePart += datatype.getFullTypeName(); @@ -166,7 +166,7 @@ namespace utility { std::string templateParameterNamePart = "<"; clang::TemplateParameterList* parameterList = clang::dyn_cast(declaration)->getTemplateParameters(); - for (int i = 0; i < parameterList->size(); i++) + for (size_t i = 0; i < parameterList->size(); i++) { clang::NamedDecl* namedDecl = parameterList->getParam(i); diff --git a/src/test/CxxParserTestSuite.h b/src/test/CxxParserTestSuite.h index ba535b6f..8989e3dc 100644 --- a/src/test/CxxParserTestSuite.h +++ b/src/test/CxxParserTestSuite.h @@ -1057,7 +1057,7 @@ public: " T foo;\n" "};\n" "\n" - "A a\n" + "A a;\n" ); TS_ASSERT_EQUALS(client->templateSpecializations.size(), 1); @@ -1122,9 +1122,9 @@ public: "template \n" "class A\n" "{\n" - " Enum TestType\n" + " enum TestType\n" " {\n" - " TEST_ONE\n" + " TEST_ONE,\n" " TEST_TWO\n" " };\n" "};\n" @@ -1140,7 +1140,7 @@ public: "template \n" "class A\n" "{\n" - " Enum TestType\n" + " enum TestType\n" " {\n" " TEST_ONE,\n" " TEST_TWO\n" @@ -1159,7 +1159,7 @@ public: "template \n" "class A\n" "{\n" - " Enum TestType\n" + " enum TestType\n" " {\n" " TEST_ONE,\n" " TEST_TWO\n"