summaryrefslogtreecommitdiff
path: root/clang-plugin
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2014-11-03 17:29:30 +0000
committerPhilip Withnall <philip.withnall@collabora.co.uk>2014-11-03 17:29:30 +0000
commitcc8077a3794cecb515177d4ba572b3c73d81c40d (patch)
treebfb615360f2c6fb06c07cff67d2f8d05797fd06c /clang-plugin
parentba207a3730d9a9c7fe631b02b12f44cb43fbf3fc (diff)
plugin: Update Clang types API to support LLVM 3.5
The API renamed ‘result’ to ‘return’ and ‘argument’ to ‘parameter’.
Diffstat (limited to 'clang-plugin')
-rw-r--r--clang-plugin/gir-attributes.cpp18
-rw-r--r--clang-plugin/gsignal-checker.cpp18
2 files changed, 34 insertions, 2 deletions
diff --git a/clang-plugin/gir-attributes.cpp b/clang-plugin/gir-attributes.cpp
index d062705..4ccace0 100644
--- a/clang-plugin/gir-attributes.cpp
+++ b/clang-plugin/gir-attributes.cpp
@@ -72,7 +72,11 @@ _arg_is_nonnull (GIArgInfo arg, GITypeInfo type_info)
static bool
_function_return_type_is_const (FunctionDecl& func)
{
+#ifdef HAVE_LLVM_3_5
+ QualType type = func.getReturnType ();
+#else /* if !HAVE_LLVM_3_5 */
QualType type = func.getResultType ();
+#endif /* !HAVE_LLVM_3_5 */
const PointerType* pointer_type = dyn_cast<PointerType> (type);
if (pointer_type == NULL)
@@ -95,7 +99,11 @@ _constify_function_return_type (FunctionDecl& func)
* is immutable. */
const FunctionType* f_type = func.getType ()->getAs<FunctionType> ();
ASTContext& context = func.getASTContext ();
+#ifdef HAVE_LLVM_3_5
+ const QualType old_result_type = f_type->getReturnType ();
+#else /* if !HAVE_LLVM_3_5 */
const QualType old_result_type = f_type->getResultType ();
+#endif /* !HAVE_LLVM_3_5 */
const PointerType* old_result_pointer_type = dyn_cast<PointerType> (old_result_type);
if (old_result_pointer_type == NULL)
@@ -117,8 +125,16 @@ _constify_function_return_type (FunctionDecl& func)
} else {
const FunctionProtoType *f_p_type =
cast<FunctionProtoType> (f_type);
+ ArrayRef<QualType> param_types;
+
+#ifdef HAVE_LLVM_3_5
+ param_types = f_p_type->getParamTypes ();
+#else /* !HAVE_LLVM_3_5 */
+ param_types = f_p_type->getArgTypes ();
+#endif /* !HAVE_LLVM_3_5 */
+
t = context.getFunctionType (new_result_type,
- f_p_type->getArgTypes (),
+ param_types,
f_p_type->getExtProtoInfo ());
}
diff --git a/clang-plugin/gsignal-checker.cpp b/clang-plugin/gsignal-checker.cpp
index adcbfec..a7a7342 100644
--- a/clang-plugin/gsignal-checker.cpp
+++ b/clang-plugin/gsignal-checker.cpp
@@ -69,6 +69,8 @@
* A = gpointer
*/
+#include "config.h"
+
#include <cstring>
#include <clang/AST/Attr.h>
@@ -742,7 +744,13 @@ _check_signal_callback_type (const Expr *expr,
*/
GICallableInfo *callable_info = signal_info;
guint n_signal_args = g_callable_info_get_n_args (callable_info) + 2;
- guint n_callback_args = callback_type->getNumArgs ();
+ guint n_callback_args;
+
+#ifdef HAVE_LLVM_3_5
+ n_callback_args = callback_type->getNumParams ();
+#else /* if !HAVE_LLVM_3_5 */
+ n_callback_args = callback_type->getNumArgs ();
+#endif /* !HAVE_LLVM_3_5 */
GITypeInfo expected_type_info;
QualType actual_type, expected_type;
@@ -771,7 +779,11 @@ _check_signal_callback_type (const Expr *expr,
const gchar *arg_name;
bool type_error;
+#ifdef HAVE_LLVM_3_5
+ actual_type = callback_type->getParamType (i);
+#else /* if !HAVE_LLVM_3_5 */
actual_type = callback_type->getArgType (i);
+#endif /* !HAVE_LLVM_3_5 */
if ((i == 0 && !is_swapped) ||
(i == n_signal_args - 1 && is_swapped)) {
@@ -1007,7 +1019,11 @@ _check_signal_callback_type (const Expr *expr,
/* Return type. */
g_callable_info_load_return_type (callable_info, &expected_type_info);
+#ifdef HAVE_LLVM_3_5
+ actual_type = callback_type->getReturnType ();
+#else /* !HAVE_LLVM_3_5 */
actual_type = callback_type->getResultType ();
+#endif /* HAVE_LLVM_3_5 */
expected_type = _type_info_to_type (&expected_type_info, context,
gir_manager, type_manager);
if (expected_type.isNull ()) {