aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergio Martins <smartins@kde.org>2018-09-22 20:33:41 +0100
committerSergio Martins <smartins@kde.org>2018-09-22 22:35:52 +0100
commit64023370e0454f89ecc55bedabbbcfcf627cc655 (patch)
tree55d3ae80e01e0ba37c68da383d02893862d8c98d
parent3665a54a9f52dab0dcc0546145dfda72b6a1cb92 (diff)
parentd6cb7569816ce11160a2eeebd58a92a345b59f70 (diff)
Merge branch '1.3' into 1.4
-rw-r--r--CMakeLists.txt6
-rw-r--r--src/Clazy.cpp15
-rw-r--r--src/Clazy.h4
3 files changed, 22 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8ba12c82..9139e5bc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -32,6 +32,12 @@ add_definitions(-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS)
add_definitions(-D_GNU_SOURCE -DHAVE_CLANG_CONFIG_H)
option(CLAZY_BUILD_UTILS_LIB "Enable this option to build a library so you can reuse clazy's utility functions" OFF)
+option(CLAZY_AST_MATCHERS_CRASH_WORKAROUND "Disable AST Matchers if being built with clang. See bug #392223" ON)
+
+if (CLAZY_AST_MATCHERS_CRASH_WORKAROUND AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ message("Enabling AST Matchers workaround. Consider building with gcc instead. See bug #392223.")
+ add_definitions(-DCLAZY_DISABLE_AST_MATCHERS)
+endif()
if(CLAZY_BUILD_UTILS_LIB)
add_definitions(-DCLAZY_BUILD_UTILS_LIB)
diff --git a/src/Clazy.cpp b/src/Clazy.cpp
index 0e562da2..0fcaed92 100644
--- a/src/Clazy.cpp
+++ b/src/Clazy.cpp
@@ -62,12 +62,17 @@ static void manuallyPopulateParentMap(ParentMap *map, Stmt *s)
ClazyASTConsumer::ClazyASTConsumer(ClazyContext *context)
: m_context(context)
{
+#ifndef CLAZY_DISABLE_AST_MATCHERS
+ m_matchFinder = new clang::ast_matchers::MatchFinder();
+#endif
}
void ClazyASTConsumer::addCheck(const std::pair<CheckBase *, RegisteredCheck> &check)
{
CheckBase *checkBase = check.first;
- checkBase->registerASTMatchers(m_matchFinder);
+#ifndef CLAZY_DISABLE_AST_MATCHERS
+ checkBase->registerASTMatchers(*m_matchFinder);
+#endif
//m_createdChecks.push_back(checkBase);
const RegisteredCheck &rcheck = check.second;
@@ -77,10 +82,14 @@ void ClazyASTConsumer::addCheck(const std::pair<CheckBase *, RegisteredCheck> &c
if (rcheck.options & RegisteredCheck::Option_VisitsDecls)
m_checksToVisitDecls.push_back(checkBase);
+
}
ClazyASTConsumer::~ClazyASTConsumer()
{
+#ifndef CLAZY_DISABLE_AST_MATCHERS
+ delete m_matchFinder;
+#endif
delete m_context;
}
@@ -152,8 +161,10 @@ void ClazyASTConsumer::HandleTranslationUnit(ASTContext &ctx)
// Run our RecursiveAstVisitor based checks:
TraverseDecl(ctx.getTranslationUnitDecl());
+#ifndef CLAZY_DISABLE_AST_MATCHERS
// Run our AstMatcher base checks:
- m_matchFinder.matchAST(ctx);
+ m_matchFinder->matchAST(ctx);
+#endif
}
static bool parseArgument(const string &arg, vector<string> &args)
diff --git a/src/Clazy.h b/src/Clazy.h
index b126e221..d3d0d71f 100644
--- a/src/Clazy.h
+++ b/src/Clazy.h
@@ -109,7 +109,9 @@ private:
//CheckBase::List m_createdChecks;
CheckBase::List m_checksToVisitStmts;
CheckBase::List m_checksToVisitDecls;
- clang::ast_matchers::MatchFinder m_matchFinder;
+#ifndef CLAZY_DISABLE_AST_MATCHERS
+ clang::ast_matchers::MatchFinder *m_matchFinder = nullptr;
+#endif
};
#endif