Bump --enable-compiler-plugins to Clang 3.8.0
<https://lists.freedesktop.org/archives/libreoffice/2017-December/079107.html> "Clang baseline bump" Change-Id: I18fca8794ea34118fc6308458064d0c28cf5caf7 Reviewed-on: https://gerrit.libreoffice.org/46557 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
@@ -50,7 +50,7 @@ C++17, C++14, or C++11" in its current form (due to the #pragma GCC diagnostic i
|
||||
that it does not understand).
|
||||
|
||||
If you want to use Clang with the LibreOffice compiler plugins, the minimal
|
||||
version of Clang is 3.4. Since Xcode doesn't provide the compiler plugin
|
||||
version of Clang is 3.8. Since Xcode doesn't provide the compiler plugin
|
||||
headers, you have to compile your own Clang to use them on macOS.
|
||||
|
||||
You can find the TDF configure switches in the distro-configs/ directory.
|
||||
|
@@ -9,8 +9,9 @@
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include <clang/AST/DeclCXX.h>
|
||||
|
||||
#include "check.hxx"
|
||||
#include "compat.hxx"
|
||||
|
||||
namespace loplugin {
|
||||
|
||||
@@ -153,14 +154,14 @@ ContextCheck DeclCheck::MemberFunction() const {
|
||||
TerminalCheck ContextCheck::GlobalNamespace() const {
|
||||
return TerminalCheck(
|
||||
context_ != nullptr
|
||||
&& ((compat::isLookupContext(*context_)
|
||||
&& ((context_->isLookupContext()
|
||||
? context_ : context_->getLookupParent())
|
||||
->isTranslationUnit()));
|
||||
}
|
||||
|
||||
TerminalCheck ContextCheck::StdNamespace() const {
|
||||
return TerminalCheck(
|
||||
context_ != nullptr && compat::isStdNamespace(*context_));
|
||||
context_ != nullptr && context_->isStdNamespace());
|
||||
}
|
||||
|
||||
ContextCheck ContextCheck::AnonymousNamespace() const {
|
||||
@@ -171,13 +172,7 @@ ContextCheck ContextCheck::AnonymousNamespace() const {
|
||||
|
||||
namespace {
|
||||
|
||||
bool BaseCheckNotSomethingInterestingSubclass(
|
||||
const clang::CXXRecordDecl *BaseDefinition
|
||||
#if CLANG_VERSION < 30800
|
||||
, void *
|
||||
#endif
|
||||
)
|
||||
{
|
||||
bool BaseCheckNotSomethingInterestingSubclass(const clang::CXXRecordDecl *BaseDefinition) {
|
||||
if (BaseDefinition) {
|
||||
auto tc = TypeCheck(BaseDefinition);
|
||||
if (tc.Class("Dialog").GlobalNamespace() || tc.Class("SfxPoolItem").GlobalNamespace()) {
|
||||
@@ -201,7 +196,7 @@ bool isDerivedFromSomethingInteresting(const clang::CXXRecordDecl *decl) {
|
||||
if (// not sure what hasAnyDependentBases() does,
|
||||
// but it avoids classes we don't want, e.g. WeakAggComponentImplHelper1
|
||||
!decl->hasAnyDependentBases() &&
|
||||
!compat::forallBases(*decl, BaseCheckNotSomethingInterestingSubclass, nullptr, true)) {
|
||||
!decl->forallBases(BaseCheckNotSomethingInterestingSubclass, true)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@@ -9,9 +9,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
#include "compat.hxx"
|
||||
#include "plugin.hxx"
|
||||
|
||||
#include <clang/Lex/Preprocessor.h>
|
||||
@@ -37,14 +37,14 @@ class CheckConfigMacros
|
||||
explicit CheckConfigMacros( const InstantiationData& data );
|
||||
virtual void run() override;
|
||||
virtual void MacroDefined( const Token& macroToken, const MacroDirective* info ) override;
|
||||
virtual void MacroUndefined( const Token& macroToken, compat::MacroDefinitionParam
|
||||
virtual void MacroUndefined( const Token& macroToken, MacroDefinition const &
|
||||
#if CLANG_VERSION >= 50000
|
||||
, MacroDirective const *
|
||||
#endif
|
||||
) override;
|
||||
virtual void Ifdef( SourceLocation location, const Token& macroToken, compat::MacroDefinitionParam ) override;
|
||||
virtual void Ifndef( SourceLocation location, const Token& macroToken, compat::MacroDefinitionParam ) override;
|
||||
virtual void Defined( const Token& macroToken, compat::MacroDefinitionParam, SourceRange Range ) override;
|
||||
virtual void Ifdef( SourceLocation location, const Token& macroToken, MacroDefinition const & ) override;
|
||||
virtual void Ifndef( SourceLocation location, const Token& macroToken, MacroDefinition const & ) override;
|
||||
virtual void Defined( const Token& macroToken, MacroDefinition const &, SourceRange Range ) override;
|
||||
enum { isPPCallback = true };
|
||||
private:
|
||||
void checkMacro( const Token& macroToken, SourceLocation location );
|
||||
@@ -54,7 +54,7 @@ class CheckConfigMacros
|
||||
CheckConfigMacros::CheckConfigMacros( const InstantiationData& data )
|
||||
: Plugin( data )
|
||||
{
|
||||
compat::addPPCallbacks(compiler.getPreprocessor(), this);
|
||||
compiler.getPreprocessor().addPPCallbacks(std::unique_ptr<PPCallbacks>(this));
|
||||
}
|
||||
|
||||
void CheckConfigMacros::run()
|
||||
@@ -75,7 +75,7 @@ void CheckConfigMacros::MacroDefined( const Token& macroToken, const MacroDirect
|
||||
}
|
||||
}
|
||||
|
||||
void CheckConfigMacros::MacroUndefined( const Token& macroToken, compat::MacroDefinitionParam
|
||||
void CheckConfigMacros::MacroUndefined( const Token& macroToken, MacroDefinition const &
|
||||
#if CLANG_VERSION >= 50000
|
||||
, MacroDirective const *
|
||||
#endif
|
||||
@@ -84,17 +84,17 @@ void CheckConfigMacros::MacroUndefined( const Token& macroToken, compat::MacroDe
|
||||
configMacros.erase( macroToken.getIdentifierInfo()->getName());
|
||||
}
|
||||
|
||||
void CheckConfigMacros::Ifdef( SourceLocation location, const Token& macroToken, compat::MacroDefinitionParam )
|
||||
void CheckConfigMacros::Ifdef( SourceLocation location, const Token& macroToken, MacroDefinition const & )
|
||||
{
|
||||
checkMacro( macroToken, location );
|
||||
}
|
||||
|
||||
void CheckConfigMacros::Ifndef( SourceLocation location, const Token& macroToken, compat::MacroDefinitionParam )
|
||||
void CheckConfigMacros::Ifndef( SourceLocation location, const Token& macroToken, MacroDefinition const & )
|
||||
{
|
||||
checkMacro( macroToken, location );
|
||||
}
|
||||
|
||||
void CheckConfigMacros::Defined( const Token& macroToken, compat::MacroDefinitionParam , SourceRange )
|
||||
void CheckConfigMacros::Defined( const Token& macroToken, MacroDefinition const &, SourceRange )
|
||||
{
|
||||
checkMacro( macroToken, macroToken.getLocation());
|
||||
}
|
||||
|
@@ -11,26 +11,14 @@
|
||||
#define INCLUDED_COMPILERPLUGINS_CLANG_COMPAT_HXX
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "clang/AST/Decl.h"
|
||||
#include "clang/AST/DeclBase.h"
|
||||
#include "clang/AST/DeclCXX.h"
|
||||
#include "clang/AST/Expr.h"
|
||||
#include "clang/AST/ExprCXX.h"
|
||||
#include "clang/AST/Type.h"
|
||||
#include "clang/Basic/Diagnostic.h"
|
||||
#include "clang/Basic/DiagnosticIDs.h"
|
||||
#include "clang/Basic/Linkage.h"
|
||||
#include "clang/Basic/SourceManager.h"
|
||||
#include "clang/Basic/Visibility.h"
|
||||
#include "clang/Frontend/CompilerInstance.h"
|
||||
#include "clang/Lex/PPCallbacks.h"
|
||||
#include "clang/Lex/Preprocessor.h"
|
||||
#include "clang/Lex/Lexer.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
#include "config_clang.h"
|
||||
|
||||
@@ -46,37 +34,6 @@ inline llvm::StringRef take_front(llvm::StringRef ref, std::size_t N = 1) {
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool isLookupContext(clang::DeclContext const & ctxt) {
|
||||
#if CLANG_VERSION >= 30700
|
||||
return ctxt.isLookupContext();
|
||||
#else
|
||||
return !ctxt.isFunctionOrMethod()
|
||||
&& ctxt.getDeclKind() != clang::Decl::LinkageSpec;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool forallBases(
|
||||
clang::CXXRecordDecl const & decl,
|
||||
clang::CXXRecordDecl::ForallBasesCallback BaseMatches,
|
||||
void* callbackParam,
|
||||
bool AllowShortCircuit)
|
||||
{
|
||||
#if CLANG_VERSION >= 30800
|
||||
(void) callbackParam;
|
||||
return decl.forallBases(BaseMatches, AllowShortCircuit);
|
||||
#else
|
||||
return decl.forallBases(BaseMatches, callbackParam, AllowShortCircuit);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline clang::QualType getReturnType(clang::FunctionDecl const & decl) {
|
||||
#if CLANG_VERSION >= 30500
|
||||
return decl.getReturnType();
|
||||
#else
|
||||
return decl.getResultType();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if CLANG_VERSION >= 30900
|
||||
inline clang::ArrayRef<clang::ParmVarDecl *> parameters(
|
||||
@@ -84,128 +41,15 @@ inline clang::ArrayRef<clang::ParmVarDecl *> parameters(
|
||||
{
|
||||
return decl.parameters();
|
||||
}
|
||||
#elif CLANG_VERSION >= 30500
|
||||
#else
|
||||
inline clang::FunctionDecl::param_const_range parameters(
|
||||
clang::FunctionDecl const & decl)
|
||||
{
|
||||
return decl.params();
|
||||
}
|
||||
#else
|
||||
struct FunctionDeclParamsWrapper
|
||||
{
|
||||
clang::FunctionDecl const & decl;
|
||||
FunctionDeclParamsWrapper(clang::FunctionDecl const & _decl) : decl(_decl) {}
|
||||
clang::FunctionDecl::param_const_iterator begin() const { return decl.param_begin(); }
|
||||
clang::FunctionDecl::param_const_iterator end() const { return decl.param_end(); }
|
||||
};
|
||||
inline FunctionDeclParamsWrapper parameters(
|
||||
clang::FunctionDecl const & decl)
|
||||
{
|
||||
return FunctionDeclParamsWrapper(decl);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
inline clang::QualType getReturnType(clang::FunctionProtoType const & type) {
|
||||
#if CLANG_VERSION >= 30500
|
||||
return type.getReturnType();
|
||||
#else
|
||||
return type.getResultType();
|
||||
#endif
|
||||
}
|
||||
|
||||
inline unsigned getNumParams(clang::FunctionProtoType const & type) {
|
||||
#if CLANG_VERSION >= 30500
|
||||
return type.getNumParams();
|
||||
#else
|
||||
return type.getNumArgs();
|
||||
#endif
|
||||
}
|
||||
|
||||
inline clang::QualType getParamType(
|
||||
clang::FunctionProtoType const & type, unsigned i)
|
||||
{
|
||||
#if CLANG_VERSION >= 30500
|
||||
return type.getParamType(i);
|
||||
#else
|
||||
return type.getArgType(i);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline clang::Stmt::const_child_iterator begin(
|
||||
clang::Stmt::const_child_range const & range)
|
||||
{
|
||||
#if CLANG_VERSION >= 30800
|
||||
return range.begin();
|
||||
#else
|
||||
return range.first;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline clang::Stmt::const_child_iterator end(
|
||||
clang::Stmt::const_child_range const & range)
|
||||
{
|
||||
#if CLANG_VERSION >= 30800
|
||||
return range.end();
|
||||
#else
|
||||
return range.second;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline unsigned getBuiltinCallee(clang::CallExpr const & expr) {
|
||||
#if CLANG_VERSION >= 30500
|
||||
return expr.getBuiltinCallee();
|
||||
#else
|
||||
return expr.isBuiltinCall();
|
||||
#endif
|
||||
}
|
||||
|
||||
inline unsigned getCustomDiagID(
|
||||
clang::DiagnosticsEngine & engine, clang::DiagnosticsEngine::Level L,
|
||||
llvm::StringRef FormatString)
|
||||
{
|
||||
#if CLANG_VERSION >= 30500
|
||||
return engine.getDiagnosticIDs()->getCustomDiagID(
|
||||
static_cast<clang::DiagnosticIDs::Level>(L), FormatString);
|
||||
#else
|
||||
return engine.getCustomDiagID(L, FormatString);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline std::unique_ptr<llvm::raw_fd_ostream> create_raw_fd_ostream(
|
||||
char const * Filename, std::string & ErrorInfo)
|
||||
{
|
||||
#if CLANG_VERSION >= 30600
|
||||
std::error_code ec;
|
||||
std::unique_ptr<llvm::raw_fd_ostream> s(
|
||||
new llvm::raw_fd_ostream(Filename, ec, llvm::sys::fs::F_None));
|
||||
ErrorInfo = ec ? "error: " + ec.message() : std::string();
|
||||
return s;
|
||||
#elif CLANG_VERSION >= 30500
|
||||
return std::unique_ptr<llvm::raw_fd_ostream>(
|
||||
new llvm::raw_fd_ostream(Filename, ErrorInfo, llvm::sys::fs::F_None));
|
||||
#else
|
||||
return std::unique_ptr<llvm::raw_fd_ostream>(
|
||||
new llvm::raw_fd_ostream(Filename, ErrorInfo));
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CLANG_VERSION >= 30700
|
||||
using MacroDefinitionParam = clang::MacroDefinition const &;
|
||||
#else
|
||||
using MacroDefinitionParam = clang::MacroDirective const *;
|
||||
#endif
|
||||
|
||||
inline void addPPCallbacks(
|
||||
clang::Preprocessor & preprocessor, clang::PPCallbacks * C)
|
||||
{
|
||||
#if CLANG_VERSION >= 30600
|
||||
preprocessor.addPPCallbacks(std::unique_ptr<clang::PPCallbacks>(C));
|
||||
#else
|
||||
preprocessor.addPPCallbacks(C);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool isPointWithin(
|
||||
clang::SourceManager const & SM, clang::SourceLocation Location, clang::SourceLocation Start,
|
||||
clang::SourceLocation End)
|
||||
@@ -272,37 +116,6 @@ inline llvm::StringRef getImmediateMacroNameForDiagnostics(
|
||||
#endif
|
||||
}
|
||||
|
||||
inline auto getAsTagDecl(clang::Type const& t) -> clang::TagDecl *
|
||||
{
|
||||
#if CLANG_VERSION >= 30500
|
||||
// TODO not sure if it works with clang 3.6, trunk is known to work
|
||||
return t.getAsTagDecl();
|
||||
#else
|
||||
return t.getAs<clang::TagType>()->getDecl();
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool isStdNamespace(clang::DeclContext const & context) {
|
||||
#if CLANG_VERSION >= 30500
|
||||
return context.isStdNamespace();
|
||||
#else
|
||||
// cf. lib/AST/DeclBase.cpp:
|
||||
if (!context.isNamespace()) {
|
||||
return false;
|
||||
}
|
||||
const clang::NamespaceDecl *ND = clang::cast<clang::NamespaceDecl>(
|
||||
&context);
|
||||
if (ND->isInline()) {
|
||||
return isStdNamespace(*ND->getParent());
|
||||
}
|
||||
if (!context.getParent()->getRedeclContext()->isTranslationUnit()) {
|
||||
return false;
|
||||
}
|
||||
const clang::IdentifierInfo *II = ND->getIdentifier();
|
||||
return II && II->isStr("std");
|
||||
#endif
|
||||
}
|
||||
|
||||
// Work around <http://reviews.llvm.org/D22128>:
|
||||
//
|
||||
// SfxErrorHandler::GetClassString (svtools/source/misc/ehdl.cxx):
|
||||
|
@@ -107,12 +107,8 @@ void ConstantParam::addToCallSet(const FunctionDecl* functionDecl, int paramInde
|
||||
functionDecl = functionDecl->getInstantiatedFromMemberFunction();
|
||||
else if (functionDecl->getClassScopeSpecializationPattern())
|
||||
functionDecl = functionDecl->getClassScopeSpecializationPattern();
|
||||
// workaround clang-3.5 issue
|
||||
#if CLANG_VERSION >= 30600
|
||||
else if (functionDecl->getTemplateInstantiationPattern())
|
||||
functionDecl = functionDecl->getTemplateInstantiationPattern();
|
||||
#endif
|
||||
|
||||
|
||||
if (!functionDecl->getNameInfo().getLoc().isValid())
|
||||
return;
|
||||
@@ -131,7 +127,7 @@ void ConstantParam::addToCallSet(const FunctionDecl* functionDecl, int paramInde
|
||||
|
||||
|
||||
MyCallSiteInfo aInfo;
|
||||
aInfo.returnType = compat::getReturnType(*functionDecl).getCanonicalType().getAsString();
|
||||
aInfo.returnType = functionDecl->getReturnType().getCanonicalType().getAsString();
|
||||
|
||||
if (isa<CXXMethodDecl>(functionDecl)) {
|
||||
const CXXRecordDecl* recordDecl = dyn_cast<CXXMethodDecl>(functionDecl)->getParent();
|
||||
@@ -259,11 +255,8 @@ bool ConstantParam::VisitCallExpr(const CallExpr * callExpr) {
|
||||
functionDecl = functionDecl->getInstantiatedFromMemberFunction();
|
||||
else if (functionDecl->getClassScopeSpecializationPattern())
|
||||
functionDecl = functionDecl->getClassScopeSpecializationPattern();
|
||||
// workaround clang-3.5 issue
|
||||
#if CLANG_VERSION >= 30600
|
||||
else if (functionDecl->getTemplateInstantiationPattern())
|
||||
functionDecl = functionDecl->getTemplateInstantiationPattern();
|
||||
#endif
|
||||
|
||||
unsigned len = std::max(callExpr->getNumArgs(), functionDecl->getNumParams());
|
||||
for (unsigned i = 0; i < len; ++i) {
|
||||
|
@@ -95,11 +95,8 @@ void CountUsersOfDefaultParams::niceName(const FunctionDecl* functionDecl, MyFun
|
||||
functionDecl = functionDecl->getInstantiatedFromMemberFunction();
|
||||
else if (functionDecl->getClassScopeSpecializationPattern())
|
||||
functionDecl = functionDecl->getClassScopeSpecializationPattern();
|
||||
// workaround clang-3.5 issue
|
||||
#if CLANG_VERSION >= 30600
|
||||
else if (functionDecl->getTemplateInstantiationPattern())
|
||||
functionDecl = functionDecl->getTemplateInstantiationPattern();
|
||||
#endif
|
||||
|
||||
switch (functionDecl->getAccess())
|
||||
{
|
||||
@@ -108,7 +105,7 @@ void CountUsersOfDefaultParams::niceName(const FunctionDecl* functionDecl, MyFun
|
||||
case AS_protected: aInfo.access = "protected"; break;
|
||||
default: aInfo.access = "unknown"; break;
|
||||
}
|
||||
aInfo.returnType = compat::getReturnType(*functionDecl).getCanonicalType().getAsString();
|
||||
aInfo.returnType = functionDecl->getReturnType().getCanonicalType().getAsString();
|
||||
|
||||
if (isa<CXXMethodDecl>(functionDecl)) {
|
||||
const CXXRecordDecl* recordDecl = dyn_cast<CXXMethodDecl>(functionDecl)->getParent();
|
||||
@@ -160,11 +157,8 @@ bool CountUsersOfDefaultParams::VisitCallExpr(const CallExpr * callExpr) {
|
||||
functionDecl = functionDecl->getInstantiatedFromMemberFunction();
|
||||
else if (functionDecl->getClassScopeSpecializationPattern())
|
||||
functionDecl = functionDecl->getClassScopeSpecializationPattern();
|
||||
// workaround clang-3.5 issue
|
||||
#if CLANG_VERSION >= 30600
|
||||
else if (functionDecl->getTemplateInstantiationPattern())
|
||||
functionDecl = functionDecl->getTemplateInstantiationPattern();
|
||||
#endif
|
||||
int n = functionDecl->getNumParams() - 1;
|
||||
if (n < 0 || !functionDecl->getParamDecl(n)->hasDefaultArg()) {
|
||||
return true;
|
||||
@@ -192,11 +186,8 @@ bool CountUsersOfDefaultParams::VisitCXXConstructExpr(const CXXConstructExpr * c
|
||||
constructorDecl = dyn_cast<CXXConstructorDecl>(constructorDecl->getInstantiatedFromMemberFunction());
|
||||
else if (constructorDecl->getClassScopeSpecializationPattern())
|
||||
constructorDecl = dyn_cast<CXXConstructorDecl>(constructorDecl->getClassScopeSpecializationPattern());
|
||||
// workaround clang-3.5 issue
|
||||
#if CLANG_VERSION >= 30600
|
||||
else if (constructorDecl->getTemplateInstantiationPattern())
|
||||
constructorDecl = dyn_cast<CXXConstructorDecl>(constructorDecl->getTemplateInstantiationPattern());
|
||||
#endif
|
||||
int n = constructorDecl->getNumParams() - 1;
|
||||
if (n < 0 || !constructorDecl->getParamDecl(n)->hasDefaultArg()) {
|
||||
return true;
|
||||
|
@@ -100,8 +100,6 @@ bool DataMemberShadow::VisitFieldDecl(FieldDecl const * fieldDecl)
|
||||
|
||||
fieldDecl = fieldDecl->getCanonicalDecl();
|
||||
|
||||
#if CLANG_VERSION >= 30800
|
||||
|
||||
auto BaseMatchesCallback = [&](const CXXBaseSpecifier *cxxBaseSpecifier, CXXBasePath& Paths)
|
||||
{
|
||||
if (!cxxBaseSpecifier->getType().getTypePtr())
|
||||
@@ -143,7 +141,6 @@ bool DataMemberShadow::VisitFieldDecl(FieldDecl const * fieldDecl)
|
||||
|
||||
CXXBasePaths aPaths;
|
||||
parentCXXRecordDecl->lookupInBases(BaseMatchesCallback, aPaths);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -116,11 +116,8 @@ MyFuncInfo ExpandableMethods::niceName(const FunctionDecl* functionDecl)
|
||||
functionDecl = functionDecl->getInstantiatedFromMemberFunction();
|
||||
else if (functionDecl->getClassScopeSpecializationPattern())
|
||||
functionDecl = functionDecl->getClassScopeSpecializationPattern();
|
||||
// workaround clang-3.5 issue
|
||||
#if CLANG_VERSION >= 30600
|
||||
else if (functionDecl->getTemplateInstantiationPattern())
|
||||
functionDecl = functionDecl->getTemplateInstantiationPattern();
|
||||
#endif
|
||||
|
||||
MyFuncInfo aInfo;
|
||||
switch (functionDecl->getAccess())
|
||||
@@ -131,7 +128,7 @@ MyFuncInfo ExpandableMethods::niceName(const FunctionDecl* functionDecl)
|
||||
default: aInfo.access = "unknown"; break;
|
||||
}
|
||||
if (!isa<CXXConstructorDecl>(functionDecl)) {
|
||||
aInfo.returnType = compat::getReturnType(*functionDecl).getCanonicalType().getAsString();
|
||||
aInfo.returnType = functionDecl->getReturnType().getCanonicalType().getAsString();
|
||||
} else {
|
||||
aInfo.returnType = "";
|
||||
}
|
||||
|
@@ -13,7 +13,6 @@
|
||||
// only compile this on clang 3.7 or higher, which is known to work
|
||||
// there were problems on clang 3.5 at least
|
||||
#include "config_clang.h"
|
||||
#if CLANG_VERSION >= 30700
|
||||
#include <cassert>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
@@ -312,6 +311,5 @@ loplugin::Plugin::Registration<GetImplementationName> X(
|
||||
"getimplementationname", false);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@@ -19,30 +19,6 @@
|
||||
#include "compat.hxx"
|
||||
#include "plugin.hxx"
|
||||
|
||||
#if CLANG_VERSION < 30700
|
||||
|
||||
namespace std {
|
||||
|
||||
template<> struct iterator_traits<ExprIterator> {
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef Expr * value_type;
|
||||
typedef Expr const ** pointer;
|
||||
typedef Expr const & reference;
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
};
|
||||
|
||||
template<> struct iterator_traits<ConstExprIterator> {
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef Expr const * value_type;
|
||||
typedef Expr const ** pointer;
|
||||
typedef Expr const & reference;
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
Expr const * ignoreParenAndTemporaryMaterialization(Expr const * expr) {
|
||||
@@ -334,19 +310,19 @@ bool ImplicitBoolConversion::TraverseCallExpr(CallExpr * expr) {
|
||||
std::ptrdiff_t n = j - expr->arg_begin();
|
||||
assert(n >= 0);
|
||||
if (t != nullptr
|
||||
&& static_cast<std::size_t>(n) >= compat::getNumParams(*t))
|
||||
&& static_cast<std::size_t>(n) >= t->getNumParams())
|
||||
{
|
||||
assert(t->isVariadic());
|
||||
// ignore bool to int promotions of variadic arguments
|
||||
} else if (bExt) {
|
||||
if (t != nullptr) {
|
||||
assert(
|
||||
static_cast<std::size_t>(n) < compat::getNumParams(*t));
|
||||
if (!(compat::getParamType(*t, n)->isSpecificBuiltinType(
|
||||
static_cast<std::size_t>(n) < t->getNumParams());
|
||||
if (!(t->getParamType(n)->isSpecificBuiltinType(
|
||||
BuiltinType::Int)
|
||||
|| compat::getParamType(*t, n)->isSpecificBuiltinType(
|
||||
|| t->getParamType(n)->isSpecificBuiltinType(
|
||||
BuiltinType::UInt)
|
||||
|| compat::getParamType(*t, n)->isSpecificBuiltinType(
|
||||
|| t->getParamType(n)->isSpecificBuiltinType(
|
||||
BuiltinType::Long)))
|
||||
{
|
||||
reportWarning(i);
|
||||
@@ -831,7 +807,7 @@ bool ImplicitBoolConversion::TraverseReturnStmt(ReturnStmt * stmt) {
|
||||
bool ImplicitBoolConversion::TraverseFunctionDecl(FunctionDecl * decl) {
|
||||
bool bExt = false;
|
||||
if (hasCLanguageLinkageType(decl) && decl->isThisDeclarationADefinition()) {
|
||||
QualType t { compat::getReturnType(*decl) };
|
||||
QualType t { decl->getReturnType() };
|
||||
if (t->isSpecificBuiltinType(BuiltinType::Int)
|
||||
|| t->isSpecificBuiltinType(BuiltinType::UInt))
|
||||
{
|
||||
|
@@ -7,6 +7,8 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "compat.hxx"
|
||||
#include "plugin.hxx"
|
||||
|
||||
@@ -16,7 +18,7 @@ class IncludeForm final: public PPCallbacks, public loplugin::RewritePlugin {
|
||||
public:
|
||||
explicit IncludeForm(loplugin::InstantiationData const & data):
|
||||
RewritePlugin(data)
|
||||
{ compat::addPPCallbacks(compiler.getPreprocessor(), this); }
|
||||
{ compiler.getPreprocessor().addPPCallbacks(std::unique_ptr<PPCallbacks>(this)); }
|
||||
|
||||
private:
|
||||
void run() override {}
|
||||
|
@@ -31,10 +31,10 @@ private:
|
||||
};
|
||||
|
||||
static bool oneAndOnlyOne(clang::Stmt::const_child_range range) {
|
||||
if (compat::begin(range) == compat::end(range)) {
|
||||
if (range.begin() == range.end()) {
|
||||
return false;
|
||||
}
|
||||
if (++compat::begin(range) != compat::end(range)) {
|
||||
if (++range.begin() != range.end()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -133,7 +133,7 @@ bool InlineSimpleMemberFunctions::VisitCXXMethodDecl(const CXXMethodDecl * funct
|
||||
{
|
||||
childStmt2 = *childStmt2->child_begin();
|
||||
if (dyn_cast<CXXThisExpr>( childStmt2 ) != nullptr
|
||||
&& compat::begin(childStmt2->children()) == compat::end(childStmt2->children()))
|
||||
&& childStmt2->children().begin() == childStmt2->children().end())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -144,7 +144,7 @@ bool InlineSimpleMemberFunctions::VisitCXXMethodDecl(const CXXMethodDecl * funct
|
||||
{
|
||||
const Stmt* childStmt2 = *childStmt->child_begin();
|
||||
if (dyn_cast<CXXThisExpr>( childStmt2 ) != nullptr
|
||||
&& compat::begin(childStmt2->children()) == compat::end(childStmt2->children()))
|
||||
&& childStmt2->children().begin() == childStmt2->children().end())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -207,7 +207,7 @@ bool InlineSimpleMemberFunctions::VisitCXXMethodDecl(const CXXMethodDecl * funct
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if ( compat::begin(childStmt->children()) == compat::end(childStmt->children()) )
|
||||
if ( childStmt->children().begin() == childStmt->children().end() )
|
||||
return true;
|
||||
childStmt = *childStmt->child_begin();
|
||||
}
|
||||
|
@@ -8,8 +8,8 @@
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
|
||||
#include "compat.hxx"
|
||||
#include "plugin.hxx"
|
||||
|
||||
namespace {
|
||||
@@ -17,7 +17,7 @@ namespace {
|
||||
class OslEndian: public loplugin::Plugin, public PPCallbacks {
|
||||
public:
|
||||
explicit OslEndian(loplugin::InstantiationData const & data): Plugin(data) {
|
||||
compat::addPPCallbacks(compiler.getPreprocessor(), this);
|
||||
compiler.getPreprocessor().addPPCallbacks(std::unique_ptr<PPCallbacks>(this));
|
||||
}
|
||||
|
||||
enum { isPPCallback = true };
|
||||
@@ -59,7 +59,7 @@ private:
|
||||
}
|
||||
|
||||
void MacroUndefined(
|
||||
Token const & MacroNameTok, compat::MacroDefinitionParam
|
||||
Token const & MacroNameTok, MacroDefinition const &
|
||||
#if CLANG_VERSION >= 50000
|
||||
, MacroDirective const *
|
||||
#endif
|
||||
@@ -75,7 +75,7 @@ private:
|
||||
}
|
||||
|
||||
void Defined(
|
||||
Token const & MacroNameTok, compat::MacroDefinitionParam, SourceRange)
|
||||
Token const & MacroNameTok, MacroDefinition const &, SourceRange)
|
||||
override
|
||||
{
|
||||
check(MacroNameTok);
|
||||
@@ -83,14 +83,14 @@ private:
|
||||
|
||||
void Ifdef(
|
||||
SourceLocation, Token const & MacroNameTok,
|
||||
compat::MacroDefinitionParam) override
|
||||
MacroDefinition const &) override
|
||||
{
|
||||
check(MacroNameTok);
|
||||
}
|
||||
|
||||
void Ifndef(
|
||||
SourceLocation, Token const & MacroNameTok,
|
||||
compat::MacroDefinitionParam) override
|
||||
MacroDefinition const &) override
|
||||
{
|
||||
check(MacroNameTok);
|
||||
}
|
||||
|
@@ -11,7 +11,6 @@
|
||||
#include <set>
|
||||
|
||||
#include "check.hxx"
|
||||
#include "compat.hxx"
|
||||
#include "plugin.hxx"
|
||||
|
||||
// Find places where various things are passed by value.
|
||||
@@ -222,7 +221,7 @@ void PassStuffByRef::checkReturnValue(const FunctionDecl * functionDecl, const C
|
||||
return;
|
||||
}
|
||||
|
||||
const QualType type = compat::getReturnType(*functionDecl).getDesugaredType(compiler.getASTContext());
|
||||
const QualType type = functionDecl->getReturnType().getDesugaredType(compiler.getASTContext());
|
||||
if (type->isReferenceType() || type->isIntegralOrEnumerationType() || type->isPointerType()
|
||||
|| type->isTemplateTypeParmType() || type->isDependentType() || type->isBuiltinType()
|
||||
|| type->isScalarType())
|
||||
|
@@ -10,7 +10,8 @@
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include "compat.hxx"
|
||||
#include <system_error>
|
||||
|
||||
#include "plugin.hxx"
|
||||
#include "pluginhandler.hxx"
|
||||
|
||||
@@ -168,9 +169,9 @@ DiagnosticBuilder PluginHandler::report( DiagnosticsEngine::Level level, const c
|
||||
}
|
||||
fullMessage += "]";
|
||||
if( loc.isValid())
|
||||
return diag.Report( loc, compat::getCustomDiagID(diag, level, fullMessage) );
|
||||
return diag.Report( loc, diag.getDiagnosticIDs()->getCustomDiagID(static_cast<DiagnosticIDs::Level>(level), fullMessage) );
|
||||
else
|
||||
return diag.Report( compat::getCustomDiagID(diag, level, fullMessage) );
|
||||
return diag.Report( diag.getDiagnosticIDs()->getCustomDiagID(static_cast<DiagnosticIDs::Level>(level), fullMessage) );
|
||||
}
|
||||
|
||||
DiagnosticBuilder PluginHandler::report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc )
|
||||
@@ -305,15 +306,18 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context )
|
||||
sprintf( filename, "%s.new.%d", modifyFile.c_str(), getpid());
|
||||
std::string error;
|
||||
bool bOk = false;
|
||||
std::error_code ec;
|
||||
std::unique_ptr<raw_fd_ostream> ostream(
|
||||
compat::create_raw_fd_ostream(filename, error) );
|
||||
if( error.empty())
|
||||
new raw_fd_ostream(filename, ec, sys::fs::F_None));
|
||||
if( !ec)
|
||||
{
|
||||
it->second.write( *ostream );
|
||||
ostream->close();
|
||||
if( !ostream->has_error() && rename( filename, modifyFile.c_str()) == 0 )
|
||||
bOk = true;
|
||||
}
|
||||
else
|
||||
error = "error: " + ec.message();
|
||||
ostream->clear_error();
|
||||
unlink( filename );
|
||||
if( !bOk )
|
||||
@@ -323,17 +327,10 @@ void PluginHandler::HandleTranslationUnit( ASTContext& context )
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CLANG_VERSION >= 30600
|
||||
std::unique_ptr<ASTConsumer> LibreOfficeAction::CreateASTConsumer( CompilerInstance& Compiler, StringRef )
|
||||
{
|
||||
return llvm::make_unique<PluginHandler>( Compiler, _args );
|
||||
}
|
||||
#else
|
||||
ASTConsumer* LibreOfficeAction::CreateASTConsumer( CompilerInstance& Compiler, StringRef )
|
||||
{
|
||||
return new PluginHandler( Compiler, _args );
|
||||
}
|
||||
#endif
|
||||
|
||||
bool LibreOfficeAction::ParseArgs( const CompilerInstance&, const std::vector< std::string >& args )
|
||||
{
|
||||
|
@@ -80,11 +80,7 @@ class LibreOfficeAction
|
||||
: public PluginASTAction
|
||||
{
|
||||
public:
|
||||
#if CLANG_VERSION >= 30600
|
||||
virtual std::unique_ptr<ASTConsumer> CreateASTConsumer( CompilerInstance& Compiler, StringRef InFile );
|
||||
#else
|
||||
virtual ASTConsumer* CreateASTConsumer( CompilerInstance& Compiler, StringRef InFile );
|
||||
#endif
|
||||
|
||||
virtual bool ParseArgs( const CompilerInstance& CI, const std::vector< std::string >& args );
|
||||
private:
|
||||
|
@@ -103,20 +103,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
bool TraverseInitListExpr(
|
||||
InitListExpr * expr
|
||||
#if CLANG_VERSION >= 30800
|
||||
, DataRecursionQueue * queue = nullptr
|
||||
#endif
|
||||
)
|
||||
{
|
||||
bool TraverseInitListExpr(InitListExpr * expr, DataRecursionQueue * queue = nullptr) {
|
||||
return WalkUpFromInitListExpr(expr)
|
||||
&& TraverseSynOrSemInitListExpr(
|
||||
expr->isSemanticForm() ? expr : expr->getSemanticForm()
|
||||
#if CLANG_VERSION >= 30800
|
||||
, queue
|
||||
#endif
|
||||
);
|
||||
expr->isSemanticForm() ? expr : expr->getSemanticForm(), queue);
|
||||
}
|
||||
|
||||
bool VisitImplicitCastExpr(ImplicitCastExpr const * expr);
|
||||
@@ -806,7 +796,7 @@ bool RedundantCast::visitBinOp(BinaryOperator const * expr) {
|
||||
|
||||
bool RedundantCast::isOverloadedFunction(FunctionDecl const * decl) {
|
||||
auto const ctx = decl->getDeclContext();
|
||||
if (!compat::isLookupContext(*ctx)) {
|
||||
if (!ctx->isLookupContext()) {
|
||||
return false;
|
||||
}
|
||||
auto const canon = decl->getCanonicalDecl();
|
||||
|
@@ -11,7 +11,6 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "check.hxx"
|
||||
#include "compat.hxx"
|
||||
#include "plugin.hxx"
|
||||
#include "clang/AST/CXXInheritance.h"
|
||||
|
||||
@@ -95,15 +94,10 @@ bool isDerivedFrom(const CXXRecordDecl *decl, DeclChecker base) {
|
||||
if (!decl->hasDefinition()) {
|
||||
return false;
|
||||
}
|
||||
if (!compat::forallBases(
|
||||
*decl,
|
||||
#if CLANG_VERSION < 30800
|
||||
BaseCheckNotSubclass,
|
||||
#else
|
||||
if (!decl->forallBases(
|
||||
[&base](const CXXRecordDecl *BaseDefinition) -> bool
|
||||
{ return BaseCheckNotSubclass(BaseDefinition, &base); },
|
||||
#endif
|
||||
&base, true))
|
||||
true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -550,7 +544,7 @@ bool RefCounting::VisitFunctionDecl(const FunctionDecl * functionDecl) {
|
||||
if (methodDecl && methodDecl->size_overridden_methods() > 0) {
|
||||
return true;
|
||||
}
|
||||
checkUnoReference(compat::getReturnType(*functionDecl), functionDecl, nullptr, "return");
|
||||
checkUnoReference(functionDecl->getReturnType(), functionDecl, nullptr, "return");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -59,7 +59,6 @@ void ReservedId::run() {
|
||||
if (TraverseDecl(compiler.getASTContext().getTranslationUnitDecl())
|
||||
&& compiler.hasPreprocessor())
|
||||
{
|
||||
#if CLANG_VERSION >= 30700
|
||||
auto & prep = compiler.getPreprocessor();
|
||||
for (auto const & m: prep.macros(false)) {
|
||||
auto id = m.first->getName();
|
||||
@@ -129,7 +128,6 @@ void ReservedId::run() {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -108,7 +108,7 @@ BoolOverloadKind isBoolOverloadOf(
|
||||
// encounter in practice:
|
||||
bool hasBoolOverload(FunctionDecl const * decl, bool mustBeDeleted) {
|
||||
auto ctx = decl->getDeclContext();
|
||||
if (!compat::isLookupContext(*ctx)) {
|
||||
if (!ctx->isLookupContext()) {
|
||||
return false;
|
||||
}
|
||||
auto res = ctx->lookup(decl->getDeclName());
|
||||
@@ -285,8 +285,8 @@ bool SalBool::VisitCallExpr(CallExpr * expr) {
|
||||
}
|
||||
}
|
||||
if (ft != nullptr) {
|
||||
for (unsigned i = 0; i != compat::getNumParams(*ft); ++i) {
|
||||
QualType t(compat::getParamType(*ft, i));
|
||||
for (unsigned i = 0; i != ft->getNumParams(); ++i) {
|
||||
QualType t(ft->getParamType(i));
|
||||
bool b = false;
|
||||
if (t->isLValueReferenceType()) {
|
||||
t = t.getNonReferenceType();
|
||||
@@ -688,7 +688,7 @@ bool SalBool::VisitFunctionDecl(FunctionDecl const * decl) {
|
||||
if (ignoreLocation(decl)) {
|
||||
return true;
|
||||
}
|
||||
if (isSalBool(compat::getReturnType(*decl).getNonReferenceType())
|
||||
if (isSalBool(decl->getReturnType().getNonReferenceType())
|
||||
&& !(decl->isDeletedAsWritten() && isa<CXXConversionDecl>(decl)))
|
||||
{
|
||||
FunctionDecl const * f = decl->getCanonicalDecl();
|
||||
|
@@ -11,7 +11,6 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "plugin.hxx"
|
||||
#include "compat.hxx"
|
||||
#include "check.hxx"
|
||||
#include "clang/AST/CXXInheritance.h"
|
||||
|
||||
@@ -34,13 +33,7 @@ public:
|
||||
bool VisitCXXRecordDecl( const CXXRecordDecl* );
|
||||
};
|
||||
|
||||
bool BaseCheckNotSfxPoolItemSubclass(
|
||||
const CXXRecordDecl *BaseDefinition
|
||||
#if CLANG_VERSION < 30800
|
||||
, void *
|
||||
#endif
|
||||
)
|
||||
{
|
||||
bool BaseCheckNotSfxPoolItemSubclass(const CXXRecordDecl *BaseDefinition) {
|
||||
if (BaseDefinition && loplugin::TypeCheck(BaseDefinition).Class("SfxPoolItem").GlobalNamespace()) {
|
||||
return false;
|
||||
}
|
||||
@@ -58,20 +51,14 @@ bool isDerivedFromSfxPoolItem(const CXXRecordDecl *decl) {
|
||||
if (// not sure what hasAnyDependentBases() does,
|
||||
// but it avoids classes we don't want, e.g. WeakAggComponentImplHelper1
|
||||
!decl->hasAnyDependentBases() &&
|
||||
!compat::forallBases(*decl, BaseCheckNotSfxPoolItemSubclass, nullptr, true)) {
|
||||
!decl->forallBases(BaseCheckNotSfxPoolItemSubclass, true)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool BaseCheckNotSwMsgPoolItemSubclass(
|
||||
const CXXRecordDecl *BaseDefinition
|
||||
#if CLANG_VERSION < 30800
|
||||
, void *
|
||||
#endif
|
||||
)
|
||||
{
|
||||
bool BaseCheckNotSwMsgPoolItemSubclass(const CXXRecordDecl *BaseDefinition) {
|
||||
if (BaseDefinition && loplugin::TypeCheck(BaseDefinition).Class("SwMsgPoolItem")) {
|
||||
return false;
|
||||
}
|
||||
@@ -89,7 +76,7 @@ bool isDerivedFromSwMsgPoolItem(const CXXRecordDecl *decl) {
|
||||
if (// not sure what hasAnyDependentBases() does,
|
||||
// but it avoids classes we don't want, e.g. WeakAggComponentImplHelper1
|
||||
!decl->hasAnyDependentBases() &&
|
||||
!compat::forallBases(*decl, BaseCheckNotSwMsgPoolItemSubclass, nullptr, true)) {
|
||||
!decl->forallBases(BaseCheckNotSwMsgPoolItemSubclass, true)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@@ -13,7 +13,6 @@
|
||||
#include <fstream>
|
||||
#include <set>
|
||||
#include "plugin.hxx"
|
||||
#include "compat.hxx"
|
||||
|
||||
/**
|
||||
Look for fields that are only ever assigned a single constant value.
|
||||
@@ -262,7 +261,7 @@ bool SingleValFields::VisitMemberExpr( const MemberExpr* memberExpr )
|
||||
if (parentFunction && parent && isa<ReturnStmt>(parent)) {
|
||||
const Stmt* parent2 = getParentStmt(parent);
|
||||
if (parent2 && isa<CompoundStmt>(parent2)) {
|
||||
QualType qt = compat::getReturnType(*parentFunction).getDesugaredType(compiler.getASTContext());
|
||||
QualType qt = parentFunction->getReturnType().getDesugaredType(compiler.getASTContext());
|
||||
if (!qt.isConstQualified() && qt->isReferenceType()) {
|
||||
bPotentiallyAssignedTo = true;
|
||||
}
|
||||
@@ -449,10 +448,10 @@ void SingleValFields::checkCallExpr(const Stmt* child, const CallExpr* callExpr,
|
||||
return;
|
||||
}
|
||||
for (unsigned i = 0; i < callExpr->getNumArgs(); ++i) {
|
||||
if (i >= compat::getNumParams(*proto)) // can happen in template code
|
||||
if (i >= proto->getNumParams()) // can happen in template code
|
||||
break;
|
||||
if (callExpr->getArg(i) == child) {
|
||||
QualType qt = compat::getParamType(*proto, i).getDesugaredType(compiler.getASTContext());
|
||||
QualType qt = proto->getParamType(i).getDesugaredType(compiler.getASTContext());
|
||||
if (!qt.isConstQualified() && qt->isReferenceType()) {
|
||||
assignValue = "?";
|
||||
bPotentiallyAssignedTo = true;
|
||||
|
@@ -10,7 +10,6 @@
|
||||
#include "clang/AST/Attr.h"
|
||||
|
||||
#include "check.hxx"
|
||||
#include "compat.hxx"
|
||||
#include "plugin.hxx"
|
||||
|
||||
/*
|
||||
@@ -39,13 +38,7 @@ private:
|
||||
StringRef getFilename(SourceLocation loc);
|
||||
};
|
||||
|
||||
bool BaseCheckNotTestFixtureSubclass(
|
||||
const CXXRecordDecl *BaseDefinition
|
||||
#if CLANG_VERSION < 30800
|
||||
, void *
|
||||
#endif
|
||||
)
|
||||
{
|
||||
bool BaseCheckNotTestFixtureSubclass(const CXXRecordDecl *BaseDefinition) {
|
||||
if (loplugin::TypeCheck(BaseDefinition).Class("TestFixture").Namespace("CppUnit").GlobalNamespace()) {
|
||||
return false;
|
||||
}
|
||||
@@ -58,7 +51,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() &&
|
||||
!compat::forallBases(*decl, BaseCheckNotTestFixtureSubclass, nullptr, true)) {
|
||||
!decl->forallBases(BaseCheckNotTestFixtureSubclass, true)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@@ -11,7 +11,6 @@
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include "plugin.hxx"
|
||||
#include "compat.hxx"
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
@@ -75,7 +74,7 @@ std::string niceName(const CXXMethodDecl* functionDecl)
|
||||
{
|
||||
std::string s =
|
||||
functionDecl->getParent()->getQualifiedNameAsString() + "::"
|
||||
+ compat::getReturnType(*functionDecl).getAsString() + "-"
|
||||
+ functionDecl->getReturnType().getAsString() + "-"
|
||||
+ functionDecl->getNameAsString() + "(";
|
||||
for (const ParmVarDecl *pParmVarDecl : functionDecl->params()) {
|
||||
s += pParmVarDecl->getType().getAsString();
|
||||
|
@@ -10,7 +10,6 @@
|
||||
#include <string>
|
||||
#include <set>
|
||||
|
||||
#include "compat.hxx"
|
||||
#include "plugin.hxx"
|
||||
|
||||
// Find places where we are returning a pointer to something, where we can be returning a reference.
|
||||
@@ -55,7 +54,7 @@ bool ReturnByRef::VisitCXXMethodDecl(const CXXMethodDecl * functionDecl) {
|
||||
if (isInUnoIncludeFile(functionDecl)) {
|
||||
return true;
|
||||
}
|
||||
QualType t1 { compat::getReturnType(*functionDecl) };
|
||||
QualType t1 { functionDecl->getReturnType() };
|
||||
if (!t1->isPointerType()) {
|
||||
return true;
|
||||
}
|
||||
|
@@ -11,8 +11,6 @@
|
||||
|
||||
#include <config_clang.h>
|
||||
|
||||
// '#if CLANG_VERSION >= 30800' covers large parts of compilerplugins/clang/datamembershadow.cxx
|
||||
#if CLANG_VERSION >= 30800
|
||||
struct Bar {
|
||||
int x; // expected-note {{superclass member here [loplugin:datamembershadow]}}
|
||||
};
|
||||
@@ -20,8 +18,5 @@ struct Bar {
|
||||
struct Foo : public Bar {
|
||||
int x; // expected-error {{data member x is shadowing member in superclass, through inheritance path Foo->Bar [loplugin:datamembershadow]}}
|
||||
};
|
||||
#else
|
||||
// expected-no-diagnostics
|
||||
#endif
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||
|
@@ -14,7 +14,6 @@
|
||||
#include <set>
|
||||
|
||||
#include <clang/AST/CXXInheritance.h>
|
||||
#include "compat.hxx"
|
||||
#include "plugin.hxx"
|
||||
|
||||
/**
|
||||
@@ -102,12 +101,7 @@ public:
|
||||
|
||||
private:
|
||||
const CXXMethodDecl * findOverriddenOrSimilarMethodInSuperclasses(const CXXMethodDecl *);
|
||||
bool BaseCheckCallback(
|
||||
const CXXRecordDecl *BaseDefinition
|
||||
#if CLANG_VERSION < 30800
|
||||
, void *
|
||||
#endif
|
||||
);
|
||||
bool BaseCheckCallback(const CXXRecordDecl *BaseDefinition);
|
||||
};
|
||||
|
||||
bool UnnecessaryOverride::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl)
|
||||
@@ -277,8 +271,8 @@ bool UnnecessaryOverride::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl)
|
||||
}
|
||||
}
|
||||
|
||||
if (compat::getReturnType(*methodDecl).getCanonicalType()
|
||||
!= compat::getReturnType(*overriddenMethodDecl).getCanonicalType())
|
||||
if (methodDecl->getReturnType().getCanonicalType()
|
||||
!= overriddenMethodDecl->getReturnType().getCanonicalType())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -290,7 +284,7 @@ bool UnnecessaryOverride::VisitCXXMethodDecl(const CXXMethodDecl* methodDecl)
|
||||
return true;
|
||||
|
||||
const CXXMemberCallExpr* callExpr = nullptr;
|
||||
if (compat::getReturnType(*methodDecl).getCanonicalType()->isVoidType())
|
||||
if (methodDecl->getReturnType().getCanonicalType()->isVoidType())
|
||||
{
|
||||
if (auto const e = dyn_cast<Expr>(*compoundStmt->body_begin())) {
|
||||
callExpr = dyn_cast<CXXMemberCallExpr>(e->IgnoreImplicit()->IgnoreParens());
|
||||
@@ -395,9 +389,6 @@ const CXXMethodDecl* UnnecessaryOverride::findOverriddenOrSimilarMethodInSupercl
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#if CLANG_VERSION < 30800
|
||||
return nullptr;
|
||||
#else
|
||||
std::vector<const CXXMethodDecl*> maSimilarMethods;
|
||||
|
||||
auto BaseMatchesCallback = [&](const CXXBaseSpecifier *cxxBaseSpecifier, CXXBasePath& )
|
||||
@@ -425,8 +416,8 @@ const CXXMethodDecl* UnnecessaryOverride::findOverriddenOrSimilarMethodInSupercl
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (compat::getReturnType(*methodDecl).getCanonicalType()
|
||||
!= compat::getReturnType(*baseMethod).getCanonicalType())
|
||||
if (methodDecl->getReturnType().getCanonicalType()
|
||||
!= baseMethod->getReturnType().getCanonicalType())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -454,7 +445,6 @@ const CXXMethodDecl* UnnecessaryOverride::findOverriddenOrSimilarMethodInSupercl
|
||||
return maSimilarMethods[0];
|
||||
}
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@@ -84,7 +84,7 @@ std::string niceName(const CXXMethodDecl* functionDecl)
|
||||
{
|
||||
std::string s =
|
||||
functionDecl->getParent()->getQualifiedNameAsString() + "::"
|
||||
+ compat::getReturnType(*functionDecl).getAsString() + "-"
|
||||
+ functionDecl->getReturnType().getAsString() + "-"
|
||||
+ functionDecl->getNameAsString() + "(";
|
||||
for (const ParmVarDecl *pParmVarDecl : compat::parameters(*functionDecl)) {
|
||||
s += pParmVarDecl->getType().getAsString();
|
||||
|
@@ -136,11 +136,8 @@ MyFuncInfo UnusedMethods::niceName(const FunctionDecl* functionDecl)
|
||||
functionDecl = functionDecl->getInstantiatedFromMemberFunction();
|
||||
else if (functionDecl->getClassScopeSpecializationPattern())
|
||||
functionDecl = functionDecl->getClassScopeSpecializationPattern();
|
||||
// workaround clang-3.5 issue
|
||||
#if CLANG_VERSION >= 30600
|
||||
else if (functionDecl->getTemplateInstantiationPattern())
|
||||
functionDecl = functionDecl->getTemplateInstantiationPattern();
|
||||
#endif
|
||||
|
||||
MyFuncInfo aInfo;
|
||||
switch (functionDecl->getAccess())
|
||||
@@ -151,7 +148,7 @@ MyFuncInfo UnusedMethods::niceName(const FunctionDecl* functionDecl)
|
||||
default: aInfo.access = "unknown"; break;
|
||||
}
|
||||
if (!isa<CXXConstructorDecl>(functionDecl)) {
|
||||
aInfo.returnType = compat::getReturnType(*functionDecl).getCanonicalType().getAsString();
|
||||
aInfo.returnType = functionDecl->getReturnType().getCanonicalType().getAsString();
|
||||
} else {
|
||||
aInfo.returnType = "";
|
||||
}
|
||||
@@ -262,7 +259,7 @@ gotfunc:
|
||||
}
|
||||
|
||||
// Now do the checks necessary for the "unused return value" analysis
|
||||
if (compat::getReturnType(*calleeFunctionDecl)->isVoidType()) {
|
||||
if (calleeFunctionDecl->getReturnType()->isVoidType()) {
|
||||
return true;
|
||||
}
|
||||
if (!parent) {
|
||||
|
@@ -76,7 +76,7 @@ UnusedMethodsRemove::~UnusedMethodsRemove()
|
||||
std::string niceName(const CXXMethodDecl* functionDecl)
|
||||
{
|
||||
std::string s =
|
||||
compat::getReturnType(*functionDecl).getCanonicalType().getAsString()
|
||||
functionDecl->getReturnType().getCanonicalType().getAsString()
|
||||
+ " " + functionDecl->getParent()->getQualifiedNameAsString()
|
||||
+ "::" + functionDecl->getNameAsString()
|
||||
+ "(";
|
||||
|
@@ -12,7 +12,6 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "plugin.hxx"
|
||||
#include "compat.hxx"
|
||||
#include "check.hxx"
|
||||
#include "clang/AST/CXXInheritance.h"
|
||||
|
||||
@@ -55,13 +54,7 @@ private:
|
||||
|
||||
#define BASE_REF_COUNTED_CLASS "VclReferenceBase"
|
||||
|
||||
bool BaseCheckNotWindowSubclass(
|
||||
const CXXRecordDecl *BaseDefinition
|
||||
#if CLANG_VERSION < 30800
|
||||
, void *
|
||||
#endif
|
||||
)
|
||||
{
|
||||
bool BaseCheckNotWindowSubclass(const CXXRecordDecl *BaseDefinition) {
|
||||
return !loplugin::DeclCheck(BaseDefinition).Class(BASE_REF_COUNTED_CLASS)
|
||||
.GlobalNamespace();
|
||||
}
|
||||
@@ -80,7 +73,7 @@ bool isDerivedFromVclReferenceBase(const CXXRecordDecl *decl) {
|
||||
if (// not sure what hasAnyDependentBases() does,
|
||||
// but it avoids classes we don't want, e.g. WeakAggComponentImplHelper1
|
||||
!decl->hasAnyDependentBases() &&
|
||||
!compat::forallBases(*decl, BaseCheckNotWindowSubclass, nullptr, true)) {
|
||||
!decl->forallBases(BaseCheckNotWindowSubclass, true)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
10
configure.ac
10
configure.ac
@@ -5921,8 +5921,7 @@ if test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
|
||||
], [AC_MSG_RESULT([no])])
|
||||
AC_LANG_POP([C++])
|
||||
|
||||
dnl Available in GCC 4.9 and at least in Clang 3.4 (which is the baseline
|
||||
dnl for at least --enable-compiler-plugins according to README.md):
|
||||
dnl Available in GCC 4.9 and at least since Clang 3.4:
|
||||
AC_MSG_CHECKING([whether $CXX supports __attribute__((warn_unused))])
|
||||
AC_LANG_PUSH([C++])
|
||||
save_CXXFLAGS=$CXXFLAGS
|
||||
@@ -6419,6 +6418,13 @@ if test "$COM_IS_CLANG" = "TRUE"; then
|
||||
else
|
||||
compiler_plugins=no
|
||||
fi
|
||||
if test "$compiler_plugins" != no -a "$CLANGVER" -lt 30800; then
|
||||
if test "$compiler_plugins" = yes; then
|
||||
AC_MSG_ERROR([Clang $CLANGVER is too old to build compiler plugins; need >= 3.8.0.])
|
||||
else
|
||||
compiler_plugins=no
|
||||
fi
|
||||
fi
|
||||
if test "$compiler_plugins" != "no"; then
|
||||
dnl The prefix where Clang resides, override to where Clang resides if
|
||||
dnl using a source build:
|
||||
|
Reference in New Issue
Block a user