compilerplugins: getAsTagDecl doesn't exist in clang 3.5

Change-Id: If7277820227486e2eb578a167e0fd9f05c8f74ae
Reviewed-on: https://gerrit.libreoffice.org/19823
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
This commit is contained in:
Michael Stahl
2015-11-06 14:23:56 +01:00
parent 24db02dc8d
commit 22fb58a6fa
2 changed files with 11 additions and 1 deletions

View File

@@ -255,6 +255,16 @@ inline bool isMacroBodyExpansion(clang::CompilerInstance& compiler, clang::Sourc
#endif
}
inline auto getAsTagDecl(clang::Type const& t) -> clang::TagDecl *
{
#if (__clang_major__ == 3 && __clang_minor__ > 5) || __clang_major__ > 3
// 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
}
}
#endif

View File

@@ -235,7 +235,7 @@ bool StringConstant::VisitCallExpr(CallExpr const * expr) {
&& t->isClassType()
&& t->getAs<SubstTemplateTypeParmType>() == nullptr)
{
auto td = t->getAsTagDecl();
auto td = compat::getAsTagDecl(*t);
auto id = td->getIdentifier();
if (id != nullptr && id->isStr("OUString")) {
auto nd = dyn_cast<NamespaceDecl>(td->getParent());