Adapt to current Clang trunk towards 3.7
Change-Id: Ibb2c641d49a1773be789c9259f53a040db6f605f
This commit is contained in:
@@ -65,6 +65,18 @@ inline bool isInExternCContext(clang::FunctionDecl const & decl) {
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool forallBases(
|
||||
clang::CXXRecordDecl const & decl,
|
||||
clang::CXXRecordDecl::ForallBasesCallback BaseMatches,
|
||||
bool AllowShortCircuit)
|
||||
{
|
||||
#if (__clang_major__ == 3 && __clang_minor__ >= 7) || __clang_major__ > 3
|
||||
return decl.forallBases(BaseMatches, AllowShortCircuit);
|
||||
#else
|
||||
return decl.forallBases(BaseMatches, nullptr, AllowShortCircuit);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if (__clang_major__ == 3 && __clang_minor__ >= 3) || __clang_major__ > 3
|
||||
typedef clang::LinkageInfo LinkageInfo;
|
||||
#else
|
||||
@@ -129,6 +141,26 @@ inline clang::QualType getParamType(
|
||||
#endif
|
||||
}
|
||||
|
||||
inline clang::Stmt::const_child_iterator begin(
|
||||
clang::Stmt::const_child_range const & range)
|
||||
{
|
||||
#if (__clang_major__ == 3 && __clang_minor__ >= 7) || __clang_major__ > 3
|
||||
return range.begin();
|
||||
#else
|
||||
return range.first;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline clang::Stmt::const_child_iterator end(
|
||||
clang::Stmt::const_child_range const & range)
|
||||
{
|
||||
#if (__clang_major__ == 3 && __clang_minor__ >= 7) || __clang_major__ > 3
|
||||
return range.end();
|
||||
#else
|
||||
return range.second;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline unsigned getBuiltinCallee(clang::CallExpr const & expr) {
|
||||
#if (__clang_major__ == 3 && __clang_minor__ >= 5) || __clang_major__ > 3
|
||||
return expr.getBuiltinCallee();
|
||||
|
@@ -18,6 +18,8 @@
|
||||
#include "compat.hxx"
|
||||
#include "plugin.hxx"
|
||||
|
||||
#if __clang_major__ == 3 && __clang_minor__ < 7
|
||||
|
||||
template<> struct std::iterator_traits<ExprIterator> {
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef Expr * value_type;
|
||||
@@ -34,6 +36,8 @@ template<> struct std::iterator_traits<ConstExprIterator> {
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
Expr const * ignoreParenAndTemporaryMaterialization(Expr const * expr) {
|
||||
|
@@ -31,10 +31,10 @@ private:
|
||||
};
|
||||
|
||||
static bool oneAndOnlyOne(clang::Stmt::const_child_range range) {
|
||||
if (range.empty()) {
|
||||
if (compat::begin(range) == compat::end(range)) {
|
||||
return false;
|
||||
}
|
||||
if ((++range.first) != range.second) {
|
||||
if (++compat::begin(range) != compat::end(range)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -134,7 +134,7 @@ bool InlineSimpleMemberFunctions::VisitCXXMethodDecl(const CXXMethodDecl * funct
|
||||
{
|
||||
childStmt2 = *childStmt2->child_begin();
|
||||
if (dyn_cast<CXXThisExpr>( childStmt2 ) != nullptr
|
||||
&& childStmt2->children().empty())
|
||||
&& compat::begin(childStmt2->children()) == compat::end(childStmt2->children()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -145,7 +145,7 @@ bool InlineSimpleMemberFunctions::VisitCXXMethodDecl(const CXXMethodDecl * funct
|
||||
{
|
||||
const Stmt* childStmt2 = *childStmt->child_begin();
|
||||
if (dyn_cast<CXXThisExpr>( childStmt2 ) != nullptr
|
||||
&& childStmt2->children().empty())
|
||||
&& compat::begin(childStmt2->children()) == compat::end(childStmt2->children()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -208,7 +208,7 @@ bool InlineSimpleMemberFunctions::VisitCXXMethodDecl(const CXXMethodDecl * funct
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if ( childStmt->children().empty() )
|
||||
if ( compat::begin(childStmt->children()) == compat::end(childStmt->children()) )
|
||||
return true;
|
||||
childStmt = *childStmt->child_begin();
|
||||
}
|
||||
|
@@ -73,7 +73,17 @@ bool isDerivedFrom(const CXXRecordDecl *decl, const char *pString) {
|
||||
if (// not sure what hasAnyDependentBases() does,
|
||||
// but it avoids classes we don't want, e.g. WeakAggComponentImplHelper1
|
||||
!decl->hasAnyDependentBases() &&
|
||||
!decl->forallBases(BaseCheckNotSubclass, static_cast<void*>(const_cast<char*>(pString)), true)) {
|
||||
!compat::forallBases(
|
||||
*decl,
|
||||
#if __clang_major__ == 3 && __clang_minor__ < 7
|
||||
BaseCheckNotSubclass,
|
||||
#else
|
||||
[pString](const CXXRecordDecl *BaseDefinition) -> bool
|
||||
{ return BaseCheckNotSubclass(
|
||||
BaseDefinition, const_cast<char *>(pString)); },
|
||||
#endif
|
||||
true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@@ -36,7 +36,13 @@ private:
|
||||
std::string getFilename(SourceLocation loc);
|
||||
};
|
||||
|
||||
bool BaseCheckNotTestFixtureSubclass(const CXXRecordDecl *BaseDefinition, void *) {
|
||||
bool BaseCheckNotTestFixtureSubclass(
|
||||
const CXXRecordDecl *BaseDefinition
|
||||
#if __clang_major__ == 3 && __clang_minor__ < 7
|
||||
, void *
|
||||
#endif
|
||||
)
|
||||
{
|
||||
if (BaseDefinition->getQualifiedNameAsString().compare("CppUnit::TestFixture") == 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -49,7 +55,7 @@ bool isDerivedFromTestFixture(const CXXRecordDecl *decl) {
|
||||
if (// not sure what hasAnyDependentBases() does,
|
||||
// but it avoids classes we don't want, e.g. WeakAggComponentImplHelper1
|
||||
!decl->hasAnyDependentBases() &&
|
||||
!decl->forallBases(BaseCheckNotTestFixtureSubclass, nullptr, true)) {
|
||||
!compat::forallBases(*decl, BaseCheckNotTestFixtureSubclass, true)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@@ -16,6 +16,7 @@
|
||||
// (LO classes won't get duplicated warnings, as the attribute is different).
|
||||
#if !HAVE_GCC_ATTRIBUTE_WARN_UNUSED_STL
|
||||
|
||||
#include "compat.hxx"
|
||||
#include "unusedvariablecheck.hxx"
|
||||
|
||||
#include <clang/AST/Attr.h>
|
||||
@@ -48,7 +49,13 @@ void UnusedVariableCheck::run()
|
||||
TraverseDecl( compiler.getASTContext().getTranslationUnitDecl());
|
||||
}
|
||||
|
||||
bool BaseCheckNotDialogSubclass(const CXXRecordDecl *BaseDefinition, void *) {
|
||||
bool BaseCheckNotDialogSubclass(
|
||||
const CXXRecordDecl *BaseDefinition
|
||||
#if __clang_major__ == 3 && __clang_minor__ < 7
|
||||
, void *
|
||||
#endif
|
||||
)
|
||||
{
|
||||
if (BaseDefinition && BaseDefinition->getQualifiedNameAsString().compare("Dialog") == 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -66,7 +73,7 @@ bool isDerivedFromDialog(const CXXRecordDecl *decl) {
|
||||
if (// not sure what hasAnyDependentBases() does,
|
||||
// but it avoids classes we don't want, e.g. WeakAggComponentImplHelper1
|
||||
!decl->hasAnyDependentBases() &&
|
||||
!decl->forallBases(BaseCheckNotDialogSubclass, nullptr, true)) {
|
||||
!compat::forallBases(*decl, BaseCheckNotDialogSubclass, true)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@@ -57,7 +57,13 @@ static bool startsWith(const std::string& s, const char* other)
|
||||
return s.compare(0, strlen(other), other) == 0;
|
||||
}
|
||||
|
||||
bool BaseCheckNotWindowSubclass(const CXXRecordDecl *BaseDefinition, void *) {
|
||||
bool BaseCheckNotWindowSubclass(
|
||||
const CXXRecordDecl *BaseDefinition
|
||||
#if __clang_major__ == 3 && __clang_minor__ < 7
|
||||
, void *
|
||||
#endif
|
||||
)
|
||||
{
|
||||
if (BaseDefinition && BaseDefinition->getQualifiedNameAsString() == "OutputDevice") {
|
||||
return false;
|
||||
}
|
||||
@@ -75,7 +81,7 @@ bool isDerivedFromWindow(const CXXRecordDecl *decl) {
|
||||
if (// not sure what hasAnyDependentBases() does,
|
||||
// but it avoids classes we don't want, e.g. WeakAggComponentImplHelper1
|
||||
!decl->hasAnyDependentBases() &&
|
||||
!decl->forallBases(BaseCheckNotWindowSubclass, nullptr, true)) {
|
||||
!compat::forallBases(*decl, BaseCheckNotWindowSubclass, true)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user