Clang API function terminology got changed
...at least in trunk 200400 towards Clang 3.5. Change-Id: I6e295e3a4cf721fbda9df8e7c5bed3993ee78216
This commit is contained in:
49
compilerplugins/clang/compat.hxx
Normal file
49
compilerplugins/clang/compat.hxx
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||||
|
/*
|
||||||
|
* This file is part of the LibreOffice project.
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INCLUDED_COMPILERPLUGINS_CLANG_COMPAT_HXX
|
||||||
|
#define INCLUDED_COMPILERPLUGINS_CLANG_COMPAT_HXX
|
||||||
|
|
||||||
|
#include "clang/AST/Decl.h"
|
||||||
|
#include "clang/AST/Type.h"
|
||||||
|
|
||||||
|
// Compatibility wrapper to abstract over (trivial) chanes in the Clang API:
|
||||||
|
namespace compat {
|
||||||
|
|
||||||
|
inline clang::QualType getReturnType(clang::FunctionDecl const & decl) {
|
||||||
|
#if (__clang_major__ == 3 && __clang_minor__ >= 5) || __clang_major__ > 3
|
||||||
|
return decl.getReturnType();
|
||||||
|
#else
|
||||||
|
return decl.getResultType();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
inline unsigned getNumParams(clang::FunctionProtoType const & type) {
|
||||||
|
#if (__clang_major__ == 3 && __clang_minor__ >= 5) || __clang_major__ > 3
|
||||||
|
return type.getNumParams();
|
||||||
|
#else
|
||||||
|
return type.getNumArgs();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
inline clang::QualType getParamType(
|
||||||
|
clang::FunctionProtoType const & type, unsigned i)
|
||||||
|
{
|
||||||
|
#if (__clang_major__ == 3 && __clang_minor__ >= 5) || __clang_major__ > 3
|
||||||
|
return type.getParamType(i);
|
||||||
|
#else
|
||||||
|
return type.getArgType(i);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
@@ -15,6 +15,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "compat.hxx"
|
||||||
#include "plugin.hxx"
|
#include "plugin.hxx"
|
||||||
|
|
||||||
template<> struct std::iterator_traits<ExprIterator> {
|
template<> struct std::iterator_traits<ExprIterator> {
|
||||||
@@ -183,11 +184,11 @@ bool ImplicitBoolConversion::TraverseCallExpr(CallExpr * expr) {
|
|||||||
} else {
|
} else {
|
||||||
std::ptrdiff_t n = j - expr->arg_begin();
|
std::ptrdiff_t n = j - expr->arg_begin();
|
||||||
assert(n >= 0);
|
assert(n >= 0);
|
||||||
assert(n < t->getNumArgs() || t->isVariadic());
|
assert(n < compat::getNumParams(*t) || t->isVariadic());
|
||||||
if (n < t->getNumArgs()
|
if (n < compat::getNumParams(*t)
|
||||||
&& !(t->getArgType(n)->isSpecificBuiltinType(
|
&& !(compat::getParamType(*t, n)->isSpecificBuiltinType(
|
||||||
BuiltinType::Int)
|
BuiltinType::Int)
|
||||||
|| (t->getArgType(n)->isSpecificBuiltinType(
|
|| (compat::getParamType(*t, n)->isSpecificBuiltinType(
|
||||||
BuiltinType::UInt))))
|
BuiltinType::UInt))))
|
||||||
{
|
{
|
||||||
reportWarning(i);
|
reportWarning(i);
|
||||||
@@ -494,8 +495,10 @@ bool ImplicitBoolConversion::TraverseReturnStmt(ReturnStmt * stmt) {
|
|||||||
bool ImplicitBoolConversion::TraverseFunctionDecl(FunctionDecl * decl) {
|
bool ImplicitBoolConversion::TraverseFunctionDecl(FunctionDecl * decl) {
|
||||||
bool ext = hasCLanguageLinkageType(decl)
|
bool ext = hasCLanguageLinkageType(decl)
|
||||||
&& decl->isThisDeclarationADefinition()
|
&& decl->isThisDeclarationADefinition()
|
||||||
&& (decl->getResultType()->isSpecificBuiltinType(BuiltinType::Int)
|
&& (compat::getReturnType(*decl)->isSpecificBuiltinType(
|
||||||
|| decl->getResultType()->isSpecificBuiltinType(BuiltinType::UInt));
|
BuiltinType::Int)
|
||||||
|
|| compat::getReturnType(*decl)->isSpecificBuiltinType(
|
||||||
|
BuiltinType::UInt));
|
||||||
if (ext) {
|
if (ext) {
|
||||||
assert(!externCIntFunctionDefinition);
|
assert(!externCIntFunctionDefinition);
|
||||||
externCIntFunctionDefinition = true;
|
externCIntFunctionDefinition = true;
|
||||||
|
Reference in New Issue
Block a user