forked from amazingfate/loongoffice
Bump compiler plugins Clang baseline to 5.0.2
...as discussed at <https://lists.freedesktop.org/archives/libreoffice/2018-November/081435.html> "minutes of ESC call ..." Change-Id: Ia053da171d59747984546f38e19da808825b4f79 Reviewed-on: https://gerrit.libreoffice.org/63832 Tested-by: Jenkins 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.8. Since Xcode doesn't provide the compiler plugin
|
||||
version of Clang is 5.0.2. 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.
|
||||
|
||||
@ -105,7 +105,6 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if CLANG_VERSION >= 50000
|
||||
bool TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl * decl) {
|
||||
returnTypes_.push(decl->getReturnType());
|
||||
auto const ret = RecursiveASTVisitor::TraverseCXXDeductionGuideDecl(
|
||||
@ -115,7 +114,6 @@ public:
|
||||
returnTypes_.pop();
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool TraverseCXXMethodDecl(CXXMethodDecl * decl) {
|
||||
returnTypes_.push(decl->getReturnType());
|
||||
@ -489,7 +487,7 @@ private:
|
||||
}
|
||||
auto const loc = compat::getBeginLoc(dre);
|
||||
if (compiler.getSourceManager().isMacroArgExpansion(loc)
|
||||
&& (compat::getImmediateMacroNameForDiagnostics(
|
||||
&& (Lexer::getImmediateMacroNameForDiagnostics(
|
||||
loc, compiler.getSourceManager(), compiler.getLangOpts())
|
||||
== "assert"))
|
||||
{
|
||||
|
||||
@ -37,11 +37,7 @@ 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, MacroDefinition const &
|
||||
#if CLANG_VERSION >= 50000
|
||||
, MacroDirective const *
|
||||
#endif
|
||||
) override;
|
||||
virtual void MacroUndefined( const Token& macroToken, MacroDefinition const &, MacroDirective const * ) 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;
|
||||
@ -75,11 +71,7 @@ void CheckConfigMacros::MacroDefined( const Token& macroToken, const MacroDirect
|
||||
}
|
||||
}
|
||||
|
||||
void CheckConfigMacros::MacroUndefined( const Token& macroToken, MacroDefinition const &
|
||||
#if CLANG_VERSION >= 50000
|
||||
, MacroDirective const *
|
||||
#endif
|
||||
)
|
||||
void CheckConfigMacros::MacroUndefined( const Token& macroToken, MacroDefinition const &, MacroDirective const * )
|
||||
{
|
||||
configMacros.erase( macroToken.getIdentifierInfo()->getName());
|
||||
}
|
||||
|
||||
@ -27,30 +27,6 @@
|
||||
// Compatibility wrapper to abstract over (trivial) changes in the Clang API:
|
||||
namespace compat {
|
||||
|
||||
inline llvm::StringRef take_front(llvm::StringRef ref, std::size_t N = 1) {
|
||||
#if CLANG_VERSION >= 40000
|
||||
return ref.take_front(N);
|
||||
#else
|
||||
auto const size = ref.size();
|
||||
return N >= size ? ref : ref.drop_back(size - N);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if CLANG_VERSION >= 30900
|
||||
inline clang::ArrayRef<clang::ParmVarDecl *> parameters(
|
||||
clang::FunctionDecl const & decl)
|
||||
{
|
||||
return decl.parameters();
|
||||
}
|
||||
#else
|
||||
inline clang::FunctionDecl::param_const_range parameters(
|
||||
clang::FunctionDecl const & decl)
|
||||
{
|
||||
return decl.params();
|
||||
}
|
||||
#endif
|
||||
|
||||
inline clang::SourceLocation getBeginLoc(clang::Decl const * decl) {
|
||||
#if CLANG_VERSION >= 80000
|
||||
return decl->getBeginLoc();
|
||||
@ -141,58 +117,6 @@ inline bool isPointWithin(
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool isMacroArgExpansion(
|
||||
clang::CompilerInstance& compiler, clang::SourceLocation location,
|
||||
clang::SourceLocation * startLocation)
|
||||
{
|
||||
#if CLANG_VERSION >= 30900
|
||||
return compiler.getSourceManager().isMacroArgExpansion(
|
||||
location, startLocation);
|
||||
#else
|
||||
bool b = compiler.getSourceManager().isMacroArgExpansion(location);
|
||||
if (b) {
|
||||
*startLocation = compiler.getSourceManager()
|
||||
.getSLocEntry(compiler.getSourceManager().getFileID(location))
|
||||
.getExpansion().getExpansionLocStart();
|
||||
}
|
||||
return b;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline llvm::StringRef getImmediateMacroNameForDiagnostics(
|
||||
clang::SourceLocation Loc, clang::SourceManager const & SM,
|
||||
clang::LangOptions const &LangOpts)
|
||||
{
|
||||
#if CLANG_VERSION >= 30900
|
||||
return clang::Lexer::getImmediateMacroNameForDiagnostics(Loc, SM, LangOpts);
|
||||
#else
|
||||
using namespace clang;
|
||||
// Verbatim copy from Clang's lib/Lex/Lexer.cpp:
|
||||
|
||||
assert(Loc.isMacroID() && "Only reasonable to call this on macros");
|
||||
// Walk past macro argument expansion.
|
||||
while (SM.isMacroArgExpansion(Loc))
|
||||
Loc = SM.getImmediateExpansionRange(Loc).first;
|
||||
|
||||
// If the macro's spelling has no FileID, then it's actually a token paste
|
||||
// or stringization (or similar) and not a macro at all.
|
||||
if (!SM.getFileEntryForID(SM.getFileID(SM.getSpellingLoc(Loc))))
|
||||
return StringRef();
|
||||
|
||||
// Find the spelling location of the start of the non-argument expansion
|
||||
// range. This is where the macro name was spelled in order to begin
|
||||
// expanding this macro.
|
||||
Loc = SM.getSpellingLoc(SM.getImmediateExpansionRange(Loc).first);
|
||||
|
||||
// Dig out the buffer where the macro name was spelled and the extents of
|
||||
// the name so that we can render it into the expansion note.
|
||||
std::pair<FileID, unsigned> ExpansionInfo = SM.getDecomposedLoc(Loc);
|
||||
unsigned MacroTokenLength = Lexer::MeasureTokenLength(Loc, SM, LangOpts);
|
||||
StringRef ExpansionBuffer = SM.getBufferData(ExpansionInfo.first);
|
||||
return ExpansionBuffer.substr(ExpansionInfo.second, MacroTokenLength);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline clang::Expr const * IgnoreImplicit(clang::Expr const * expr) {
|
||||
#if CLANG_VERSION >= 80000
|
||||
return expr->IgnoreImplicit();
|
||||
|
||||
@ -135,7 +135,7 @@ void ConstantParam::addToCallSet(const FunctionDecl* functionDecl, int paramInde
|
||||
}
|
||||
aInfo.nameAndParams += functionDecl->getNameAsString() + "(";
|
||||
bool bFirst = true;
|
||||
for (const ParmVarDecl *pParmVarDecl : compat::parameters(*functionDecl)) {
|
||||
for (const ParmVarDecl *pParmVarDecl : functionDecl->parameters()) {
|
||||
if (bFirst)
|
||||
bFirst = false;
|
||||
else
|
||||
|
||||
@ -393,10 +393,7 @@ void ConstFields::check(const FieldDecl* fieldDecl, const Expr* memberExpr)
|
||||
break;
|
||||
}
|
||||
else if (isa<CastExpr>(parent) || isa<MemberExpr>(parent) || isa<ParenExpr>(parent)
|
||||
|| isa<ParenListExpr>(parent)
|
||||
#if CLANG_VERSION >= 40000
|
||||
|| isa<ArrayInitLoopExpr>(parent)
|
||||
#endif
|
||||
|| isa<ParenListExpr>(parent) || isa<ArrayInitLoopExpr>(parent)
|
||||
|| isa<ExprWithCleanups>(parent))
|
||||
{
|
||||
walkUp();
|
||||
|
||||
@ -216,7 +216,7 @@ bool ConstParams::CheckTraverseFunctionDecl(FunctionDecl * functionDecl)
|
||||
|
||||
// calculate the ones we want to check
|
||||
bool foundInterestingParam = false;
|
||||
for (const ParmVarDecl *pParmVarDecl : compat::parameters(*functionDecl)) {
|
||||
for (const ParmVarDecl *pParmVarDecl : functionDecl->parameters()) {
|
||||
// ignore unused params
|
||||
if (pParmVarDecl->getName().empty()
|
||||
|| pParmVarDecl->hasAttr<UnusedAttr>())
|
||||
|
||||
@ -114,7 +114,7 @@ void CountUsersOfDefaultParams::niceName(const FunctionDecl* functionDecl, MyFun
|
||||
}
|
||||
aInfo.nameAndParams += functionDecl->getNameAsString() + "(";
|
||||
bool bFirst = true;
|
||||
for (const ParmVarDecl *pParmVarDecl : compat::parameters(*functionDecl)) {
|
||||
for (const ParmVarDecl *pParmVarDecl : functionDecl->parameters()) {
|
||||
if (bFirst)
|
||||
bFirst = false;
|
||||
else
|
||||
|
||||
@ -90,10 +90,7 @@ public:
|
||||
}
|
||||
}
|
||||
bool dtorOrDealloc = isDtorOrDealloc(decl);
|
||||
SourceRange source;
|
||||
#if CLANG_VERSION >= 40000
|
||||
source = decl->getExceptionSpecSourceRange();
|
||||
#endif
|
||||
auto const source = decl->getExceptionSpecSourceRange();
|
||||
if (rewriter != nullptr && source.isValid()) {
|
||||
if (dtorOrDealloc) {
|
||||
if (replaceText(source, "noexcept(false)")) {
|
||||
|
||||
@ -140,7 +140,7 @@ MyFuncInfo ExpandableMethods::niceName(const FunctionDecl* functionDecl)
|
||||
}
|
||||
aInfo.nameAndParams += functionDecl->getNameAsString() + "(";
|
||||
bool bFirst = true;
|
||||
for (const ParmVarDecl *pParmVarDecl : compat::parameters(*functionDecl)) {
|
||||
for (const ParmVarDecl *pParmVarDecl : functionDecl->parameters()) {
|
||||
if (bFirst)
|
||||
bFirst = false;
|
||||
else
|
||||
@ -187,7 +187,7 @@ bool ExpandableMethods::VisitFunctionDecl( const FunctionDecl* functionDecl )
|
||||
// any function that uses a parameter more than once
|
||||
if (!bLargeFunction) {
|
||||
StringRef bodyText(s1, s2-s1);
|
||||
for (const ParmVarDecl* param : compat::parameters(*functionDecl)) {
|
||||
for (const ParmVarDecl* param : functionDecl->parameters()) {
|
||||
StringRef name = param->getName();
|
||||
if (name.empty())
|
||||
continue;
|
||||
|
||||
@ -251,13 +251,7 @@ private:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (decl->getLinkageInternal() <
|
||||
#if CLANG_VERSION >= 50000
|
||||
ModuleLinkage
|
||||
#else
|
||||
ExternalLinkage
|
||||
#endif
|
||||
)
|
||||
if (decl->getLinkageInternal() < ModuleLinkage)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -8,7 +8,6 @@
|
||||
*/
|
||||
|
||||
#include "check.hxx"
|
||||
#include "compat.hxx"
|
||||
#include "plugin.hxx"
|
||||
|
||||
// Find variable declarations at namespace scope that need not have external
|
||||
@ -78,7 +77,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
SourceLocation argLoc;
|
||||
if (compat::isMacroArgExpansion(compiler, def->getLocation(), &argLoc)
|
||||
if (compiler.getSourceManager().isMacroArgExpansion(def->getLocation(), &argLoc)
|
||||
&& (Lexer::getImmediateMacroName(
|
||||
argLoc, compiler.getSourceManager(), compiler.getLangOpts())
|
||||
== "DEFINE_GUID"))
|
||||
|
||||
@ -11,7 +11,6 @@
|
||||
|
||||
#include "config_clang.h"
|
||||
|
||||
#include "compat.hxx"
|
||||
#include "plugin.hxx"
|
||||
|
||||
// Enforces the "Rules for #include directives (C/C++)" described in README.md.
|
||||
@ -74,7 +73,7 @@ private:
|
||||
pos = pos2;
|
||||
}
|
||||
#endif
|
||||
auto dir2 = std::string(compat::take_front(file, pos));
|
||||
auto dir2 = std::string(file.take_front(pos));
|
||||
loplugin::normalizeDotDotInFilePath(dir2);
|
||||
shouldUseAngles = !loplugin::isSamePathname(dir1, dir2);
|
||||
}
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
#include "clang/AST/Attr.h"
|
||||
|
||||
#include "plugin.hxx"
|
||||
#include "compat.hxx"
|
||||
|
||||
/**
|
||||
What we are looking for here are methods that are not reachable from any of the program
|
||||
@ -110,9 +109,8 @@ public:
|
||||
bool TraverseCXXConstructorDecl(CXXConstructorDecl*);
|
||||
bool TraverseCXXConversionDecl(CXXConversionDecl*);
|
||||
bool TraverseCXXDestructorDecl(CXXDestructorDecl*);
|
||||
#if CLANG_VERSION >= 50000
|
||||
bool TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl*);
|
||||
#endif
|
||||
|
||||
private:
|
||||
void logCallToRootMethods(const FunctionDecl* functionDeclFrom,
|
||||
const FunctionDecl* functionDeclTo);
|
||||
@ -154,7 +152,7 @@ MyFuncInfo MethodCycles::niceName(const FunctionDecl* functionDecl)
|
||||
aInfo.nameAndParams = functionDecl->getQualifiedNameAsString() + "(";
|
||||
}
|
||||
bool bFirst = true;
|
||||
for (const ParmVarDecl* pParmVarDecl : compat::parameters(*functionDecl))
|
||||
for (const ParmVarDecl* pParmVarDecl : functionDecl->parameters())
|
||||
{
|
||||
if (bFirst)
|
||||
bFirst = false;
|
||||
@ -349,7 +347,6 @@ bool MethodCycles::TraverseCXXConversionDecl(CXXConversionDecl* f)
|
||||
currentFunctionDecl = copy;
|
||||
return ret;
|
||||
}
|
||||
#if CLANG_VERSION >= 50000
|
||||
bool MethodCycles::TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl* f)
|
||||
{
|
||||
auto copy = currentFunctionDecl;
|
||||
@ -358,7 +355,6 @@ bool MethodCycles::TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl* f)
|
||||
currentFunctionDecl = copy;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
bool MethodCycles::TraverseCXXConstructorDecl(CXXConstructorDecl* f)
|
||||
{
|
||||
auto copy = currentFunctionDecl;
|
||||
|
||||
@ -59,11 +59,7 @@ private:
|
||||
}
|
||||
|
||||
void MacroUndefined(
|
||||
Token const & MacroNameTok, MacroDefinition const &
|
||||
#if CLANG_VERSION >= 50000
|
||||
, MacroDirective const *
|
||||
#endif
|
||||
) override
|
||||
Token const & MacroNameTok, MacroDefinition const &, MacroDirective const *) override
|
||||
{
|
||||
auto id = MacroNameTok.getIdentifierInfo()->getName();
|
||||
if (id == "OSL_BIGENDIAN" || id == "OSL_LITENDIAN") {
|
||||
|
||||
@ -11,7 +11,6 @@
|
||||
#include <set>
|
||||
|
||||
#include "plugin.hxx"
|
||||
#include "compat.hxx"
|
||||
#include "check.hxx"
|
||||
|
||||
/*
|
||||
@ -76,7 +75,7 @@ bool OverrideParam::VisitCXXMethodDecl(const CXXMethodDecl * methodDecl) {
|
||||
continue;
|
||||
}
|
||||
int i = 0;
|
||||
for (const ParmVarDecl *superParmVarDecl : compat::parameters(*superMethodDecl)) {
|
||||
for (const ParmVarDecl *superParmVarDecl : superMethodDecl->parameters()) {
|
||||
const ParmVarDecl *parmVarDecl = methodDecl->getParamDecl(i);
|
||||
if (parmVarDecl->hasDefaultArg() && !superParmVarDecl->hasDefaultArg()) {
|
||||
report(
|
||||
|
||||
@ -351,7 +351,6 @@ Plugin::IdenticalDefaultArgumentsResult Plugin::checkIdenticalDefaultArguments(
|
||||
? IdenticalDefaultArgumentsResult::Yes
|
||||
: IdenticalDefaultArgumentsResult::No;
|
||||
}
|
||||
#if CLANG_VERSION >= 30900
|
||||
APFloat f1(0.0f), f2(0.0f);
|
||||
if (argument1->EvaluateAsFloat(f1, compiler.getASTContext())
|
||||
&& argument2->EvaluateAsFloat(f2, compiler.getASTContext()))
|
||||
@ -360,7 +359,6 @@ Plugin::IdenticalDefaultArgumentsResult Plugin::checkIdenticalDefaultArguments(
|
||||
? IdenticalDefaultArgumentsResult::Yes
|
||||
: IdenticalDefaultArgumentsResult::No;
|
||||
}
|
||||
#endif
|
||||
auto const desugared1 = argument1->IgnoreParenImpCasts();
|
||||
auto const desugared2 = argument2->IgnoreParenImpCasts();
|
||||
if (auto const lit1 = dyn_cast<clang::StringLiteral>(desugared1)) {
|
||||
|
||||
@ -137,14 +137,7 @@ private:
|
||||
}
|
||||
|
||||
bool handleNonExternalLinkage(FunctionDecl const * decl) {
|
||||
if (decl->getLinkageInternal() >=
|
||||
#if CLANG_VERSION >= 50000
|
||||
ModuleLinkage
|
||||
#else
|
||||
ExternalLinkage
|
||||
#endif
|
||||
)
|
||||
{
|
||||
if (decl->getLinkageInternal() >= ModuleLinkage) {
|
||||
return false;
|
||||
}
|
||||
if (!compiler.getSourceManager().isInMainFile(decl->getLocation())) {
|
||||
|
||||
@ -333,8 +333,8 @@ bool SalBool::VisitCStyleCastExpr(CStyleCastExpr * expr) {
|
||||
.getImmediateMacroCallerLoc(loc);
|
||||
if (!isSharedCAndCppCode(callLoc)) {
|
||||
SourceLocation argLoc;
|
||||
if (compat::isMacroArgExpansion(
|
||||
compiler, compat::getBeginLoc(expr), &argLoc)
|
||||
if (compiler.getSourceManager().isMacroArgExpansion(
|
||||
compat::getBeginLoc(expr), &argLoc)
|
||||
//TODO: check it's the complete (first) arg to the macro
|
||||
&& (Lexer::getImmediateMacroName(
|
||||
argLoc, compiler.getSourceManager(),
|
||||
|
||||
@ -321,13 +321,11 @@ bool SingleValFields::VisitMemberExpr( const MemberExpr* memberExpr )
|
||||
{
|
||||
break;
|
||||
}
|
||||
#if CLANG_VERSION >= 40000
|
||||
else if ( isa<ArrayInitLoopExpr>(parent) )
|
||||
{
|
||||
bPotentiallyAssignedTo = true;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
bPotentiallyAssignedTo = true;
|
||||
bDump = true;
|
||||
@ -451,7 +449,6 @@ std::string SingleValFields::getExprValue(const Expr* arg)
|
||||
return dyn_cast<clang::StringLiteral>(constructExpr->getArg(0))->getString();
|
||||
}
|
||||
}
|
||||
#if CLANG_VERSION >= 50000
|
||||
if (arg->getType()->isFloatingType())
|
||||
{
|
||||
APFloat x1(0.0f);
|
||||
@ -463,7 +460,6 @@ std::string SingleValFields::getExprValue(const Expr* arg)
|
||||
return os.str();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
APSInt x1;
|
||||
if (arg->EvaluateAsInt(x1, compiler.getASTContext()))
|
||||
return x1.toString(10);
|
||||
|
||||
@ -109,7 +109,6 @@ bool StaticConstField::TraverseConstructorInitializer(CXXCtorInitializer* init)
|
||||
}
|
||||
}
|
||||
}
|
||||
#if CLANG_VERSION >= 50000
|
||||
else if (type->isFloatingType())
|
||||
{
|
||||
APFloat x1(0.0f);
|
||||
@ -122,7 +121,6 @@ bool StaticConstField::TraverseConstructorInitializer(CXXCtorInitializer* init)
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// ignore this, it seems to trigger an infinite recursion
|
||||
else if (isa<UnaryExprOrTypeTraitExpr>(initexpr))
|
||||
;
|
||||
|
||||
@ -47,7 +47,6 @@ class Class4
|
||||
}
|
||||
};
|
||||
|
||||
#if CLANG_VERSION >= 50000 // Expr::EvaluateAsFloat
|
||||
class Class5
|
||||
{
|
||||
enum class Enum
|
||||
@ -77,7 +76,6 @@ class Class5
|
||||
(void)m_fielda4;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
// no warning expected
|
||||
class Class6
|
||||
|
||||
@ -33,7 +33,6 @@ struct S2
|
||||
OUString x;
|
||||
};
|
||||
|
||||
#if CLANG_VERSION >= 50000 // probably something to do with how OUString initialisers work
|
||||
S2 const& f2()
|
||||
{
|
||||
static S2 const s1[]{
|
||||
@ -42,7 +41,6 @@ S2 const& f2()
|
||||
};
|
||||
return s1[0];
|
||||
}
|
||||
#endif
|
||||
|
||||
// no warning expected
|
||||
S2 const& f3()
|
||||
|
||||
@ -69,7 +69,6 @@ struct DerivedDifferent : Base
|
||||
|
||||
struct DerivedSame : Base
|
||||
{
|
||||
#if CLANG_VERSION >= 30900 // cf. corresponding condition in Plugin::checkIdenticalDefaultArguments
|
||||
void
|
||||
defaults( // expected-error {{public function just calls public parent [loplugin:unnecessaryoverride]}}
|
||||
void* x1 = 0, int x2 = (1 - 1), double x3 = 1.0, Base const& x4 = (Base()),
|
||||
@ -78,7 +77,6 @@ struct DerivedSame : Base
|
||||
{
|
||||
Base::defaults(x1, x2, x3, x4, x5);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct DerivedSlightlyDifferent : Base
|
||||
|
||||
@ -219,7 +219,6 @@ class Foo17 {
|
||||
};
|
||||
|
||||
// this only starts to work somewhere after clang 3.8 and before clang7
|
||||
#if CLANG_VERSION >= 30900
|
||||
class Foo18 {
|
||||
std::vector<char*> m_pbar1; // expected-note {{member is here [loplugin:useuniqueptr]}}
|
||||
~Foo18()
|
||||
@ -228,7 +227,6 @@ class Foo18 {
|
||||
delete *aIter; // expected-error {{rather manage with std::some_container<std::unique_ptr<T>> [loplugin:useuniqueptr]}}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
void foo19()
|
||||
{
|
||||
|
||||
@ -13,7 +13,6 @@
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
#include "plugin.hxx"
|
||||
#include "compat.hxx"
|
||||
#include <fstream>
|
||||
|
||||
/**
|
||||
@ -95,7 +94,7 @@ std::string niceName(const CXXMethodDecl* cxxMethodDecl)
|
||||
cxxMethodDecl = dyn_cast<CXXMethodDecl>(cxxMethodDecl->getInstantiatedFromMemberFunction());
|
||||
std::string s = cxxMethodDecl->getReturnType().getCanonicalType().getAsString()
|
||||
+ " " + cxxMethodDecl->getQualifiedNameAsString() + "(";
|
||||
for (const ParmVarDecl *pParmVarDecl : compat::parameters(*cxxMethodDecl)) {
|
||||
for (const ParmVarDecl *pParmVarDecl : cxxMethodDecl->parameters()) {
|
||||
s += pParmVarDecl->getType().getCanonicalType().getAsString();
|
||||
s += ",";
|
||||
}
|
||||
|
||||
@ -524,10 +524,7 @@ void UnusedFields::checkIfReadFrom(const FieldDecl* fieldDecl, const Expr* membe
|
||||
break;
|
||||
}
|
||||
else if (isa<CastExpr>(parent) || isa<MemberExpr>(parent) || isa<ParenExpr>(parent) || isa<ParenListExpr>(parent)
|
||||
#if CLANG_VERSION >= 40000
|
||||
|| isa<ArrayInitLoopExpr>(parent)
|
||||
#endif
|
||||
|| isa<ExprWithCleanups>(parent))
|
||||
|| isa<ArrayInitLoopExpr>(parent) || isa<ExprWithCleanups>(parent))
|
||||
{
|
||||
walkupUp();
|
||||
}
|
||||
@ -731,10 +728,7 @@ void UnusedFields::checkIfWrittenTo(const FieldDecl* fieldDecl, const Expr* memb
|
||||
break;
|
||||
}
|
||||
else if (isa<CastExpr>(parent) || isa<MemberExpr>(parent) || isa<ParenExpr>(parent) || isa<ParenListExpr>(parent)
|
||||
#if CLANG_VERSION >= 40000
|
||||
|| isa<ArrayInitLoopExpr>(parent)
|
||||
#endif
|
||||
|| isa<ExprWithCleanups>(parent))
|
||||
|| isa<ArrayInitLoopExpr>(parent) || isa<ExprWithCleanups>(parent))
|
||||
{
|
||||
walkupUp();
|
||||
}
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
#include "clang/AST/Attr.h"
|
||||
|
||||
#include "plugin.hxx"
|
||||
#include "compat.hxx"
|
||||
|
||||
/**
|
||||
This plugin performs 3 different analyses:
|
||||
@ -118,9 +117,8 @@ public:
|
||||
bool TraverseFunctionDecl( FunctionDecl* );
|
||||
bool TraverseCXXMethodDecl( CXXMethodDecl* );
|
||||
bool TraverseCXXConversionDecl( CXXConversionDecl* );
|
||||
#if CLANG_VERSION >= 50000
|
||||
bool TraverseCXXDeductionGuideDecl( CXXDeductionGuideDecl* );
|
||||
#endif
|
||||
|
||||
private:
|
||||
void logCallToRootMethods(const FunctionDecl* functionDecl, std::set<MyFuncInfo>& funcSet);
|
||||
MyFuncInfo niceName(const FunctionDecl* functionDecl);
|
||||
@ -167,7 +165,7 @@ MyFuncInfo UnusedMethods::niceName(const FunctionDecl* functionDecl)
|
||||
aInfo.nameAndParams = functionDecl->getQualifiedNameAsString() + "(";
|
||||
}
|
||||
bool bFirst = true;
|
||||
for (const ParmVarDecl *pParmVarDecl : compat::parameters(*functionDecl)) {
|
||||
for (const ParmVarDecl *pParmVarDecl : functionDecl->parameters()) {
|
||||
if (bFirst)
|
||||
bFirst = false;
|
||||
else
|
||||
@ -400,7 +398,6 @@ bool UnusedMethods::TraverseCXXConversionDecl(CXXConversionDecl* f)
|
||||
currentFunctionDecl = copy;
|
||||
return ret;
|
||||
}
|
||||
#if CLANG_VERSION >= 50000
|
||||
bool UnusedMethods::TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl* f)
|
||||
{
|
||||
auto copy = currentFunctionDecl;
|
||||
@ -409,7 +406,6 @@ bool UnusedMethods::TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl* f)
|
||||
currentFunctionDecl = copy;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
loplugin::Plugin::Registration< UnusedMethods > X("unusedmethods", false);
|
||||
|
||||
|
||||
@ -81,7 +81,7 @@ std::string niceName(const CXXMethodDecl* functionDecl)
|
||||
+ "::" + functionDecl->getNameAsString()
|
||||
+ "(";
|
||||
bool bFirst = true;
|
||||
for (const ParmVarDecl *pParmVarDecl : compat::parameters(*functionDecl)) {
|
||||
for (const ParmVarDecl *pParmVarDecl : functionDecl->parameters()) {
|
||||
if (bFirst)
|
||||
bFirst = false;
|
||||
else
|
||||
|
||||
@ -133,9 +133,7 @@ public:
|
||||
bool VisitFunctionDecl(const FunctionDecl* );
|
||||
bool VisitCXXDeleteExpr(const CXXDeleteExpr* );
|
||||
bool TraverseFunctionDecl(FunctionDecl* );
|
||||
#if CLANG_VERSION >= 50000
|
||||
bool TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl* );
|
||||
#endif
|
||||
bool TraverseCXXMethodDecl(CXXMethodDecl* );
|
||||
bool TraverseCXXConstructorDecl(CXXConstructorDecl* );
|
||||
bool TraverseCXXConversionDecl(CXXConversionDecl* );
|
||||
@ -957,7 +955,6 @@ bool UseUniquePtr::TraverseCXXMethodDecl(CXXMethodDecl* methodDecl)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if CLANG_VERSION >= 50000
|
||||
bool UseUniquePtr::TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl* methodDecl)
|
||||
{
|
||||
if (ignoreLocation(methodDecl))
|
||||
@ -970,7 +967,6 @@ bool UseUniquePtr::TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl* methodDe
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool UseUniquePtr::TraverseCXXConstructorDecl(CXXConstructorDecl* methodDecl)
|
||||
{
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
#include "plugin.hxx"
|
||||
#include "compat.hxx"
|
||||
#include <fstream>
|
||||
|
||||
/**
|
||||
@ -74,9 +73,8 @@ public:
|
||||
bool TraverseFunctionDecl(FunctionDecl*);
|
||||
bool TraverseCXXMethodDecl(CXXMethodDecl*);
|
||||
bool TraverseCXXConversionDecl(CXXConversionDecl*);
|
||||
#if CLANG_VERSION >= 50000
|
||||
bool TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl*);
|
||||
#endif
|
||||
|
||||
private:
|
||||
std::string toString(SourceLocation loc);
|
||||
std::string niceName(const CXXMethodDecl* functionDecl);
|
||||
@ -177,7 +175,6 @@ bool VirtualDown::TraverseCXXConversionDecl(CXXConversionDecl* f)
|
||||
currentFunctionDecl = copy;
|
||||
return ret;
|
||||
}
|
||||
#if CLANG_VERSION >= 50000
|
||||
bool VirtualDown::TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl* f)
|
||||
{
|
||||
auto copy = currentFunctionDecl;
|
||||
@ -186,13 +183,12 @@ bool VirtualDown::TraverseCXXDeductionGuideDecl(CXXDeductionGuideDecl* f)
|
||||
currentFunctionDecl = copy;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string VirtualDown::niceName(const CXXMethodDecl* cxxMethodDecl)
|
||||
{
|
||||
std::string s = cxxMethodDecl->getReturnType().getCanonicalType().getAsString() + " "
|
||||
+ cxxMethodDecl->getQualifiedNameAsString() + "(";
|
||||
for (const ParmVarDecl* pParmVarDecl : compat::parameters(*cxxMethodDecl))
|
||||
for (const ParmVarDecl* pParmVarDecl : cxxMethodDecl->parameters())
|
||||
{
|
||||
s += pParmVarDecl->getType().getCanonicalType().getAsString();
|
||||
s += ",";
|
||||
|
||||
@ -6698,9 +6698,9 @@ 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" != no -a "$CLANGVER" -lt 50002; then
|
||||
if test "$compiler_plugins" = yes; then
|
||||
AC_MSG_ERROR([Clang $CLANGVER is too old to build compiler plugins; need >= 3.8.0.])
|
||||
AC_MSG_ERROR([Clang $CLANGVER is too old to build compiler plugins; need >= 5.0.2.])
|
||||
else
|
||||
compiler_plugins=no
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user