diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1f534651..6fb8e9a7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -54,7 +54,11 @@ if(UNIX AND NOT APPLE)
find_package(LLVM REQUIRED PATHS "$ENV{CLANG_DIR}/build_debug/share/llvm/cmake")
endif()
else()
- find_package(LLVM REQUIRED PATHS "$ENV{CLANG_DIR}/build/share/llvm/cmake")
+ if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
+ find_package(LLVM REQUIRED PATHS "$ENV{CLANG_DIR}/build_release/share/llvm/cmake")
+ else()
+ find_package(LLVM REQUIRED PATHS "$ENV{CLANG_DIR}/build/share/llvm/cmake")
+ endif()
endif()
find_package(CLANG REQUIRED PATHS "${CMAKE_SOURCE_DIR}/cmake")
diff --git a/README.md b/README.md
index be3acf60..9002adab 100644
--- a/README.md
+++ b/README.md
@@ -27,3 +27,25 @@ For Win32:
Run setup script:
$ ./script/setup.sh
+
+##### Updating Clang on UNIX
+
+$ cd .../clang_llvm
+
+$ cd llvm
+$ git pull origin master
+
+$ cd tools/clang
+$ git pull origin master
+
+$ cd tools/extra/
+$ git pull origin master
+
+$ cd ../../../../../build
+$ cmake -G Ninja ../llvm
+$ ninja -j 4 check-all
+
+$ cd ../release_build
+$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ../llvm
+$ ninja -j 4 clang
+
diff --git a/bin/app/data/color_schemes/bright.xml b/bin/app/data/color_schemes/bright.xml
index 92ede209..45bafba2 100644
--- a/bin/app/data/color_schemes/bright.xml
+++ b/bin/app/data/color_schemes/bright.xml
@@ -179,6 +179,11 @@
#DDD
#CCC
+
+
+ #DDD
+ #CCC
+
#DDD
#CCC
diff --git a/bin/app/data/color_schemes/dark.xml b/bin/app/data/color_schemes/dark.xml
index 52a1f74e..76a7c5b8 100644
--- a/bin/app/data/color_schemes/dark.xml
+++ b/bin/app/data/color_schemes/dark.xml
@@ -179,6 +179,11 @@
#1B564E
#247368
+
+
+ #1B564E
+ #247368
+
#1B564E
#247368
diff --git a/cmake/CLANGConfig.cmake b/cmake/CLANGConfig.cmake
index ea3260c5..428e2c63 100644
--- a/cmake/CLANGConfig.cmake
+++ b/cmake/CLANGConfig.cmake
@@ -1,11 +1,10 @@
-if(UNIX AND NOT APPLE)
+if (UNIX AND NOT APPLE)
execute_process(
COMMAND $ENV{CLANG_DIR}/build_debug/bin/llvm-config --cxxflags
OUTPUT_VARIABLE CLANG_DEFINITIONS
)
-
set(CLANG_INCLUDE_DIRS
"$ENV{CLANG_DIR}/llvm/tools/clang/include"
"$ENV{CLANG_DIR}/build_debug/tools/clang/include"
@@ -25,15 +24,19 @@ else()
OUTPUT_VARIABLE CLANG_DEFINITIONS
)
+ # Remove unwanted flags
+ string(REPLACE "-fno-exceptions" "" CLANG_DEFINITIONS ${CLANG_DEFINITIONS})
+ string(REPLACE "-fno-rtti" "" CLANG_DEFINITIONS ${CLANG_DEFINITIONS})
+
set(CLANG_INCLUDE_DIRS
"$ENV{CLANG_DIR}/llvm/tools/clang/include"
"$ENV{CLANG_DIR}/build/tools/clang/include"
)
- set(CLANG_LIBRARY_DIRS "$ENV{CLANG_DIR}/build_debug/lib")
+ set(CLANG_LIBRARY_DIRS "$ENV{CLANG_DIR}/build/lib")
if (UNIX)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
- set(CLANG_LIBRARY_DIRS "$ENV{CLANG_DIR}/build/Release+Asserts/lib")
+ set(CLANG_LIBRARY_DIRS "$ENV{CLANG_DIR}/build_release/lib")
endif()
endif ()
diff --git a/src/lib/component/view/GraphViewStyle.cpp b/src/lib/component/view/GraphViewStyle.cpp
index c64c2d32..9cef5ffb 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_UNDEFINED_MACRO:
case Node::NODE_MACRO:
return s_fontSize;
@@ -198,6 +199,7 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsForNodeType(Node::NodeType
case Node::NODE_GLOBAL_VARIABLE:
case Node::NODE_FIELD:
case Node::NODE_ENUM_CONSTANT:
+ case Node::NODE_UNDEFINED_MACRO:
case Node::NODE_MACRO:
margins.left = margins.right = 5;
margins.top = margins.bottom = 3;
@@ -347,6 +349,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
case Node::NODE_UNDEFINED_FUNCTION:
case Node::NODE_UNDEFINED_VARIABLE:
+ case Node::NODE_UNDEFINED_MACRO:
style.hatchingColor = scheme->getColor("graph/hatching");
case Node::NODE_FUNCTION:
diff --git a/src/lib/data/Storage.cpp b/src/lib/data/Storage.cpp
index 286a7502..ab1ec26b 100644
--- a/src/lib/data/Storage.cpp
+++ b/src/lib/data/Storage.cpp
@@ -664,40 +664,28 @@ Id Storage::onFileIncludeParsed(const ParseLocation& location, const FileInfo& f
return fileNodeId;
}
-Id Storage::onMacroDefineParsed(const ParseLocation &location, const NameHierarchy& macroNameHierarchy) {
+Id Storage::onMacroDefineParsed(const ParseLocation& location, const NameHierarchy& macroNameHierarchy)
+{
+ log("macro", macroNameHierarchy.getFullName(), location);
- Id macroId = 0;
+ Id macroId = addNodeHierarchy(Node::NODE_MACRO, macroNameHierarchy);
+ addSourceLocation(macroId, location);
- 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());
- }
+ Id fileNodeId = getFileNodeId(location.filePath);
+ addEdge(fileNodeId, macroId, Edge::EDGE_MACRO_USAGE, location);
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;
+Id Storage::onMacroExpandParsed(const ParseLocation &location, const NameHierarchy& macroNameHierarchy)
+{
+ log("macro use", macroNameHierarchy.getFullName(), location);
- 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());
- }
+ Id macroExpandId = addNodeHierarchy(Node::NODE_UNDEFINED_MACRO, macroNameHierarchy);
+ Id fileNodeId = getFileNodeId(location.filePath);
+ Id edgeId = addEdge(fileNodeId, macroExpandId, Edge::EDGE_MACRO_USAGE, location);
- return 0;
+ return edgeId;
}
Id Storage::getIdForNodeWithName(const std::string& fullName) const // use name hierarchy here
@@ -876,6 +864,10 @@ std::vector Storage::getActiveTokenIdsForTokenIds(const std::vector& tok
}
}
+ std::set idSet(activeIds.begin(), activeIds.end());
+ activeIds.clear();
+ activeIds.insert(activeIds.end(), idSet.begin(), idSet.end());
+
return activeIds;
}
diff --git a/src/lib/data/graph/Edge.cpp b/src/lib/data/graph/Edge.cpp
index c8933c67..9be01262 100644
--- a/src/lib/data/graph/Edge.cpp
+++ b/src/lib/data/graph/Edge.cpp
@@ -364,7 +364,7 @@ bool Edge::checkType() const
}
return true;
case EDGE_MACRO_USAGE:
- if(!m_to->isType(Node::NODE_MACRO) || !m_from->isType(Node::NODE_FILE))
+ if(!m_to->isType(Node::NODE_MACRO | Node::NODE_UNDEFINED_MACRO) || !m_from->isType(Node::NODE_FILE))
{
break;
}
diff --git a/src/lib/data/graph/Node.cpp b/src/lib/data/graph/Node.cpp
index 81dba72d..cba5234a 100644
--- a/src/lib/data/graph/Node.cpp
+++ b/src/lib/data/graph/Node.cpp
@@ -47,6 +47,8 @@ std::string Node::getTypeString(NodeType type)
return "template_parameter_type";
case NODE_FILE:
return "file";
+ case NODE_UNDEFINED_MACRO:
+ return "undefined_macro";
case NODE_MACRO:
return "macro";
}
@@ -96,6 +98,8 @@ Node::NodeType Node::intToType(int value)
case 0x8000:
return NODE_FILE;
case 0x10000:
+ return NODE_UNDEFINED_MACRO;
+ case 0x20000:
return NODE_MACRO;
}
diff --git a/src/lib/data/graph/Node.h b/src/lib/data/graph/Node.h
index b34469b2..cc4acfd0 100644
--- a/src/lib/data/graph/Node.h
+++ b/src/lib/data/graph/Node.h
@@ -41,7 +41,9 @@ public:
NODE_TEMPLATE_PARAMETER_TYPE = 0x4000,
NODE_FILE = 0x8000,
- NODE_MACRO = 0x10000,
+
+ NODE_UNDEFINED_MACRO = 0x10000,
+ NODE_MACRO = 0x20000,
};
static std::string getTypeString(NodeType type);
diff --git a/src/lib/data/parser/cxx/ASTBodyVisitor.cpp b/src/lib/data/parser/cxx/ASTBodyVisitor.cpp
index 93ec3e70..418e4373 100644
--- a/src/lib/data/parser/cxx/ASTBodyVisitor.cpp
+++ b/src/lib/data/parser/cxx/ASTBodyVisitor.cpp
@@ -25,7 +25,7 @@ void ASTBodyVisitor::VisitStmt(clang::Stmt* stmt)
void ASTBodyVisitor::VisitChildren(clang::Stmt* stmt)
{
- for (clang::Stmt::child_range it = stmt->children(); it; it++)
+ for (clang::Stmt::child_iterator it = stmt->child_begin(); it != stmt->child_end(); it++)
{
if (*it)
{
diff --git a/src/lib/data/parser/cxx/PreprocessorCallbacks.cpp b/src/lib/data/parser/cxx/PreprocessorCallbacks.cpp
index 9f84e186..bcc2b668 100644
--- a/src/lib/data/parser/cxx/PreprocessorCallbacks.cpp
+++ b/src/lib/data/parser/cxx/PreprocessorCallbacks.cpp
@@ -56,7 +56,8 @@ void PreprocessorCallbacks::InclusionDirective(
std::string includedFilePath = fileEntry->getName();
const FileManager* fileManager = m_fileRegister->getFileManager();
- if (fileManager->hasFilePath(baseFilePath) && fileManager->hasFilePath(includedFilePath))
+ if (fileManager->hasFilePath(baseFilePath) && fileManager->hasFilePath(includedFilePath) &&
+ !m_fileRegister->includeFileIsParsed(baseFilePath))
{
m_client->onFileIncludeParsed(
getParseLocation(fileNameRange.getAsRange()),
@@ -67,53 +68,73 @@ void PreprocessorCallbacks::InclusionDirective(
}
}
-void PreprocessorCallbacks::MacroDefined( const clang::Token &MacroNameTok, const clang::MacroDirective *MD)
+void PreprocessorCallbacks::MacroDefined(const clang::Token& macroNameToken, const clang::MacroDirective* macroDirective)
{
- // ignore builtin macros
- if(m_sourceManager.getSpellingLoc(MacroNameTok.getLocation()).printToString(m_sourceManager)[0] == '<')
+ const std::string& fileStr = m_sourceManager.getFilename(macroNameToken.getLocation());
+ if (!fileStr.size())
{
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);
+ FilePath filePath = FilePath(fileStr);
+ if (m_fileRegister->getFileManager()->hasFilePath(filePath) && !m_fileRegister->includeFileIsParsed(filePath))
+ {
+ // ignore builtin macros
+ if (m_sourceManager.getSpellingLoc(macroNameToken.getLocation()).printToString(m_sourceManager)[0] == '<')
+ {
+ return;
+ }
+
+ NameHierarchy nameHierarchy;
+ nameHierarchy.push(std::make_shared(macroNameToken.getIdentifierInfo()->getName().str()));
+
+ m_client->onMacroDefineParsed(getParseLocation(macroNameToken), nameHierarchy);
+ }
}
void PreprocessorCallbacks::MacroExpands(
- const clang::Token &MacroNameTok, const clang::MacroDefinition &MD,
- clang::SourceRange Range, const clang::MacroArgs *Args
+ const clang::Token& macroNameToken, const clang::MacroDefinition& macroDirective,
+ clang::SourceRange range, const clang::MacroArgs* args
){
- NameHierarchy nameHierarchy;
- nameHierarchy.push(std::make_shared(MacroNameTok.getIdentifierInfo()->getName().str()));
+ const std::string& fileStr = m_sourceManager.getFilename(macroNameToken.getLocation());
+ if (!fileStr.size())
+ {
+ return;
+ }
- m_client->onMacroExpandParsed( getParseLocation(MacroNameTok), nameHierarchy);
+ FilePath filePath = FilePath(fileStr);
+ if (m_fileRegister->getFileManager()->hasFilePath(filePath) && !m_fileRegister->includeFileIsParsed(filePath))
+ {
+ NameHierarchy nameHierarchy;
+ nameHierarchy.push(std::make_shared(macroNameToken.getIdentifierInfo()->getName().str()));
+
+ m_client->onMacroExpandParsed(getParseLocation(macroNameToken), nameHierarchy);
+ }
}
-ParseLocation PreprocessorCallbacks::getParseLocation(const clang::Token &MacroNameTok) const
+ParseLocation PreprocessorCallbacks::getParseLocation(const clang::Token& macroNameTok) const
{
- clang::SourceLocation location = MacroNameTok.getLocation();
+ 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
+ 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
+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
+ m_sourceManager.getFilename(location),
+ m_sourceManager.getSpellingLineNumber(location),
+ m_sourceManager.getSpellingColumnNumber(location),
+ m_sourceManager.getSpellingLineNumber(endLocation),
+ m_sourceManager.getSpellingColumnNumber(endLocation) - 1
);
}
diff --git a/src/lib/data/parser/cxx/PreprocessorCallbacks.h b/src/lib/data/parser/cxx/PreprocessorCallbacks.h
index f20cac24..97f41cc7 100644
--- a/src/lib/data/parser/cxx/PreprocessorCallbacks.h
+++ b/src/lib/data/parser/cxx/PreprocessorCallbacks.h
@@ -24,17 +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 MacroDefined(const clang::Token& macroNameToken, const clang::MacroDirective* macroDirective);
virtual void MacroExpands(
- const clang::Token &MacroNameTok, const clang::MacroDefinition &MD,
- clang::SourceRange Range, const clang::MacroArgs *Args
+ const clang::Token& macroNameToken, const clang::MacroDefinition& macroDirective,
+ 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;
+ ParseLocation getParseLocation(const clang::Token& macroNameToc) const;
+ ParseLocation getParseLocation(clang::MacroInfo* macroNameToc) const;
const clang::SourceManager& m_sourceManager;
ParserClient* m_client;