aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSergio Martins <smartins@kde.org>2018-09-19 19:28:25 +0100
committerSergio Martins <smartins@kde.org>2018-09-19 19:30:10 +0100
commit36dadd0e6d33101d0f26248376f2f1cbda5d8793 (patch)
tree335131dd88f31d7135aea0b994092538bcbc5a16 /src
parentcb6134157b33d9f902126f5e19480d21b724c343 (diff)
prospective fix for crash with clang-7.0
This shuffles the code around in hope of avoiding what seems to be a clang bug. The backtrace and valgrind report don't make sense to me, and the crash goes away if building clazy with gcc. CCBUG: 392223
Diffstat (limited to 'src')
-rw-r--r--src/Clazy.cpp7
-rw-r--r--src/Clazy.h2
2 files changed, 6 insertions, 3 deletions
diff --git a/src/Clazy.cpp b/src/Clazy.cpp
index 037316f9..5ef48ae0 100644
--- a/src/Clazy.cpp
+++ b/src/Clazy.cpp
@@ -62,17 +62,20 @@ static void manuallyPopulateParentMap(ParentMap *map, Stmt *s)
ClazyASTConsumer::ClazyASTConsumer(ClazyContext *context)
: m_context(context)
{
+ clang::ast_matchers::MatchFinder::MatchFinderOptions options;
+ m_matchFinder = new clang::ast_matchers::MatchFinder(options);
}
void ClazyASTConsumer::addCheck(CheckBase *check)
{
- check->registerASTMatchers(m_matchFinder);
+ check->registerASTMatchers(*m_matchFinder);
m_createdChecks.push_back(check);
}
ClazyASTConsumer::~ClazyASTConsumer()
{
delete m_context;
+ delete m_matchFinder;
}
bool ClazyASTConsumer::VisitDecl(Decl *decl)
@@ -132,7 +135,7 @@ void ClazyASTConsumer::HandleTranslationUnit(ASTContext &ctx)
TraverseDecl(ctx.getTranslationUnitDecl());
// Run our AstMatcher base checks:
- m_matchFinder.matchAST(ctx);
+ m_matchFinder->matchAST(ctx);
}
static bool parseArgument(const string &arg, vector<string> &args)
diff --git a/src/Clazy.h b/src/Clazy.h
index 2c7c3b75..b80c9113 100644
--- a/src/Clazy.h
+++ b/src/Clazy.h
@@ -108,7 +108,7 @@ private:
clang::Stmt *lastStm = nullptr;
ClazyContext *const m_context;
CheckBase::List m_createdChecks;
- clang::ast_matchers::MatchFinder m_matchFinder;
+ clang::ast_matchers::MatchFinder *m_matchFinder = nullptr;
};
#endif