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:
|
// Compatibility wrapper to abstract over (trivial) changes in the Clang API:
|
||||||
namespace compat {
|
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) {
|
inline bool isExternCContext(clang::DeclContext const & ctxt) {
|
||||||
#if (__clang_major__ == 3 && __clang_minor__ >= 4) || __clang_major__ > 3
|
#if (__clang_major__ == 3 && __clang_minor__ >= 4) || __clang_major__ > 3
|
||||||
return ctxt.isExternCContext();
|
return ctxt.isExternCContext();
|
||||||
|
@@ -12,11 +12,11 @@
|
|||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include <clang/AST/DeclBase.h>
|
#include <clang/AST/DeclBase.h>
|
||||||
#include <clang/AST/Type.h>
|
#include <clang/AST/Type.h>
|
||||||
|
|
||||||
|
#include "compat.hxx"
|
||||||
|
|
||||||
namespace loplugin {
|
namespace loplugin {
|
||||||
|
|
||||||
class NamespaceCheck;
|
class NamespaceCheck;
|
||||||
@@ -72,7 +72,7 @@ public:
|
|||||||
TerminalCheck GlobalNamespace() const {
|
TerminalCheck GlobalNamespace() const {
|
||||||
return TerminalCheck(
|
return TerminalCheck(
|
||||||
context_ != nullptr
|
context_ != nullptr
|
||||||
&& ((context_->isLookupContext()
|
&& ((compat::isLookupContext(*context_)
|
||||||
? context_ : context_->getLookupParent())
|
? context_ : context_->getLookupParent())
|
||||||
->isTranslationUnit()));
|
->isTranslationUnit()));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user