Adapt compilerplugins to old Clang versions
Change-Id: I91335f1e81e251f0578792517dded9fae239fb61
This commit is contained in:
@@ -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();
|
||||
|
@@ -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()));
|
||||
}
|
||||
|
Reference in New Issue
Block a user