Remove support for Clang < 3.3

Change-Id: I185852a738bac10dc6d331afccfcbc7ae1225cb1
This commit is contained in:
Stephan Bergmann 2016-06-29 08:55:27 +02:00
parent 6439d93cbe
commit 1ce7176ba1
12 changed files with 29 additions and 155 deletions

View File

@ -34,13 +34,6 @@ class CheckConfigMacros
public: public:
explicit CheckConfigMacros( const InstantiationData& data ); explicit CheckConfigMacros( const InstantiationData& data );
virtual void run() override; virtual void run() override;
#if CLANG_VERSION < 30300
virtual void MacroDefined( const Token& macroToken, const MacroInfo* info ) override;
virtual void MacroUndefined( const Token& macroToken, const MacroInfo* info ) override;
virtual void Ifdef( SourceLocation location, const Token& macroToken ) override;
virtual void Ifndef( SourceLocation location, const Token& macroToken ) override;
virtual void Defined( const Token& macroToken ) override;
#else
virtual void MacroDefined( const Token& macroToken, const MacroDirective* info ) override; virtual void MacroDefined( const Token& macroToken, const MacroDirective* info ) override;
#if CLANG_VERSION < 30700 #if CLANG_VERSION < 30700
virtual void MacroUndefined( const Token& macroToken, const MacroDirective* info ) override; virtual void MacroUndefined( const Token& macroToken, const MacroDirective* info ) override;
@ -57,7 +50,6 @@ class CheckConfigMacros
virtual void Defined( const Token& macroToken, const MacroDirective* info, SourceRange Range ) override; virtual void Defined( const Token& macroToken, const MacroDirective* info, SourceRange Range ) override;
#else #else
virtual void Defined( const Token& macroToken, const MacroDefinition& info, SourceRange Range ) override; virtual void Defined( const Token& macroToken, const MacroDefinition& info, SourceRange Range ) override;
#endif
#endif #endif
enum { isPPCallback = true }; enum { isPPCallback = true };
private: private:
@ -76,15 +68,9 @@ void CheckConfigMacros::run()
// nothing, only check preprocessor usage // nothing, only check preprocessor usage
} }
#if CLANG_VERSION < 30300
void CheckConfigMacros::MacroDefined( const Token& macroToken, const MacroInfo* info )
{
SourceLocation location = info->getDefinitionLoc();
#else
void CheckConfigMacros::MacroDefined( const Token& macroToken, const MacroDirective* info ) void CheckConfigMacros::MacroDefined( const Token& macroToken, const MacroDirective* info )
{ {
SourceLocation location = info->getLocation(); SourceLocation location = info->getLocation();
#endif
const char* filename = compiler.getSourceManager().getPresumedLoc( location ).getFilename(); const char* filename = compiler.getSourceManager().getPresumedLoc( location ).getFilename();
if( filename != NULL if( filename != NULL
&& ( strncmp( filename, BUILDDIR "/config_host/", strlen( BUILDDIR "/config_host/" )) == 0 && ( strncmp( filename, BUILDDIR "/config_host/", strlen( BUILDDIR "/config_host/" )) == 0
@ -95,9 +81,7 @@ void CheckConfigMacros::MacroDefined( const Token& macroToken, const MacroDirect
} }
} }
#if CLANG_VERSION < 30300 #if CLANG_VERSION < 30700
void CheckConfigMacros::MacroUndefined( const Token& macroToken, const MacroInfo* )
#elif CLANG_VERSION < 30700
void CheckConfigMacros::MacroUndefined( const Token& macroToken, const MacroDirective* ) void CheckConfigMacros::MacroUndefined( const Token& macroToken, const MacroDirective* )
#else #else
void CheckConfigMacros::MacroUndefined( const Token& macroToken, const MacroDefinition& ) void CheckConfigMacros::MacroUndefined( const Token& macroToken, const MacroDefinition& )
@ -106,9 +90,7 @@ void CheckConfigMacros::MacroUndefined( const Token& macroToken, const MacroDefi
configMacros.erase( macroToken.getIdentifierInfo()->getName()); configMacros.erase( macroToken.getIdentifierInfo()->getName());
} }
#if CLANG_VERSION < 30300 #if CLANG_VERSION < 30700
void CheckConfigMacros::Ifdef( SourceLocation location, const Token& macroToken )
#elif CLANG_VERSION < 30700
void CheckConfigMacros::Ifdef( SourceLocation location, const Token& macroToken, const MacroDirective* ) void CheckConfigMacros::Ifdef( SourceLocation location, const Token& macroToken, const MacroDirective* )
#else #else
void CheckConfigMacros::Ifdef( SourceLocation location, const Token& macroToken, const MacroDefinition& ) void CheckConfigMacros::Ifdef( SourceLocation location, const Token& macroToken, const MacroDefinition& )
@ -117,9 +99,7 @@ void CheckConfigMacros::Ifdef( SourceLocation location, const Token& macroToken,
checkMacro( macroToken, location ); checkMacro( macroToken, location );
} }
#if CLANG_VERSION < 30300 #if CLANG_VERSION < 30700
void CheckConfigMacros::Ifndef( SourceLocation location, const Token& macroToken )
#elif CLANG_VERSION < 30700
void CheckConfigMacros::Ifndef( SourceLocation location, const Token& macroToken, const MacroDirective* ) void CheckConfigMacros::Ifndef( SourceLocation location, const Token& macroToken, const MacroDirective* )
#else #else
void CheckConfigMacros::Ifndef( SourceLocation location, const Token& macroToken, const MacroDefinition& ) void CheckConfigMacros::Ifndef( SourceLocation location, const Token& macroToken, const MacroDefinition& )
@ -128,9 +108,7 @@ void CheckConfigMacros::Ifndef( SourceLocation location, const Token& macroToken
checkMacro( macroToken, location ); checkMacro( macroToken, location );
} }
#if CLANG_VERSION < 30300 #if CLANG_VERSION < 30400
void CheckConfigMacros::Defined( const Token& macroToken )
#elif CLANG_VERSION < 30400
void CheckConfigMacros::Defined( const Token& macroToken, const MacroDirective* ) void CheckConfigMacros::Defined( const Token& macroToken, const MacroDirective* )
#elif CLANG_VERSION < 30700 #elif CLANG_VERSION < 30700
void CheckConfigMacros::Defined( const Token& macroToken, const MacroDirective* , SourceRange ) void CheckConfigMacros::Defined( const Token& macroToken, const MacroDirective* , SourceRange )

View File

@ -90,28 +90,6 @@ inline bool forallBases(
#endif #endif
} }
#if CLANG_VERSION >= 30300
typedef clang::LinkageInfo LinkageInfo;
#else
typedef clang::NamedDecl::LinkageInfo LinkageInfo;
#endif
inline clang::Linkage getLinkage(LinkageInfo const & info) {
#if CLANG_VERSION >= 30300
return info.getLinkage();
#else
return info.linkage();
#endif
}
inline clang::Visibility getVisibility(LinkageInfo const & info) {
#if CLANG_VERSION >= 30300
return info.getVisibility();
#else
return info.visibility();
#endif
}
inline bool isFirstDecl(clang::FunctionDecl const & decl) { inline bool isFirstDecl(clang::FunctionDecl const & decl) {
#if CLANG_VERSION >= 30400 #if CLANG_VERSION >= 30400
return decl.isFirstDecl(); return decl.isFirstDecl();
@ -251,30 +229,6 @@ inline std::unique_ptr<llvm::raw_fd_ostream> create_raw_fd_ostream(
#endif #endif
} }
#if CLANG_VERSION >= 30700
typedef clang::DeclContext::lookup_result DeclContextLookupResult;
typedef clang::DeclContext::lookup_iterator DeclContextLookupIterator;
#else
typedef clang::DeclContext::lookup_const_result DeclContextLookupResult;
typedef clang::DeclContext::lookup_const_iterator DeclContextLookupIterator;
#endif
inline DeclContextLookupIterator begin(DeclContextLookupResult const & result) {
#if CLANG_VERSION >= 30300
return result.begin();
#else
return result.first;
#endif
}
inline DeclContextLookupIterator end(DeclContextLookupResult const & result) {
#if CLANG_VERSION >= 30300
return result.end();
#else
return result.second;
#endif
}
inline void addPPCallbacks( inline void addPPCallbacks(
clang::Preprocessor & preprocessor, clang::PPCallbacks * C) clang::Preprocessor & preprocessor, clang::PPCallbacks * C)
{ {
@ -303,16 +257,6 @@ inline bool isMacroArgExpansion(
#endif #endif
} }
inline bool isMacroBodyExpansion(clang::CompilerInstance& compiler, clang::SourceLocation location)
{
#if CLANG_VERSION >= 30300
return compiler.getSourceManager().isMacroBodyExpansion(location);
#else
return location.isMacroID()
&& !compiler.getSourceManager().isMacroArgExpansion(location);
#endif
}
inline auto getAsTagDecl(clang::Type const& t) -> clang::TagDecl * inline auto getAsTagDecl(clang::Type const& t) -> clang::TagDecl *
{ {
#if CLANG_VERSION >= 30500 #if CLANG_VERSION >= 30500

View File

@ -33,7 +33,7 @@ bool ExternAndNotDefined::VisitFunctionDecl(const FunctionDecl * functionDecl) {
return true; return true;
} }
if (functionDecl->isDefined() || functionDecl->isPure() if (functionDecl->isDefined() || functionDecl->isPure()
|| (compat::getLinkage(functionDecl->getLinkageAndVisibility()) || (functionDecl->getLinkageAndVisibility().getLinkage()
!= ExternalLinkage)) { != ExternalLinkage)) {
return true; return true;
} }

View File

@ -224,15 +224,9 @@ bool hasCLanguageLinkageType(FunctionDecl const * decl) {
if (decl->isExternC()) { if (decl->isExternC()) {
return true; return true;
} }
#if CLANG_VERSION >= 30300
if (decl->isInExternCContext()) { if (decl->isInExternCContext()) {
return true; return true;
} }
#else
if (decl->getCanonicalDecl()->getDeclContext()->isExternCContext()) {
return true;
}
#endif
return false; return false;
} }

View File

@ -93,7 +93,7 @@ void LiteralToBoolConversion::handleImplicitCastSubExpr(
while (compiler.getSourceManager().isMacroArgExpansion(loc)) { while (compiler.getSourceManager().isMacroArgExpansion(loc)) {
loc = compiler.getSourceManager().getImmediateMacroCallerLoc(loc); loc = compiler.getSourceManager().getImmediateMacroCallerLoc(loc);
} }
if (compat::isMacroBodyExpansion(compiler, loc)) { if (compiler.getSourceManager().isMacroBodyExpansion(loc)) {
StringRef name { Lexer::getImmediateMacroName( StringRef name { Lexer::getImmediateMacroName(
loc, compiler.getSourceManager(), compiler.getLangOpts()) }; loc, compiler.getSourceManager(), compiler.getLangOpts()) };
if (name == "sal_False" || name == "sal_True") { if (name == "sal_False" || name == "sal_True") {

View File

@ -67,8 +67,6 @@ private:
bool isFromCIncludeFile(SourceLocation spellingLocation) const; bool isFromCIncludeFile(SourceLocation spellingLocation) const;
bool isMacroBodyExpansion(SourceLocation location) const;
void visitCXXCtorInitializer(CXXCtorInitializer const * init); void visitCXXCtorInitializer(CXXCtorInitializer const * init);
void handleZero(Expr const * expr); void handleZero(Expr const * expr);
@ -218,15 +216,6 @@ bool Nullptr::isFromCIncludeFile(SourceLocation spellingLocation) const {
.endswith(".h")); .endswith(".h"));
} }
bool Nullptr::isMacroBodyExpansion(SourceLocation location) const {
#if CLANG_VERSION >= 30300
return compiler.getSourceManager().isMacroBodyExpansion(location);
#else
return location.isMacroID()
&& !compiler.getSourceManager().isMacroArgExpansion(location);
#endif
}
void Nullptr::visitCXXCtorInitializer(CXXCtorInitializer const * init) { void Nullptr::visitCXXCtorInitializer(CXXCtorInitializer const * init) {
if (!init->isWritten()) { if (!init->isWritten()) {
return; return;
@ -273,7 +262,7 @@ void Nullptr::handleNull(
while (compiler.getSourceManager().isMacroArgExpansion(loc)) { while (compiler.getSourceManager().isMacroArgExpansion(loc)) {
loc = compiler.getSourceManager().getImmediateMacroCallerLoc(loc); loc = compiler.getSourceManager().getImmediateMacroCallerLoc(loc);
} }
if (isMacroBodyExpansion(loc)) { if (compiler.getSourceManager().isMacroBodyExpansion(loc)) {
if (Lexer::getImmediateMacroName( if (Lexer::getImmediateMacroName(
loc, compiler.getSourceManager(), compiler.getLangOpts()) loc, compiler.getSourceManager(), compiler.getLangOpts())
== "NULL") == "NULL")
@ -336,7 +325,8 @@ void Nullptr::rewriteOrWarn(
locStart = compiler.getSourceManager() locStart = compiler.getSourceManager()
.getImmediateMacroCallerLoc(locStart); .getImmediateMacroCallerLoc(locStart);
} }
if (compiler.getLangOpts().CPlusPlus && isMacroBodyExpansion(locStart) if (compiler.getLangOpts().CPlusPlus
&& compiler.getSourceManager().isMacroBodyExpansion(locStart)
&& (Lexer::getImmediateMacroName( && (Lexer::getImmediateMacroName(
locStart, compiler.getSourceManager(), locStart, compiler.getSourceManager(),
compiler.getLangOpts()) compiler.getLangOpts())
@ -350,7 +340,8 @@ void Nullptr::rewriteOrWarn(
locEnd = compiler.getSourceManager() locEnd = compiler.getSourceManager()
.getImmediateMacroCallerLoc(locEnd); .getImmediateMacroCallerLoc(locEnd);
} }
if (compiler.getLangOpts().CPlusPlus && isMacroBodyExpansion(locEnd) if (compiler.getLangOpts().CPlusPlus
&& compiler.getSourceManager().isMacroBodyExpansion(locEnd)
&& (Lexer::getImmediateMacroName( && (Lexer::getImmediateMacroName(
locEnd, compiler.getSourceManager(), locEnd, compiler.getSourceManager(),
compiler.getLangOpts()) compiler.getLangOpts())

View File

@ -146,8 +146,8 @@ bool RedundantCast::VisitImplicitCastExpr(const ImplicitCastExpr * expr) {
&& isVoidPointer( && isVoidPointer(
dyn_cast<CXXStaticCastExpr>(e)->getSubExpr() dyn_cast<CXXStaticCastExpr>(e)->getSubExpr()
->IgnoreParenImpCasts()->getType()) ->IgnoreParenImpCasts()->getType())
&& !compat::isMacroBodyExpansion( && !compiler.getSourceManager().isMacroBodyExpansion(
compiler, e->getLocStart())) e->getLocStart()))
{ {
report( report(
DiagnosticsEngine::Warning, DiagnosticsEngine::Warning,
@ -223,13 +223,13 @@ bool RedundantCast::VisitCXXReinterpretCastExpr(
loc = compiler.getSourceManager().getImmediateMacroCallerLoc( loc = compiler.getSourceManager().getImmediateMacroCallerLoc(
loc); loc);
} }
if (compat::isMacroBodyExpansion(compiler, loc)) { if (compiler.getSourceManager().isMacroBodyExpansion(loc)) {
auto loc2 = expr->getLocEnd(); auto loc2 = expr->getLocEnd();
while (compiler.getSourceManager().isMacroArgExpansion(loc2)) { while (compiler.getSourceManager().isMacroArgExpansion(loc2)) {
loc2 = compiler.getSourceManager() loc2 = compiler.getSourceManager()
.getImmediateMacroCallerLoc(loc2); .getImmediateMacroCallerLoc(loc2);
} }
if (compat::isMacroBodyExpansion(compiler, loc2)) { if (compiler.getSourceManager().isMacroBodyExpansion(loc2)) {
//TODO: check loc, loc2 are in same macro body expansion //TODO: check loc, loc2 are in same macro body expansion
loc = compiler.getSourceManager().getSpellingLoc(loc); loc = compiler.getSourceManager().getSpellingLoc(loc);
} }

View File

@ -32,20 +32,6 @@ bool isSalBoolArray(QualType type) {
|| isSalBoolArray(t->getElementType())); || isSalBoolArray(t->getElementType()));
} }
// Clang 3.2 FunctionDecl::isInlined doesn't work as advertised ("Determine
// whether this function should be inlined, because it is either marked 'inline'
// or 'constexpr' or is a member function of a class that was defined in the
// class body.") but mis-classifies salhelper::Timer's isTicking, isExpired, and
// expiresBefore members as defined in salhelper/source/timer.cxx as inlined:
bool isInlined(FunctionDecl const & decl) {
#if CLANG_VERSION >= 30300
return decl.isInlined();
#else
(void)decl;
return false;
#endif
}
// It appears that, given a function declaration, there is no way to determine // It appears that, given a function declaration, there is no way to determine
// the language linkage of the function's type, only of the function's name // the language linkage of the function's type, only of the function's name
// (via FunctionDecl::isExternC); however, in a case like // (via FunctionDecl::isExternC); however, in a case like
@ -61,15 +47,9 @@ bool hasCLanguageLinkageType(FunctionDecl const * decl) {
if (decl->isExternC()) { if (decl->isExternC()) {
return true; return true;
} }
#if CLANG_VERSION >= 30300
if (decl->isInExternCContext()) { if (decl->isInExternCContext()) {
return true; return true;
} }
#else
if (decl->getCanonicalDecl()->getDeclContext()->isExternCContext()) {
return true;
}
#endif
return false; return false;
} }
@ -94,7 +74,7 @@ OverrideKind getOverrideKind(FunctionDecl const * decl) {
bool hasBoolOverload(FunctionDecl const * decl, bool mustBeDeleted) { bool hasBoolOverload(FunctionDecl const * decl, bool mustBeDeleted) {
unsigned n = decl->getNumParams(); unsigned n = decl->getNumParams();
auto res = decl->getDeclContext()->lookup(decl->getDeclName()); auto res = decl->getDeclContext()->lookup(decl->getDeclName());
for (auto d = compat::begin(res); d != compat::end(res); ++d) { for (auto d = res.begin(); d != res.end(); ++d) {
FunctionDecl const * f = dyn_cast<FunctionDecl>(*d); FunctionDecl const * f = dyn_cast<FunctionDecl>(*d);
if (f != nullptr && (!mustBeDeleted || f->isDeleted())) { if (f != nullptr && (!mustBeDeleted || f->isDeleted())) {
if (f->getNumParams() == n) { if (f->getNumParams() == n) {
@ -298,7 +278,7 @@ bool SalBool::VisitCStyleCastExpr(CStyleCastExpr * expr) {
while (compiler.getSourceManager().isMacroArgExpansion(loc)) { while (compiler.getSourceManager().isMacroArgExpansion(loc)) {
loc = compiler.getSourceManager().getImmediateMacroCallerLoc(loc); loc = compiler.getSourceManager().getImmediateMacroCallerLoc(loc);
} }
if (compat::isMacroBodyExpansion(compiler, loc)) { if (compiler.getSourceManager().isMacroBodyExpansion(loc)) {
StringRef name { Lexer::getImmediateMacroName( StringRef name { Lexer::getImmediateMacroName(
loc, compiler.getSourceManager(), compiler.getLangOpts()) }; loc, compiler.getSourceManager(), compiler.getLangOpts()) };
if (name == "sal_False" || name == "sal_True") { if (name == "sal_False" || name == "sal_True") {
@ -396,7 +376,7 @@ bool SalBool::VisitImplicitCastExpr(ImplicitCastExpr * expr) {
while (compiler.getSourceManager().isMacroArgExpansion(l)) { while (compiler.getSourceManager().isMacroArgExpansion(l)) {
l = compiler.getSourceManager().getImmediateMacroCallerLoc(l); l = compiler.getSourceManager().getImmediateMacroCallerLoc(l);
} }
if (compat::isMacroBodyExpansion(compiler, l)) { if (compiler.getSourceManager().isMacroBodyExpansion(l)) {
auto n = Lexer::getImmediateMacroName( auto n = Lexer::getImmediateMacroName(
l, compiler.getSourceManager(), compiler.getLangOpts()); l, compiler.getSourceManager(), compiler.getLangOpts());
if (n == "sal_False" || n == "sal_True") { if (n == "sal_False" || n == "sal_True") {
@ -495,7 +475,7 @@ bool SalBool::VisitParmVarDecl(ParmVarDecl const * decl) {
|| (isInUnoIncludeFile( || (isInUnoIncludeFile(
compiler.getSourceManager().getSpellingLoc( compiler.getSourceManager().getSpellingLoc(
f->getNameInfo().getLoc())) f->getNameInfo().getLoc()))
&& (!isInlined(*f) || f->hasAttr<DeprecatedAttr>() && (!f->isInlined() || f->hasAttr<DeprecatedAttr>()
|| decl->getType()->isReferenceType() || decl->getType()->isReferenceType()
|| hasBoolOverload(f, false))) || hasBoolOverload(f, false)))
|| f->isDeleted() || hasBoolOverload(f, true))) || f->isDeleted() || hasBoolOverload(f, true)))
@ -672,7 +652,7 @@ bool SalBool::VisitFunctionDecl(FunctionDecl const * decl) {
|| (isInUnoIncludeFile( || (isInUnoIncludeFile(
compiler.getSourceManager().getSpellingLoc( compiler.getSourceManager().getSpellingLoc(
f->getNameInfo().getLoc())) f->getNameInfo().getLoc()))
&& (!isInlined(*f) || f->hasAttr<DeprecatedAttr>())))) && (!f->isInlined() || f->hasAttr<DeprecatedAttr>()))))
{ {
SourceLocation loc { decl->getLocStart() }; SourceLocation loc { decl->getLocStart() };
SourceLocation l { compiler.getSourceManager().getExpansionLoc( SourceLocation l { compiler.getSourceManager().getExpansionLoc(

View File

@ -440,7 +440,7 @@ bool ConstantFunction::VisitFunctionDecl(const FunctionDecl * pFunctionDecl) {
} }
std::string aImmediateMacro = ""; std::string aImmediateMacro = "";
if (compat::isMacroBodyExpansion(compiler, pFunctionDecl->getLocStart()) ) { if (compiler.getSourceManager().isMacroBodyExpansion(pFunctionDecl->getLocStart()) ) {
StringRef name { Lexer::getImmediateMacroName( StringRef name { Lexer::getImmediateMacroName(
pFunctionDecl->getLocStart(), compiler.getSourceManager(), compiler.getLangOpts()) }; pFunctionDecl->getLocStart(), compiler.getSourceManager(), compiler.getLangOpts()) };
aImmediateMacro = name; aImmediateMacro = name;

View File

@ -34,12 +34,8 @@ class RtlConstAsciiMacro
bool VisitCXXConstructExpr( CXXConstructExpr* expr ); bool VisitCXXConstructExpr( CXXConstructExpr* expr );
bool VisitCXXTemporaryObjectExpr( CXXTemporaryObjectExpr* expr ); bool VisitCXXTemporaryObjectExpr( CXXTemporaryObjectExpr* expr );
bool VisitStringLiteral( const StringLiteral* literal ); bool VisitStringLiteral( const StringLiteral* literal );
#if CLANG_VERSION < 30300
virtual void MacroExpands( const Token& macro, const MacroInfo* info, SourceRange range ) override;
#else
virtual void MacroExpands( const Token& macro, const MacroDirective* directive, virtual void MacroExpands( const Token& macro, const MacroDirective* directive,
SourceRange range, const MacroArgs* args ) override; SourceRange range, const MacroArgs* args ) override;
#endif
enum { isPPCallback = true }; enum { isPPCallback = true };
private: private:
map< SourceLocation, SourceLocation > expansions; // start location -> end location map< SourceLocation, SourceLocation > expansions; // start location -> end location
@ -59,12 +55,8 @@ void RtlConstAsciiMacro::run()
TraverseDecl( compiler.getASTContext().getTranslationUnitDecl()); TraverseDecl( compiler.getASTContext().getTranslationUnitDecl());
} }
#if CLANG_VERSION < 30300
void RtlConstAsciiMacro::MacroExpands( const Token& macro, const MacroInfo*, SourceRange range )
#else
void RtlConstAsciiMacro::MacroExpands( const Token& macro, const MacroDirective*, void RtlConstAsciiMacro::MacroExpands( const Token& macro, const MacroDirective*,
SourceRange range, const MacroArgs* ) SourceRange range, const MacroArgs* )
#endif
{ {
if( macro.getIdentifierInfo()->getName() != "RTL_CONSTASCII_USTRINGPARAM" ) if( macro.getIdentifierInfo()->getName() != "RTL_CONSTASCII_USTRINGPARAM" )
return; return;

View File

@ -62,7 +62,7 @@ bool hasOverloads(FunctionDecl const * decl, unsigned arguments) {
ctx = ctx->getParent(); ctx = ctx->getParent();
} }
auto res = ctx->lookup(decl->getDeclName()); auto res = ctx->lookup(decl->getDeclName());
for (auto d = compat::begin(res); d != compat::end(res); ++d) { for (auto d = res.begin(); d != res.end(); ++d) {
FunctionDecl const * f = dyn_cast<FunctionDecl>(*d); FunctionDecl const * f = dyn_cast<FunctionDecl>(*d);
if (f != nullptr && f->getMinRequiredArguments() <= arguments if (f != nullptr && f->getMinRequiredArguments() <= arguments
&& f->getNumParams() >= arguments) && f->getNumParams() >= arguments)
@ -782,7 +782,8 @@ bool StringConstant::VisitCXXConstructExpr(CXXConstructExpr const * expr) {
loc = compiler.getSourceManager() loc = compiler.getSourceManager()
.getImmediateMacroCallerLoc(loc); .getImmediateMacroCallerLoc(loc);
} }
if (compat::isMacroBodyExpansion(compiler, loc) if ((compiler.getSourceManager()
.isMacroBodyExpansion(loc))
&& (Lexer::getImmediateMacroName( && (Lexer::getImmediateMacroName(
loc, compiler.getSourceManager(), loc, compiler.getSourceManager(),
compiler.getLangOpts()) compiler.getLangOpts())
@ -1119,7 +1120,7 @@ void StringConstant::reportChange(
while (compiler.getSourceManager().isMacroArgExpansion(loc)) { while (compiler.getSourceManager().isMacroArgExpansion(loc)) {
loc = compiler.getSourceManager().getImmediateMacroCallerLoc(loc); loc = compiler.getSourceManager().getImmediateMacroCallerLoc(loc);
} }
if (compat::isMacroBodyExpansion(compiler, loc)) { if (compiler.getSourceManager().isMacroBodyExpansion(loc)) {
loc = compiler.getSourceManager().getSpellingLoc(loc); loc = compiler.getSourceManager().getSpellingLoc(loc);
} }
unsigned n = Lexer::MeasureTokenLength( unsigned n = Lexer::MeasureTokenLength(

View File

@ -33,15 +33,9 @@ bool hasCLanguageLinkageType(FunctionDecl const * decl) {
if (decl->isExternC()) { if (decl->isExternC()) {
return true; return true;
} }
#if CLANG_VERSION >= 30300
if (decl->isInExternCContext()) { if (decl->isInExternCContext()) {
return true; return true;
} }
#else
if (decl->getCanonicalDecl()->getDeclContext()->isExternCContext()) {
return true;
}
#endif
return false; return false;
} }
@ -134,13 +128,13 @@ bool UnrefFun::VisitFunctionDecl(FunctionDecl const * decl) {
{ {
return true; return true;
} }
compat::LinkageInfo info(canon->getLinkageAndVisibility()); LinkageInfo info(canon->getLinkageAndVisibility());
if (compat::getLinkage(info) == ExternalLinkage if (info.getLinkage() == ExternalLinkage
&& hasCLanguageLinkageType(canon) && canon->isDefined() && hasCLanguageLinkageType(canon) && canon->isDefined()
&& ((decl == canon && compat::getVisibility(info) == DefaultVisibility) && ((decl == canon && info.getVisibility() == DefaultVisibility)
|| ((canon->hasAttr<ConstructorAttr>() || ((canon->hasAttr<ConstructorAttr>()
|| canon->hasAttr<DestructorAttr>()) || canon->hasAttr<DestructorAttr>())
&& compat::getVisibility(info) == HiddenVisibility))) && info.getVisibility() == HiddenVisibility)))
{ {
return true; return true;
} }