[Libreoffice-commits] core.git: 2 commits - compilerplugins/clang
Stephan Bergmann
sbergman at redhat.com
Fri Jan 31 00:52:55 PST 2014
compilerplugins/clang/compat.hxx | 64 +++++++++++++++++++++++
compilerplugins/clang/implicitboolconversion.cxx | 15 +++--
compilerplugins/clang/pluginhandler.cxx | 5 +
3 files changed, 76 insertions(+), 8 deletions(-)
New commits:
commit 11235e86497df47ff3acc61c1cab9fff0b91949e
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Jan 31 09:50:21 2014 +0100
clang::DiagnosticsEnginge::getCustomDiagID now needs a literal FormatString
...at least in trunk 200400 towards Clang 3.5.
Change-Id: Ibe956a7f28c16510506bd354582b3fe5a72582e5
diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx
index 9e35049..d4d92a0 100644
--- a/compilerplugins/clang/compat.hxx
+++ b/compilerplugins/clang/compat.hxx
@@ -12,6 +12,9 @@
#include "clang/AST/Decl.h"
#include "clang/AST/Type.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticIDs.h"
+#include "llvm/ADT/StringRef.h"
// Compatibility wrapper to abstract over (trivial) chanes in the Clang API:
namespace compat {
@@ -42,6 +45,18 @@ inline clang::QualType getParamType(
#endif
}
+inline unsigned getCustomDiagID(
+ clang::DiagnosticsEngine const & engine, clang::DiagnosticsEngine::Level L,
+ llvm::StringRef FormatString)
+{
+#if (__clang_major__ == 3 && __clang_minor__ >= 5) || __clang_major__ > 3
+ return engine.getDiagnosticIDs()->getCustomDiagID(
+ static_cast<clang::DiagnosticIDs::Level>(L), FormatString);
+#else
+ return engine.getCustomDiagID(L, FormatString);
+#endif
+}
+
}
#endif
diff --git a/compilerplugins/clang/pluginhandler.cxx b/compilerplugins/clang/pluginhandler.cxx
index 440df1c..345363b 100644
--- a/compilerplugins/clang/pluginhandler.cxx
+++ b/compilerplugins/clang/pluginhandler.cxx
@@ -9,6 +9,7 @@
*
*/
+#include "compat.hxx"
#include "pluginhandler.hxx"
#include <clang/Frontend/CompilerInstance.h>
@@ -161,9 +162,9 @@ DiagnosticBuilder PluginHandler::report( DiagnosticsEngine::Level level, const c
}
fullMessage += "]";
if( loc.isValid())
- return diag.Report( loc, diag.getCustomDiagID( level, fullMessage ));
+ return diag.Report( loc, compat::getCustomDiagID(diag, level, fullMessage) );
else
- return diag.Report( diag.getCustomDiagID( level, fullMessage ));
+ return diag.Report( compat::getCustomDiagID(diag, level, fullMessage) );
}
DiagnosticBuilder PluginHandler::report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc )
commit b21e3d16aa21992d6370c4b57a83039c433ef070
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Jan 31 09:37:27 2014 +0100
Clang API function terminology got changed
...at least in trunk 200400 towards Clang 3.5.
Change-Id: I6e295e3a4cf721fbda9df8e7c5bed3993ee78216
diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx
new file mode 100644
index 0000000..9e35049
--- /dev/null
+++ b/compilerplugins/clang/compat.hxx
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_COMPILERPLUGINS_CLANG_COMPAT_HXX
+#define INCLUDED_COMPILERPLUGINS_CLANG_COMPAT_HXX
+
+#include "clang/AST/Decl.h"
+#include "clang/AST/Type.h"
+
+// Compatibility wrapper to abstract over (trivial) chanes in the Clang API:
+namespace compat {
+
+inline clang::QualType getReturnType(clang::FunctionDecl const & decl) {
+#if (__clang_major__ == 3 && __clang_minor__ >= 5) || __clang_major__ > 3
+ return decl.getReturnType();
+#else
+ return decl.getResultType();
+#endif
+}
+
+inline unsigned getNumParams(clang::FunctionProtoType const & type) {
+#if (__clang_major__ == 3 && __clang_minor__ >= 5) || __clang_major__ > 3
+ return type.getNumParams();
+#else
+ return type.getNumArgs();
+#endif
+}
+
+inline clang::QualType getParamType(
+ clang::FunctionProtoType const & type, unsigned i)
+{
+#if (__clang_major__ == 3 && __clang_minor__ >= 5) || __clang_major__ > 3
+ return type.getParamType(i);
+#else
+ return type.getArgType(i);
+#endif
+}
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/implicitboolconversion.cxx b/compilerplugins/clang/implicitboolconversion.cxx
index ae26e01..5a44ad6 100644
--- a/compilerplugins/clang/implicitboolconversion.cxx
+++ b/compilerplugins/clang/implicitboolconversion.cxx
@@ -15,6 +15,7 @@
#include <string>
#include <vector>
+#include "compat.hxx"
#include "plugin.hxx"
template<> struct std::iterator_traits<ExprIterator> {
@@ -183,11 +184,11 @@ bool ImplicitBoolConversion::TraverseCallExpr(CallExpr * expr) {
} else {
std::ptrdiff_t n = j - expr->arg_begin();
assert(n >= 0);
- assert(n < t->getNumArgs() || t->isVariadic());
- if (n < t->getNumArgs()
- && !(t->getArgType(n)->isSpecificBuiltinType(
+ assert(n < compat::getNumParams(*t) || t->isVariadic());
+ if (n < compat::getNumParams(*t)
+ && !(compat::getParamType(*t, n)->isSpecificBuiltinType(
BuiltinType::Int)
- || (t->getArgType(n)->isSpecificBuiltinType(
+ || (compat::getParamType(*t, n)->isSpecificBuiltinType(
BuiltinType::UInt))))
{
reportWarning(i);
@@ -494,8 +495,10 @@ bool ImplicitBoolConversion::TraverseReturnStmt(ReturnStmt * stmt) {
bool ImplicitBoolConversion::TraverseFunctionDecl(FunctionDecl * decl) {
bool ext = hasCLanguageLinkageType(decl)
&& decl->isThisDeclarationADefinition()
- && (decl->getResultType()->isSpecificBuiltinType(BuiltinType::Int)
- || decl->getResultType()->isSpecificBuiltinType(BuiltinType::UInt));
+ && (compat::getReturnType(*decl)->isSpecificBuiltinType(
+ BuiltinType::Int)
+ || compat::getReturnType(*decl)->isSpecificBuiltinType(
+ BuiltinType::UInt));
if (ext) {
assert(!externCIntFunctionDefinition);
externCIntFunctionDefinition = true;
More information about the Libreoffice-commits
mailing list