Kaydet (Commit) 733198de authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Remove support for Clang < 3.4

Change-Id: I81e97c5f720535b33dd3ce72d01151765e4e93a0
üst 94809ea0
......@@ -13,7 +13,6 @@
#include <fstream>
#include <set>
#include "plugin.hxx"
#include "compat.hxx"
/**
Find calls to "delete x" where x is a field on an object.
......
......@@ -13,7 +13,6 @@
#include <fstream>
#include <set>
#include "plugin.hxx"
#include "compat.hxx"
/**
......
......@@ -44,9 +44,7 @@ class CheckConfigMacros
virtual void Ifdef( SourceLocation location, const Token& macroToken, const MacroDefinition& info ) override;
virtual void Ifndef( SourceLocation location, const Token& macroToken, const MacroDefinition& info ) override;
#endif
#if CLANG_VERSION < 30400
virtual void Defined( const Token& macroToken, const MacroDirective* info ) override;
#elif CLANG_VERSION < 30700
#if CLANG_VERSION < 30700
virtual void Defined( const Token& macroToken, const MacroDirective* info, SourceRange Range ) override;
#else
virtual void Defined( const Token& macroToken, const MacroDefinition& info, SourceRange Range ) override;
......@@ -108,9 +106,7 @@ void CheckConfigMacros::Ifndef( SourceLocation location, const Token& macroToken
checkMacro( macroToken, location );
}
#if CLANG_VERSION < 30400
void CheckConfigMacros::Defined( const Token& macroToken, const MacroDirective* )
#elif CLANG_VERSION < 30700
#if CLANG_VERSION < 30700
void CheckConfigMacros::Defined( const Token& macroToken, const MacroDirective* , SourceRange )
#else
void CheckConfigMacros::Defined( const Token& macroToken, const MacroDefinition& , SourceRange )
......
......@@ -13,7 +13,6 @@
#include <fstream>
#include <set>
#include "plugin.hxx"
#include "compat.hxx"
/**
the comma operator is best used sparingly
......
......@@ -32,14 +32,6 @@
#include "config_clang.h"
#if CLANG_VERSION >= 30400
#define LO_COMPILERPLUGINS_CLANG_COMPAT_HAVE_isAtEndOfImmediateMacroExpansion \
true
#else
#define LO_COMPILERPLUGINS_CLANG_COMPAT_HAVE_isAtEndOfImmediateMacroExpansion \
false
#endif
// Compatibility wrapper to abstract over (trivial) changes in the Clang API:
namespace compat {
......@@ -52,30 +44,6 @@ inline bool isLookupContext(clang::DeclContext const & ctxt) {
#endif
}
inline bool isExternCContext(clang::DeclContext const & ctxt) {
#if CLANG_VERSION >= 30400
return ctxt.isExternCContext();
#else
for (clang::DeclContext const * c = &ctxt;
c->getDeclKind() != clang::Decl::TranslationUnit; c = c->getParent())
{
if (c->getDeclKind() == clang::Decl::LinkageSpec) {
return llvm::cast<clang::LinkageSpecDecl>(c)->getLanguage()
== clang::LinkageSpecDecl::lang_c;
}
}
return false;
#endif
}
inline bool isInExternCContext(clang::FunctionDecl const & decl) {
#if CLANG_VERSION >= 30400
return decl.isInExternCContext();
#else
return isExternCContext(*decl.getCanonicalDecl()->getDeclContext());
#endif
}
inline bool forallBases(
clang::CXXRecordDecl const & decl,
clang::CXXRecordDecl::ForallBasesCallback BaseMatches,
......@@ -90,14 +58,6 @@ inline bool forallBases(
#endif
}
inline bool isFirstDecl(clang::FunctionDecl const & decl) {
#if CLANG_VERSION >= 30400
return decl.isFirstDecl();
#else
return decl.isFirstDeclaration();
#endif
}
inline clang::QualType getReturnType(clang::FunctionDecl const & decl) {
#if CLANG_VERSION >= 30500
return decl.getReturnType();
......@@ -189,16 +149,6 @@ inline unsigned getBuiltinCallee(clang::CallExpr const & expr) {
#endif
}
inline bool isInMainFile(
clang::SourceManager const & manager, clang::SourceLocation Loc)
{
#if CLANG_VERSION >= 30400
return manager.isInMainFile(Loc);
#else
return manager.isFromMainFile(Loc);
#endif
}
inline unsigned getCustomDiagID(
clang::DiagnosticsEngine & engine, clang::DiagnosticsEngine::Level L,
llvm::StringRef FormatString)
......
......@@ -13,7 +13,6 @@
#include <fstream>
#include <set>
#include "plugin.hxx"
#include "compat.hxx"
/**
Check for calls to CPPUNIT_ASSERT when it should be using CPPUNIT_ASSERT_EQUALS
......
......@@ -10,7 +10,6 @@
#include <cassert>
#include <string>
#include "plugin.hxx"
#include "compat.hxx"
//
// We don't like using C-style casts in C++ code
......@@ -76,7 +75,7 @@ bool areSimilar(QualType type1, QualType type2) {
}
bool hasCLanguageLinkageType(FunctionDecl const * decl) {
return decl->isExternC() || compat::isInExternCContext(*decl);
return decl->isExternC() || decl->isInExternCContext();
}
QualType resolvePointers(QualType type) {
......
......@@ -10,7 +10,6 @@
#include <string>
#include "plugin.hxx"
#include "compat.hxx"
// Having an extern prototype for a method in a module and not actually declaring that method is dodgy.
//
......@@ -54,7 +53,8 @@ bool ExternAndNotDefined::VisitFunctionDecl(const FunctionDecl * functionDecl) {
if (functionName == "gdk_x11_screen_get_screen_number") {
return true;
}
if (!compat::isInMainFile( compiler.getSourceManager(), functionDecl->getLocation())) {
if (!compiler.getSourceManager().isInMainFile(functionDecl->getLocation()))
{
return true;
}
StringRef fileName { compiler.getSourceManager().getFilename(functionDecl->getLocation()) };
......
......@@ -14,7 +14,6 @@
#include <set>
#include "check.hxx"
#include "compat.hxx"
#include "plugin.hxx"
/**
......
......@@ -234,9 +234,10 @@ bool InlineSimpleMemberFunctions::rewrite(const CXXMethodDecl * functionDecl) {
// definition (in a main file only processed later) to fail
// with a "mismatch" error before the rewriter had a chance
// to act upon the definition.
if (!compat::isInMainFile( compiler.getSourceManager(),
compiler.getSourceManager().getSpellingLoc(
functionDecl->getNameInfo().getLoc()))) {
if (!compiler.getSourceManager().isInMainFile(
compiler.getSourceManager().getSpellingLoc(
functionDecl->getNameInfo().getLoc())))
{
return false;
}
......
......@@ -13,7 +13,6 @@
#include "clang/AST/Attr.h"
#include "clang/Sema/SemaInternal.h" // warn_unused_function
#include "compat.hxx"
#include "plugin.hxx"
namespace {
......
......@@ -9,7 +9,6 @@
#include "clang/Lex/Lexer.h"
#include "compat.hxx"
#include "plugin.hxx"
namespace {
......@@ -50,7 +49,7 @@ bool LiteralToBoolConversion::VisitImplicitCastExpr(
bool LiteralToBoolConversion::isFromCIncludeFile(
SourceLocation spellingLocation) const
{
return !compat::isInMainFile(compiler.getSourceManager(), spellingLocation)
return !compiler.getSourceManager().isInMainFile(spellingLocation)
&& (StringRef(
compiler.getSourceManager().getPresumedLoc(spellingLocation)
.getFilename())
......
......@@ -11,7 +11,6 @@
#include <iostream>
#include "plugin.hxx"
#include "compat.hxx"
#include "clang/AST/CXXInheritance.h"
// Idea from bubli. Check that the index variable in a for loop is able to cover the range
......
......@@ -13,7 +13,6 @@
#include <set>
#include "plugin.hxx"
#include "compat.hxx"
#include "clang/AST/CXXInheritance.h"
// Check for local variables that we are calling delete on
......
......@@ -11,7 +11,6 @@
#include <string>
#include <iostream>
#include "plugin.hxx"
#include "compat.hxx"
#include <fstream>
/**
......
......@@ -11,7 +11,6 @@
#include <cstdlib>
#include <set>
#include "compat.hxx"
#include "plugin.hxx"
namespace {
......@@ -209,7 +208,7 @@ bool Nullptr::isInLokIncludeFile(SourceLocation spellingLocation) const {
}
bool Nullptr::isFromCIncludeFile(SourceLocation spellingLocation) const {
return !compat::isInMainFile(compiler.getSourceManager(), spellingLocation)
return !compiler.getSourceManager().isInMainFile(spellingLocation)
&& (StringRef(
compiler.getSourceManager().getPresumedLoc(spellingLocation)
.getFilename())
......
......@@ -15,7 +15,6 @@
#include "clang/AST/Attr.h"
#include "compat.hxx"
#include "plugin.hxx"
namespace {
......@@ -46,7 +45,7 @@ bool Override::VisitCXXMethodDecl(CXXMethodDecl const * decl) {
// As a heuristic, ignore declarations where the name is spelled out in an
// ignored location; that e.g. handles uses of the Q_OBJECT macro from
// external QtCore/qobjectdefs.h:
if (ignoreLocation(decl) || !compat::isFirstDecl(*decl)
if (ignoreLocation(decl) || !decl->isFirstDecl()
|| decl->begin_overridden_methods() == decl->end_overridden_methods()
|| decl->hasAttr<OverrideAttr>()
|| ignoreLocation(
......@@ -76,7 +75,6 @@ bool Override::VisitCXXMethodDecl(CXXMethodDecl const * decl) {
std::string over(
isInUnoIncludeFile(decl->getSourceRange().getBegin())
? "SAL_OVERRIDE" : "override");
#if LO_COMPILERPLUGINS_CLANG_COMPAT_HAVE_isAtEndOfImmediateMacroExpansion
if (rewriter != nullptr) {
// In void MACRO(...); getSourceRange().getEnd() would (erroneously?)
// point at "MACRO" rather than ")", so make the loop always terminate
......@@ -163,7 +161,6 @@ bool Override::VisitCXXMethodDecl(CXXMethodDecl const * decl) {
return true;
}
}
#endif
report(
DiagnosticsEngine::Warning,
("overriding virtual function declaration not marked '%0'"),
......
......@@ -17,7 +17,6 @@
#include <clang/Lex/Lexer.h>
#include "pluginhandler.hxx"
#include "compat.hxx"
/*
Base classes for plugin actions.
......@@ -106,7 +105,7 @@ const FunctionDecl* Plugin::parentFunctionDecl( const Stmt* stmt )
bool Plugin::isInUnoIncludeFile(SourceLocation spellingLocation) const {
StringRef name {
compiler.getSourceManager().getFilename(spellingLocation) };
return compat::isInMainFile(compiler.getSourceManager(), spellingLocation)
return compiler.getSourceManager().isInMainFile(spellingLocation)
? (name == SRCDIR "/cppu/source/cppu/compat.cxx"
|| name == SRCDIR "/cppuhelper/source/compat.cxx"
|| name == SRCDIR "/sal/osl/all/compat.cxx")
......
......@@ -13,7 +13,6 @@
#include <fstream>
#include <set>
#include "plugin.hxx"
#include "compat.hxx"
/**
Check for calls to operator== on a std::container< std::unique_ptr >, which is not useful,
......
......@@ -12,7 +12,6 @@
#include <iostream>
#include "plugin.hxx"
#include "compat.hxx"
#include "clang/AST/CXXInheritance.h"
// Check that we're not unnecessarily copying variables in a range based for loop
......
......@@ -25,7 +25,6 @@
#include "clang/Sema/Sema.h"
#include "compat.hxx"
#include "plugin.hxx"
namespace {
......
......@@ -11,7 +11,6 @@
#include <iostream>
#include "plugin.hxx"
#include "compat.hxx"
#include "clang/AST/CXXInheritance.h"
// Check for calls to OutputDevice methods that are not passing through RenderContext
......
......@@ -15,7 +15,6 @@
#include "clang/AST/Attr.h"
#include "compat.hxx"
#include "plugin.hxx"
namespace {
......
......@@ -527,8 +527,7 @@ bool SalBool::VisitParmVarDecl(ParmVarDecl const * decl) {
// where the function would still implicitly override and
// cause a compilation error due to the incompatible return
// type):
if (!((compat::isInMainFile(
compiler.getSourceManager(),
if (!((compiler.getSourceManager().isInMainFile(
compiler.getSourceManager().getSpellingLoc(
dyn_cast<FunctionDecl>(
decl->getDeclContext())
......@@ -587,8 +586,7 @@ bool SalBool::VisitFieldDecl(FieldDecl const * decl) {
{
TagDecl const * td = dyn_cast<TagDecl>(decl->getDeclContext());
assert(td != nullptr);
if (!(((td->isStruct() || td->isUnion())
&& compat::isExternCContext(*td))
if (!(((td->isStruct() || td->isUnion()) && td->isExternCContext())
|| isInUnoIncludeFile(
compiler.getSourceManager().getSpellingLoc(
decl->getLocation()))))
......@@ -679,8 +677,7 @@ bool SalBool::VisitFunctionDecl(FunctionDecl const * decl) {
// rewriter had a chance to act upon the definition (but use the
// heuristic of assuming pure virtual functions do not have
// definitions):
if (!((compat::isInMainFile(
compiler.getSourceManager(),
if (!((compiler.getSourceManager().isInMainFile(
compiler.getSourceManager().getSpellingLoc(
decl->getNameInfo().getLoc()))
|| f->isDefined() || f->isPure())
......@@ -729,7 +726,7 @@ bool SalBool::TraverseStaticAssertDecl(StaticAssertDecl * decl) {
}
bool SalBool::isFromCIncludeFile(SourceLocation spellingLocation) const {
return !compat::isInMainFile(compiler.getSourceManager(), spellingLocation)
return !compiler.getSourceManager().isInMainFile(spellingLocation)
&& (StringRef(
compiler.getSourceManager().getPresumedLoc(spellingLocation)
.getFilename())
......@@ -737,7 +734,7 @@ bool SalBool::isFromCIncludeFile(SourceLocation spellingLocation) const {
}
bool SalBool::isInSpecialMainFile(SourceLocation spellingLocation) const {
if (!compat::isInMainFile(compiler.getSourceManager(), spellingLocation)) {
if (!compiler.getSourceManager().isInMainFile(spellingLocation)) {
return false;
}
auto f = compiler.getSourceManager().getFilename(spellingLocation);
......
......@@ -6,7 +6,7 @@
*
*/
#include "plugin.hxx"
#include "compat.hxx"
/*
This is a compile check.
......@@ -45,7 +45,7 @@ bool StaticAnonymous::VisitFunctionDecl( FunctionDecl* func )
return true;
if( func -> isInAnonymousNamespace () )
{
if ( !isa<CXXMethodDecl>(func) && !compat::isInExternCContext(*func) )
if ( !isa<CXXMethodDecl>(func) && !func->isInExternCContext() )
{
if(func-> getStorageClass() == SC_Static)
{
......
......@@ -8,7 +8,6 @@
*/
#include "plugin.hxx"
#include "compat.hxx"
#include <iostream>
/*
......
......@@ -11,7 +11,6 @@
#include <iterator>
#include <string>
#include "compat.hxx"
#include "plugin.hxx"
// Second-guess that certain private special member function declarations for
......@@ -58,7 +57,7 @@ void DeletedSpecial::run() {
}
bool DeletedSpecial::VisitCXXMethodDecl(CXXMethodDecl const * decl) {
if (ignoreLocation(decl) || !compat::isFirstDecl(*decl) || decl->isDefined()
if (ignoreLocation(decl) || !decl->isFirstDecl() || decl->isDefined()
|| decl->isDefaulted() || decl->getAccess() != AS_private)
{
return true;
......
......@@ -12,7 +12,6 @@
#include <map>
#include "plugin.hxx"
#include "compat.hxx"
#include "clang/AST/CXXInheritance.h"
// Idea from tml.
......
......@@ -9,7 +9,6 @@
#include "clang/Lex/Lexer.h"
#include "compat.hxx"
#include "plugin.hxx"
#include <iostream>
#include <fstream>
......
......@@ -33,9 +33,6 @@ public:
{ TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
bool VisitCXXMethodDecl(CXXMethodDecl const * decl);
private:
bool isInMainFile(SourceLocation spellingLocation) const;
};
bool StdException::VisitCXXMethodDecl(CXXMethodDecl const * decl) {
......@@ -150,7 +147,7 @@ found:
// (but use the heuristic of assuming pure virtual functions do
// not have definitions):
if (rewriter != nullptr
&& (isInMainFile(
&& (compiler.getSourceManager().isInMainFile(
compiler.getSourceManager().getSpellingLoc(loc))
|| decl->isDefined() || decl->isPure())
&& insertTextAfterToken(
......@@ -184,14 +181,6 @@ found:
return true;
}
bool StdException::isInMainFile(SourceLocation spellingLocation) const {
#if CLANG_VERSION >= 30400
return compiler.getSourceManager().isInMainFile(spellingLocation);
#else
return compiler.getSourceManager().isFromMainFile(spellingLocation);
#endif
}
loplugin::Plugin::Registration<StdException> X("stdexception", true);
}
......
......@@ -11,7 +11,6 @@
#include <string>
#include <set>
#include "compat.hxx"
#include "plugin.hxx"
// Check for some basic naming mismatches which make the code harder to read
......
......@@ -16,7 +16,6 @@
#include <iostream>
#include "check.hxx"
#include "compat.hxx"
#include "plugin.hxx"
// Define a "string constant" to be a constant expression either of type "array
......
......@@ -13,7 +13,6 @@
#include "clang/AST/Attr.h"
#include "clang/Sema/SemaInternal.h" // warn_unused_function
#include "compat.hxx"
#include "plugin.hxx"
namespace {
......@@ -111,10 +110,8 @@ bool UnrefFun::VisitFunctionDecl(FunctionDecl const * decl) {
//TODO: is that the first?
if (canon->isDeleted() || canon->isReferenced()
|| !(canon->isDefined()
? decl->isThisDeclarationADefinition()
: compat::isFirstDecl(*decl))
|| !compat::isInMainFile(
compiler.getSourceManager(), canon->getLocation())
? decl->isThisDeclarationADefinition() : decl->isFirstDecl())
|| !compiler.getSourceManager().isInMainFile(canon->getLocation())
|| isInUnoIncludeFile(
compiler.getSourceManager().getSpellingLoc(
canon->getNameInfo().getLoc()))
......@@ -141,19 +138,15 @@ bool UnrefFun::VisitFunctionDecl(FunctionDecl const * decl) {
report(
DiagnosticsEngine::Warning,
(canon->isDefined()
#if CLANG_VERSION >= 30400
? (canon->isExternallyVisible()
? "Unreferenced externally visible function%0 definition"
: "Unreferenced externally invisible function%0 definition")
#else
? "Unreferenced function%0 definition"
#endif
: "Unreferenced function%0 declaration"),
decl->getLocation())
<< (decl->getTemplatedKind() == FunctionDecl::TK_FunctionTemplate
? " template" : "")
<< decl->getSourceRange();
if (canon->isDefined() && !compat::isFirstDecl(*decl)) {
if (canon->isDefined() && !decl->isFirstDecl()) {
report(
DiagnosticsEngine::Note, "first declaration is here",
canon->getLocation())
......
......@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment