diff options
author | Richard Oehlinger <r.oehlinger@avibit.com> | 2017-10-19 16:00:29 +0200 |
---|---|---|
committer | Sergio Martins <iamsergio@gmail.com> | 2017-10-19 18:36:19 +0100 |
commit | 4847a25f3fa65744bd7dd23533da6bb8783ca6b6 (patch) | |
tree | 93e2360e730ff3ece74ed62164a6fb4e22d7ea87 /src | |
parent | c19c0d65581a64c0fc41000138163915d8460f1d (diff) |
Add option to visit implicit code, such as compiler generated CTORs
Although clazy's built-in checks don't need this, some custom user
checks might
Not enabled by default as it causes a slight slowdown
BUG: 385851
Diffstat (limited to 'src')
-rw-r--r-- | src/Clazy.cpp | 3 | ||||
-rw-r--r-- | src/Clazy.h | 1 | ||||
-rw-r--r-- | src/ClazyContext.h | 8 | ||||
-rw-r--r-- | src/ClazyStandaloneMain.cpp | 6 |
4 files changed, 17 insertions, 1 deletions
diff --git a/src/Clazy.cpp b/src/Clazy.cpp index 8014d81b..0b1875ab 100644 --- a/src/Clazy.cpp +++ b/src/Clazy.cpp @@ -200,6 +200,9 @@ bool ClazyASTAction::ParseArgs(const CompilerInstance &ci, const std::vector<std if (parseArgument("qt-developer", args)) m_options |= ClazyContext::ClazyOption_QtDeveloper; + if (parseArgument("visit-implicit-code", args)) + m_options |= ClazyContext::ClazyOption_VisitImplicitCode; + m_context = new ClazyContext(ci, m_options); // This argument is for debugging purposes diff --git a/src/Clazy.h b/src/Clazy.h index ee960531..8d89d893 100644 --- a/src/Clazy.h +++ b/src/Clazy.h @@ -91,6 +91,7 @@ class ClazyASTConsumer : public clang::ASTConsumer, public: explicit ClazyASTConsumer(ClazyContext *context); ~ClazyASTConsumer(); + bool shouldVisitImplicitCode() const { return m_context->isVisitImplicitCode(); } bool VisitDecl(clang::Decl *decl); bool VisitStmt(clang::Stmt *stm); diff --git a/src/ClazyContext.h b/src/ClazyContext.h index 5a41d322..c2311ceb 100644 --- a/src/ClazyContext.h +++ b/src/ClazyContext.h @@ -56,7 +56,8 @@ public: ClazyOption_AllFixitsEnabled = 4, ClazyOption_Qt4Compat = 8, ClazyOption_OnlyQt = 16, // Ignore non-Qt files. This is done by bailing out if QT_CORE_LIB is not set. - ClazyOption_QtDeveloper = 32 // For running clazy on Qt itself, optional, but honours specific guidelines + ClazyOption_QtDeveloper = 32, // For running clazy on Qt itself, optional, but honours specific guidelines + ClazyOption_VisitImplicitCode = 64, // Inspect compiler generated code aswell. }; typedef int ClazyOptions; @@ -88,6 +89,11 @@ public: return options & ClazyOption_QtDeveloper; } + bool isVisitImplicitCode() const + { + return options & ClazyContext::ClazyOption_VisitImplicitCode; + } + bool isOptionSet(const std::string &optionName) const { return clazy_std::contains(extraOptions, optionName); diff --git a/src/ClazyStandaloneMain.cpp b/src/ClazyStandaloneMain.cpp index 5270b234..04b20c88 100644 --- a/src/ClazyStandaloneMain.cpp +++ b/src/ClazyStandaloneMain.cpp @@ -53,6 +53,9 @@ static cl::opt<bool> s_onlyQt("only-qt", cl::desc("Won't emit warnings for non-Q static cl::opt<bool> s_qtDeveloper("qt-developer", cl::desc("For running clazy on Qt itself, optional, but honours specific guidelines"), cl::init(false), cl::cat(s_clazyCategory)); +static cl::opt<bool> s_visitImplicitCode("visit-implicit-code", cl::desc("Should clazy visit implicit code like compiler generated construktors"), + cl::init(false), cl::cat(s_clazyCategory)); + static cl::extrahelp s_commonHelp(CommonOptionsParser::HelpMessage); class ClazyToolActionFactory : public clang::tooling::FrontendActionFactory @@ -79,6 +82,9 @@ public: if (s_onlyQt.getValue()) options |= ClazyContext::ClazyOption_OnlyQt; + if (s_visitImplicitCode.getValue()) + options |= ClazyContext::ClazyOption_VisitImplicitCode; + return new ClazyStandaloneASTAction(s_checks.getValue(), options); } }; |