Adapt compilerplugins to old Clang versions

Change-Id: I91335f1e81e251f0578792517dded9fae239fb61
This commit is contained in:
Stephan Bergmann
2015-11-19 09:19:30 +01:00
parent e6d21d08af
commit 4a6268f0d3
2 changed files with 12 additions and 3 deletions

View File

@@ -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();

View File

@@ -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()));
}