diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-11-19 09:19:30 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-11-19 09:19:30 +0100 |
commit | 4a6268f0d37f377181f972ed307d2a074e8e1b6a (patch) | |
tree | b5576f2ab2fe4add1a23f4d700972ef445b8e53b /compilerplugins/clang | |
parent | e6d21d08af14a3e48eb1f9fedf1cb7e4f449a4de (diff) |
Adapt compilerplugins to old Clang versions
Change-Id: I91335f1e81e251f0578792517dded9fae239fb61
Diffstat (limited to 'compilerplugins/clang')
-rw-r--r-- | compilerplugins/clang/compat.hxx | 9 | ||||
-rw-r--r-- | compilerplugins/clang/typecheck.hxx | 6 |
2 files changed, 12 insertions, 3 deletions
diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx index 6b1451000ff6..0a16a3c99c2e 100644 --- a/compilerplugins/clang/compat.hxx +++ b/compilerplugins/clang/compat.hxx @@ -41,6 +41,15 @@ // Compatibility wrapper to abstract over (trivial) changes in the Clang API: namespace compat { +inline bool isLookupContext(clang::DeclContext const & ctxt) { +#if (__clang_major__ == 3 && __clang_minor__ > 7) || __clang_major__ > 3 + return ctxt.isLookupContext(); +#else + return !ctxt.isFunctionOrMethod() + && ctxt.getDeclKind() != clang::Decl::LinkageSpec; +#endif +} + inline bool isExternCContext(clang::DeclContext const & ctxt) { #if (__clang_major__ == 3 && __clang_minor__ >= 4) || __clang_major__ > 3 return ctxt.isExternCContext(); diff --git a/compilerplugins/clang/typecheck.hxx b/compilerplugins/clang/typecheck.hxx index 6ab8f74e1aad..35d4e5769b6e 100644 --- a/compilerplugins/clang/typecheck.hxx +++ b/compilerplugins/clang/typecheck.hxx @@ -12,11 +12,11 @@ #include <cstddef> -#include <iostream> - #include <clang/AST/DeclBase.h> #include <clang/AST/Type.h> +#include "compat.hxx" + namespace loplugin { class NamespaceCheck; @@ -72,7 +72,7 @@ public: TerminalCheck GlobalNamespace() const { return TerminalCheck( context_ != nullptr - && ((context_->isLookupContext() + && ((compat::isLookupContext(*context_) ? context_ : context_->getLookupParent()) ->isTranslationUnit())); } |