[Libreoffice-commits] core.git: compilerplugins/clang

Michael Stahl mstahl at redhat.com
Fri Nov 6 11:38:40 PST 2015


 compilerplugins/clang/compat.hxx         |   10 ++++++++++
 compilerplugins/clang/stringconstant.cxx |    2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

New commits:
commit 22fb58a6fa7764ec0045529c483693e1a81b488e
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Nov 6 14:23:56 2015 +0100

    compilerplugins: getAsTagDecl doesn't exist in clang 3.5
    
    Change-Id: If7277820227486e2eb578a167e0fd9f05c8f74ae
    Reviewed-on: https://gerrit.libreoffice.org/19823
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx
index 0ca37fa..6b14510 100644
--- a/compilerplugins/clang/compat.hxx
+++ b/compilerplugins/clang/compat.hxx
@@ -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
diff --git a/compilerplugins/clang/stringconstant.cxx b/compilerplugins/clang/stringconstant.cxx
index 8fbed25..56ae27c 100644
--- a/compilerplugins/clang/stringconstant.cxx
+++ b/compilerplugins/clang/stringconstant.cxx
@@ -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());


More information about the Libreoffice-commits mailing list