From e3696df5e1b20431bfec5de53943425a60971669 Mon Sep 17 00:00:00 2001 From: Andreas Stallinger Date: Mon, 28 Sep 2015 15:25:52 +0200 Subject: [PATCH] data: Macro handling Macros have now edges from Files where they are usesd --- CMakeLists.txt | 55 +--------------- bin/app/data/color_schemes/bright.xml | 8 +++ bin/app/data/color_schemes/dark.xml | 8 +++ cmake/LinuxPackage.cmake | 53 +++++++++++++++ src/lib/Project.cpp | 1 + src/lib/component/view/GraphViewStyle.cpp | 3 + src/lib/data/Storage.cpp | 36 +++++++++++ src/lib/data/Storage.h | 3 + src/lib/data/graph/Edge.cpp | 11 ++++ src/lib/data/graph/Edge.h | 3 +- src/lib/data/graph/Node.cpp | 6 ++ src/lib/data/graph/Node.h | 3 +- src/lib/data/parser/ParserClient.h | 9 +++ src/lib/data/parser/cxx/ASTVisitor.h | 10 +-- .../data/parser/cxx/PreprocessorCallbacks.cpp | 55 ++++++++++++++++ .../data/parser/cxx/PreprocessorCallbacks.h | 11 ++++ src/lib/utility/file/FileSystem.cpp | 1 + src/lib/utility/file/FileSystem.h | 1 + src/test/CxxParserTestSuite.h | 64 ++++++++++++++++--- 19 files changed, 272 insertions(+), 69 deletions(-) create mode 100644 cmake/LinuxPackage.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index c51147fd..1f534651 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -338,58 +338,5 @@ endif () # Linux package if(UNIX AND NOT APPLE) - execute_process( - COMMAND ${CMAKE_SOURCE_DIR}/setup/Linux/findAndCopyLibraries.sh - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - ) - - INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/bin/app/data - DESTINATION share/coati/.config/coati - PATTERN "log/*" EXCLUDE - PATTERN "projects/*" EXCLUDE - ) - INSTALL(FILES ${CMAKE_SOURCE_DIR}/setup/Linux/coati.desktop - DESTINATION share/applications - ) - INSTALL(FILES ${CMAKE_SOURCE_DIR}/bin/app/data/gui/icon/logo_1024_1024.png - DESTINATION share/icons - RENAME coati.png) - INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/setup/Linux/lib - DESTINATION share/coati - ) - INSTALL(FILES - ${CMAKE_SOURCE_DIR}/setup/Linux/libqxcb.so - DESTINATION share/coati/platforms - ) - INSTALL(PROGRAMS - ${CMAKE_SOURCE_DIR}/setup/Linux/Coati.sh - DESTINATION share/coati - ) - INSTALL(PROGRAMS ${CMAKE_SOURCE_DIR}/setup/Linux/coati - DESTINATION bin/ - ) - # add the automatically determined parts of the RPATH - # which point to directories outside the build tree to the install RPATH - SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - - INSTALL(TARGETS ${APP_PROJECT_NAME} - DESTINATION share/coati - ) - - SET(CPACK_GENERATOR "DEB;TGZ") - SET(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") - - # DEBIAN PACKAGE - SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Andreas Stallinger ") - SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") - SET(CPACK_PACKAGE_NAME "Coati") - SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://coati.io") - SET(CPACK_DEBIAN_PACKAGE_SECTION "devel") - SET(CPACK_PACKAGING_INSTALL_PREFIX "/usr/local") - SET(CPACK_PACKAGE_VERSION ${GIT_VERSION_NUMBER}) - SET(CPACK_PACKAGE_EXECUTABLES "Coati") - SET(CPACK_STRIP_FILES "share/coati/Coati") - - INCLUDE(CPack) - + include(cmake/LinuxPackage.cmake) endif () diff --git a/bin/app/data/color_schemes/bright.xml b/bin/app/data/color_schemes/bright.xml index c01bc606..92ede209 100644 --- a/bin/app/data/color_schemes/bright.xml +++ b/bin/app/data/color_schemes/bright.xml @@ -179,6 +179,10 @@ #DDD #CCC + + #DDD + #CCC + @@ -247,6 +251,10 @@ #EEE #DDD + + #878787 + #878787 + diff --git a/bin/app/data/color_schemes/dark.xml b/bin/app/data/color_schemes/dark.xml index ebd06370..52a1f74e 100644 --- a/bin/app/data/color_schemes/dark.xml +++ b/bin/app/data/color_schemes/dark.xml @@ -179,6 +179,10 @@ #1B564E #247368 + + #1B564E + #247368 + @@ -247,6 +251,10 @@ #5D5D5D #6D6D6D + + #247368 + #247368 + diff --git a/cmake/LinuxPackage.cmake b/cmake/LinuxPackage.cmake new file mode 100644 index 00000000..fa0f5d81 --- /dev/null +++ b/cmake/LinuxPackage.cmake @@ -0,0 +1,53 @@ +# execute_process( +# COMMAND ${CMAKE_SOURCE_DIR}/setup/Linux/findAndCopyLibraries.sh +# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} +# ) + +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/bin/app/data + DESTINATION share/coati/.config/coati + PATTERN "log/*" EXCLUDE + PATTERN "projects/*" EXCLUDE +) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/setup/Linux/coati.desktop + DESTINATION share/applications +) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/bin/app/data/gui/icon/logo_1024_1024.png + DESTINATION share/icons + RENAME coati.png) +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/setup/Linux/lib + DESTINATION share/coati +) +INSTALL(FILES + ${CMAKE_SOURCE_DIR}/setup/Linux/libqxcb.so + DESTINATION share/coati/platforms +) +INSTALL(PROGRAMS + ${CMAKE_SOURCE_DIR}/setup/Linux/Coati.sh + DESTINATION share/coati +) +INSTALL(PROGRAMS ${CMAKE_SOURCE_DIR}/setup/Linux/coati + DESTINATION bin/ +) +# add the automatically determined parts of the RPATH +# which point to directories outside the build tree to the install RPATH +SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + +INSTALL(TARGETS ${APP_PROJECT_NAME} + DESTINATION share/coati +) + +SET(CPACK_GENERATOR "DEB;TGZ") +SET(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") + +# DEBIAN PACKAGE +SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Andreas Stallinger ") +SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") +SET(CPACK_PACKAGE_NAME "Coati") +SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://coati.io") +SET(CPACK_DEBIAN_PACKAGE_SECTION "devel") +SET(CPACK_PACKAGING_INSTALL_PREFIX "/usr/local") +SET(CPACK_PACKAGE_VERSION ${GIT_VERSION_NUMBER}) +SET(CPACK_PACKAGE_EXECUTABLES "Coati") +SET(CPACK_STRIP_FILES "share/coati/Coati") + +INCLUDE(CPack) diff --git a/src/lib/Project.cpp b/src/lib/Project.cpp index d36ff31d..79972daa 100644 --- a/src/lib/Project.cpp +++ b/src/lib/Project.cpp @@ -169,6 +169,7 @@ Parser::Arguments Project::getParserArguments() const // utility::append(args.systemHeaderSearchPaths, headerSearchSubPaths); utility::append(args.systemHeaderSearchPaths, projSettings->getHeaderSearchPaths()); + utility::append(args.systemHeaderSearchPaths, appSettings->getHeaderSearchPaths()); utility::append(args.frameworkSearchPaths, projSettings->getFrameworkSearchPaths()); diff --git a/src/lib/component/view/GraphViewStyle.cpp b/src/lib/component/view/GraphViewStyle.cpp index 91e59768..c64c2d32 100644 --- a/src/lib/component/view/GraphViewStyle.cpp +++ b/src/lib/component/view/GraphViewStyle.cpp @@ -111,6 +111,7 @@ size_t GraphViewStyle::getFontSizeForNodeType(Node::NodeType type) case Node::NODE_TYPEDEF: case Node::NODE_TEMPLATE_PARAMETER_TYPE: case Node::NODE_FILE: + case Node::NODE_MACRO: return s_fontSize; case Node::NODE_UNDEFINED_FUNCTION: @@ -197,6 +198,7 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsForNodeType(Node::NodeType case Node::NODE_GLOBAL_VARIABLE: case Node::NODE_FIELD: case Node::NODE_ENUM_CONSTANT: + case Node::NODE_MACRO: margins.left = margins.right = 5; margins.top = margins.bottom = 3; break; @@ -352,6 +354,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType( case Node::NODE_GLOBAL_VARIABLE: case Node::NODE_FIELD: case Node::NODE_ENUM_CONSTANT: + case Node::NODE_MACRO: if (isActive || isFocused) { style.fontBold = true; diff --git a/src/lib/data/Storage.cpp b/src/lib/data/Storage.cpp index 20d8c5ff..286a7502 100644 --- a/src/lib/data/Storage.cpp +++ b/src/lib/data/Storage.cpp @@ -664,6 +664,42 @@ Id Storage::onFileIncludeParsed(const ParseLocation& location, const FileInfo& f return fileNodeId; } +Id Storage::onMacroDefineParsed(const ParseLocation &location, const NameHierarchy& macroNameHierarchy) { + + Id macroId = 0; + + Id fileId = m_sqliteStorage.getFileByName(location.filePath.fileName()).id; + if(fileId != 0) + { + macroId = addNodeHierarchy(Node::NODE_MACRO, macroNameHierarchy); + addSourceLocation(macroId, location); + } + else + { + //TODO: What to do with this ones? + //LOG_ERROR("External MacroDefined :" + macroNameHierarchy.getFullName()); + } + + return macroId; +} + +Id Storage::onMacroExpandParsed(const ParseLocation &location, const NameHierarchy& macroNameHierarchy) { + Id macroExpandId = addNodeHierarchy(Node::NODE_UNDEFINED, macroNameHierarchy); + Id fileId = m_sqliteStorage.getFileByName(location.filePath.fileName()).id; + + if(fileId != 0) + { + addEdge(fileId, macroExpandId,Edge::EDGE_MACRO_USAGE, location); + } + else + { + //TODO: What to do with this ones? + //LOG_ERROR("External MacroExpand :" + macroNameHierarchy.getFullName()); + } + + return 0; +} + Id Storage::getIdForNodeWithName(const std::string& fullName) const // use name hierarchy here { std::vector nameParts = utility::splitToVector(fullName, "::"); diff --git a/src/lib/data/Storage.h b/src/lib/data/Storage.h index 4b5a991b..b129693d 100644 --- a/src/lib/data/Storage.h +++ b/src/lib/data/Storage.h @@ -119,6 +119,9 @@ public: virtual Id onFileIncludeParsed( const ParseLocation& location, const FileInfo& fileInfo, const FileInfo& includedFileInfo); + virtual Id onMacroDefineParsed(const ParseLocation& location, const NameHierarchy& macroNameHierarchy); + virtual Id onMacroExpandParsed(const ParseLocation& location, const NameHierarchy& macroNameHierarchy); + // StorageAccess implementation virtual Id getIdForNodeWithName(const std::string& fullName) const; virtual Id getIdForEdgeWithName(const std::string& name) const; diff --git a/src/lib/data/graph/Edge.cpp b/src/lib/data/graph/Edge.cpp index 33d3002a..c8933c67 100644 --- a/src/lib/data/graph/Edge.cpp +++ b/src/lib/data/graph/Edge.cpp @@ -49,6 +49,8 @@ Edge::EdgeType Edge::intToType(int value) return EDGE_INCLUDE; case 0x8000: return EDGE_AGGREGATION; + case 0x10000: + return EDGE_MACRO_USAGE; } return EDGE_NONE; @@ -214,7 +216,10 @@ std::string Edge::getTypeString(EdgeType type) return "include"; case EDGE_AGGREGATION: return "aggregation"; + case EDGE_MACRO_USAGE: + return "macro_use"; } + return ""; } @@ -358,6 +363,12 @@ bool Edge::checkType() const break; } return true; + case EDGE_MACRO_USAGE: + if(!m_to->isType(Node::NODE_MACRO) || !m_from->isType(Node::NODE_FILE)) + { + break; + } + return true; } LOG_ERROR_STREAM( diff --git a/src/lib/data/graph/Edge.h b/src/lib/data/graph/Edge.h index ca4380f3..46eae516 100644 --- a/src/lib/data/graph/Edge.h +++ b/src/lib/data/graph/Edge.h @@ -36,7 +36,8 @@ public: EDGE_INCLUDE = 0x4000, - EDGE_AGGREGATION = 0x8000 + EDGE_AGGREGATION = 0x8000, + EDGE_MACRO_USAGE = 0x10000, }; static int typeToInt(EdgeType type); diff --git a/src/lib/data/graph/Node.cpp b/src/lib/data/graph/Node.cpp index 9d884f71..81dba72d 100644 --- a/src/lib/data/graph/Node.cpp +++ b/src/lib/data/graph/Node.cpp @@ -47,7 +47,10 @@ std::string Node::getTypeString(NodeType type) return "template_parameter_type"; case NODE_FILE: return "file"; + case NODE_MACRO: + return "macro"; } + return ""; } @@ -92,7 +95,10 @@ Node::NodeType Node::intToType(int value) return NODE_TEMPLATE_PARAMETER_TYPE; case 0x8000: return NODE_FILE; + case 0x10000: + return NODE_MACRO; } + return NODE_UNDEFINED; } diff --git a/src/lib/data/graph/Node.h b/src/lib/data/graph/Node.h index cfaa16f6..b34469b2 100644 --- a/src/lib/data/graph/Node.h +++ b/src/lib/data/graph/Node.h @@ -40,7 +40,8 @@ public: NODE_TYPEDEF = 0x2000, NODE_TEMPLATE_PARAMETER_TYPE = 0x4000, - NODE_FILE = 0x8000 + NODE_FILE = 0x8000, + NODE_MACRO = 0x10000, }; static std::string getTypeString(NodeType type); diff --git a/src/lib/data/parser/ParserClient.h b/src/lib/data/parser/ParserClient.h index 2c7ee34b..2916c157 100644 --- a/src/lib/data/parser/ParserClient.h +++ b/src/lib/data/parser/ParserClient.h @@ -6,8 +6,12 @@ #include "utility/types.h" #include "data/name/NameHierarchy.h" + #include "utility/file/FileInfo.h" +#include "ParseLocation.h" + + struct ParseFunction; struct ParseLocation; struct ParseTypeUsage; @@ -132,6 +136,11 @@ public: virtual Id onFileParsed(const FileInfo& fileInfo) = 0; virtual Id onFileIncludeParsed( const ParseLocation& location, const FileInfo& fileInfo, const FileInfo& includedFileInfo) = 0; + + + virtual Id onMacroDefineParsed(const ParseLocation& location, const NameHierarchy& macroNameHierarchy) = 0; + virtual Id onMacroExpandParsed( + const ParseLocation& location, const NameHierarchy& macroNameHierarchy) = 0; }; #endif // PARSER_CLIENT_H diff --git a/src/lib/data/parser/cxx/ASTVisitor.h b/src/lib/data/parser/cxx/ASTVisitor.h index 25c0e6d8..44e2ba49 100644 --- a/src/lib/data/parser/cxx/ASTVisitor.h +++ b/src/lib/data/parser/cxx/ASTVisitor.h @@ -18,11 +18,11 @@ public: virtual ~ASTVisitor(); // Left for debugging purposes. Uncomment to see a colored ast-dump of the parsed file. - // virtual bool VisitTranslationUnitDecl(clang::TranslationUnitDecl* decl) - // { - // decl->dump(); - // return true; - // } +// virtual bool VisitTranslationUnitDecl(clang::TranslationUnitDecl* decl) +// { +// decl->dump(); +// return true; +// } // RecursiveASTVisitor implementation virtual bool VisitStmt(const clang::Stmt* statement); // avoid visiting diff --git a/src/lib/data/parser/cxx/PreprocessorCallbacks.cpp b/src/lib/data/parser/cxx/PreprocessorCallbacks.cpp index 9466d858..9f84e186 100644 --- a/src/lib/data/parser/cxx/PreprocessorCallbacks.cpp +++ b/src/lib/data/parser/cxx/PreprocessorCallbacks.cpp @@ -1,5 +1,10 @@ #include "data/parser/cxx/PreprocessorCallbacks.h" + +#include "clang/Driver/Util.h" +#include "clang/Basic/IdentifierTable.h" +#include "clang/Lex/MacroArgs.h" + #include "utility/file/FileManager.h" #include "utility/file/FileRegister.h" @@ -62,6 +67,56 @@ void PreprocessorCallbacks::InclusionDirective( } } +void PreprocessorCallbacks::MacroDefined( const clang::Token &MacroNameTok, const clang::MacroDirective *MD) +{ + // ignore builtin macros + if(m_sourceManager.getSpellingLoc(MacroNameTok.getLocation()).printToString(m_sourceManager)[0] == '<') + { + return; + } + m_sourceManager.getSpellingLoc(MacroNameTok.getLocation()).dump(m_sourceManager); + + NameHierarchy nameHierarchy; + nameHierarchy.push(std::make_shared(MacroNameTok.getIdentifierInfo()->getName().str())); + m_client->onMacroDefineParsed( getParseLocation(MacroNameTok), nameHierarchy); +} + +void PreprocessorCallbacks::MacroExpands( + const clang::Token &MacroNameTok, const clang::MacroDefinition &MD, + clang::SourceRange Range, const clang::MacroArgs *Args +){ + NameHierarchy nameHierarchy; + nameHierarchy.push(std::make_shared(MacroNameTok.getIdentifierInfo()->getName().str())); + + m_client->onMacroExpandParsed( getParseLocation(MacroNameTok), nameHierarchy); +} + +ParseLocation PreprocessorCallbacks::getParseLocation(const clang::Token &MacroNameTok) const +{ + clang::SourceLocation location = MacroNameTok.getLocation(); + return ParseLocation( + m_sourceManager.getFilename(location), + m_sourceManager.getSpellingLineNumber(location), + m_sourceManager.getSpellingColumnNumber(location), + m_sourceManager.getSpellingLineNumber(MacroNameTok.getEndLoc()), + m_sourceManager.getSpellingColumnNumber(MacroNameTok.getEndLoc()) - 1 + ); +} + +ParseLocation PreprocessorCallbacks::getParseLocation(clang::MacroInfo *macroInfo) const +{ + clang::SourceLocation location = macroInfo->getDefinitionLoc(); + clang::SourceLocation endLocation = macroInfo->getDefinitionEndLoc(); + + return ParseLocation( + m_sourceManager.getFilename(location), + m_sourceManager.getSpellingLineNumber(location), + m_sourceManager.getSpellingColumnNumber(location), + m_sourceManager.getSpellingLineNumber(endLocation), + m_sourceManager.getSpellingColumnNumber(endLocation) - 1 + ); +} + ParseLocation PreprocessorCallbacks::getParseLocation(const clang::SourceRange& sourceRange) const { if (sourceRange.isInvalid()) diff --git a/src/lib/data/parser/cxx/PreprocessorCallbacks.h b/src/lib/data/parser/cxx/PreprocessorCallbacks.h index 4e0aed61..f20cac24 100644 --- a/src/lib/data/parser/cxx/PreprocessorCallbacks.h +++ b/src/lib/data/parser/cxx/PreprocessorCallbacks.h @@ -2,7 +2,9 @@ #define PREPROCESSOR_CALLBACKS_H #include "clang/Basic/SourceManager.h" +#include "clang/Lex/MacroInfo.h" #include "clang/Lex/PPCallbacks.h" +#include "clang/Lex/Token.h" class FileRegister; class ParserClient; @@ -22,8 +24,17 @@ public: clang::CharSourceRange fileNameRange, const clang::FileEntry* fileEntry, llvm::StringRef searchPath, llvm::StringRef relativePath, const clang::Module* imported); + virtual void MacroDefined(const clang::Token &MacroNameTok, const clang::MacroDirective *MD ); + + virtual void MacroExpands( + const clang::Token &MacroNameTok, const clang::MacroDefinition &MD, + clang::SourceRange Range, const clang::MacroArgs *Args + ); + private: ParseLocation getParseLocation(const clang::SourceRange& sourceRange) const; + ParseLocation getParseLocation(const clang::Token& MacroNameToc) const; + ParseLocation getParseLocation(clang::MacroInfo *MacroNameToc) const; const clang::SourceManager& m_sourceManager; ParserClient* m_client; diff --git a/src/lib/utility/file/FileSystem.cpp b/src/lib/utility/file/FileSystem.cpp index e3c07d79..c47601ba 100644 --- a/src/lib/utility/file/FileSystem.cpp +++ b/src/lib/utility/file/FileSystem.cpp @@ -63,6 +63,7 @@ FileInfo FileSystem::getFileInfoForPath(FilePath filePath) return FileInfo(); } + std::vector FileSystem::getFileInfosFromPaths( const std::vector& paths, const std::vector& fileExtensions ){ diff --git a/src/lib/utility/file/FileSystem.h b/src/lib/utility/file/FileSystem.h index 968d3307..8df7936f 100644 --- a/src/lib/utility/file/FileSystem.h +++ b/src/lib/utility/file/FileSystem.h @@ -20,6 +20,7 @@ public: const std::vector& paths, const std::vector& fileExtensions); static std::string getTimeStringNow(); + static std::vector getSubDirectories(const FilePath& path); static bool exists(const std::string& path); diff --git a/src/test/CxxParserTestSuite.h b/src/test/CxxParserTestSuite.h index b5aac793..1da324d7 100644 --- a/src/test/CxxParserTestSuite.h +++ b/src/test/CxxParserTestSuite.h @@ -1201,6 +1201,30 @@ public: TS_ASSERT_EQUALS(client->typeUses[3], "int main() -> A <9:16 9:16>"); } + void test_cxx_parser_finds_macro_define() + { + std::shared_ptr client = parseCode( + "#define PI\n" + "void test()\n" + "{\n" + "};\n" + ); + TS_ASSERT_EQUALS(client->macros.size(),1); + TS_ASSERT_EQUALS(client->macros[0], "PI <1:9 1:10>"); + } + + void test_cxx_parser_finds_macro_expand() + { + std::shared_ptr client = parseCode( + "#define PI 3.14159265359\n" + "void test()\n" + "{\n" + "double i = PI;" + "};\n" + ); + TS_ASSERT_EQUALS(client->macroUses.size(),1); + TS_ASSERT_EQUALS(client->macroUses[0], "PI <4:12 4:13>"); + } void test_cxx_parser_finds_type_template_parameter_type_of_template_class() { @@ -2380,19 +2404,21 @@ public: void test_cxx_parser_finds_template_template_default_argument_type_of_template_function() { std::shared_ptr client = parseCode( - "template \n" - "class A\n" - "{};\n" - "template class T = A>\n" - "void test()\n" - "{\n" - "};\n" + "template \n" + "class A\n" + "{};\n" + "template class T = A>\n" + "void test()\n" + "{\n" + "};\n" ); TS_ASSERT_EQUALS(client->templateDefaultArgumentTypes.size(), 1); - TS_ASSERT_EQUALS(client->templateDefaultArgumentTypes[0], "A -> test typename T>::T <4:40 4:40>"); + TS_ASSERT_EQUALS(client->templateDefaultArgumentTypes[0], + "A -> test typename T>::T <4:40 4:40>"); } + void test_cxx_parser_parses_multiple_files() { TestFileManager fm; @@ -2615,6 +2641,13 @@ private: return 0; } + virtual Id onFieldUsageParsed( + const ParseLocation& location, const ParseVariable& user, const NameHierarchy& usedNameHierarchy) + { + usages.push_back(addLocationSuffix(variableStr(user) + " -> " + usedNameHierarchy.getFullName(), location)); + return 0; + } + virtual Id onGlobalVariableUsageParsed( const ParseLocation& location, const ParseFunction& user, const NameHierarchy& usedNameHierarchy) { @@ -2727,6 +2760,19 @@ private: return 0; } + virtual Id onMacroDefineParsed(const ParseLocation& location, const NameHierarchy& macroNameHierarchy) + { + macros.push_back(addLocationSuffix(macroNameHierarchy.getFullName() ,location)); + return 0; + } + + virtual Id onMacroExpandParsed(const ParseLocation& location, const NameHierarchy& macroNameHierarchy) + { + macroUses.push_back(addLocationSuffix(macroNameHierarchy.getFullName() ,location)); + return 0; + } + + std::vector errors; std::vector typedefs; @@ -2739,12 +2785,14 @@ private: std::vector methods; std::vector namespaces; std::vector structs; + std::vector macros; std::vector inheritances; std::vector overrides; std::vector calls; std::vector usages; // for variables std::vector typeUses; // for types + std::vector macroUses; std::vector templateParameterTypes; std::vector templateArgumentTypes; std::vector templateDefaultArgumentTypes;