summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Chimento <philip.chimento@gmail.com>2019-12-10 14:06:51 -0800
committerPhilip Chimento <philip.chimento@gmail.com>2019-12-16 15:39:34 -0500
commit737bbd25665b7993604d0ceda35184aea6a264ac (patch)
tree089d4ca267f40116f954b96b74adcb9e3cb5be81
parentaa19a533cb55d1fcaa8d47429aba2fd1372defd8 (diff)
clang-plugin: Update to LLVM 7.0
Some minor API changes are needed for this. We also make 7.0 the minimum required version. It's the version currently shipped in Debian Stable, so that's a good baseline. (At the time of writing, 9.0.0 is the latest released version.) Fixes: #5
-rw-r--r--README2
-rw-r--r--clang-plugin/assertion-extracter.cpp9
-rw-r--r--clang-plugin/gassert-attributes.cpp5
-rw-r--r--clang-plugin/gerror-checker.cpp11
-rw-r--r--clang-plugin/gir-attributes.cpp14
-rw-r--r--clang-plugin/gsignal-checker.cpp2
-rw-r--r--clang-plugin/nullability-checker.cpp2
-rw-r--r--configure.ac2
-rw-r--r--tests/gsignal-connect.c3
9 files changed, 25 insertions, 25 deletions
diff --git a/README b/README
index 6606552..f138e8e 100644
--- a/README
+++ b/README
@@ -17,7 +17,7 @@ Dependencies
• glib-2.0 ≥ 2.38.0
• gio-2.0 ≥ 2.38.0
• gobject-introspection-1.0 ≥ 1.38.0
- • llvm ≥ 4.0
+ • llvm ≥ 7.0
Licensing
=========
diff --git a/clang-plugin/assertion-extracter.cpp b/clang-plugin/assertion-extracter.cpp
index 80fcf59..61ec110 100644
--- a/clang-plugin/assertion-extracter.cpp
+++ b/clang-plugin/assertion-extracter.cpp
@@ -70,7 +70,8 @@ _negation_expr (Expr* e, const ASTContext& context)
return new (context)
UnaryOperator (e, UnaryOperatorKind::UO_LNot,
context.getLogicalOperationType (),
- VK_RValue, OK_Ordinary, SourceLocation ());
+ VK_RValue, OK_Ordinary, SourceLocation (),
+ /* can_overflow = */ false);
}
/* Combine expressions A and B to give (A && B). */
@@ -81,7 +82,7 @@ _conjunction_expr (Expr* lhs, Expr* rhs, const ASTContext& context)
BinaryOperator (lhs, rhs, BinaryOperatorKind::BO_LAnd,
context.getLogicalOperationType (),
VK_RValue, OK_Ordinary, SourceLocation (),
- false);
+ FPOptions ());
}
/* Combine expressions A and B to give (A || B). */
@@ -92,7 +93,7 @@ _disjunction_expr (Expr* lhs, Expr* rhs, const ASTContext& context)
BinaryOperator (lhs, rhs, BinaryOperatorKind::BO_LOr,
context.getLogicalOperationType (),
VK_RValue, OK_Ordinary, SourceLocation (),
- false);
+ FPOptions ());
}
/* Does the given statement look like:
@@ -532,7 +533,7 @@ _simplify_boolean_expr (Expr* expr, const ASTContext& context)
BinaryOperator (lhs, rhs, opcode,
context.getLogicalOperationType (),
VK_RValue, OK_Ordinary, SourceLocation (),
- false);
+ FPOptions ());
}
/* ! (S1 op S2) ↦ ! (simplify(S1) op simplify(S2)) */
diff --git a/clang-plugin/gassert-attributes.cpp b/clang-plugin/gassert-attributes.cpp
index 0a6b89e..362a120 100644
--- a/clang-plugin/gassert-attributes.cpp
+++ b/clang-plugin/gassert-attributes.cpp
@@ -65,7 +65,7 @@ _handle_assertion (FunctionDecl& func, Expr& assertion_expr,
return;
/* TODO: Factor out the code to augment a nonnull attribute. */
- std::vector<unsigned int> non_null_args;
+ std::vector<ParamIdx> non_null_args;
NonNullAttr* nonnull_attr = func.getAttr<NonNullAttr> ();
if (nonnull_attr != NULL) {
@@ -92,7 +92,8 @@ _handle_assertion (FunctionDecl& func, Expr& assertion_expr,
unsigned int j = parm_decl->getFunctionScopeIndex ();
DEBUG ("Got nonnull arg " << j << " (" <<
val_decl->getNameAsString () << ") from assertion.");
- non_null_args.push_back (j);
+ /* ParamIdx is 1-based. */
+ non_null_args.push_back (ParamIdx (j + 1, &func));
}
if (non_null_args.size () > 0) {
diff --git a/clang-plugin/gerror-checker.cpp b/clang-plugin/gerror-checker.cpp
index 0b6b917..5d12fa4 100644
--- a/clang-plugin/gerror-checker.cpp
+++ b/clang-plugin/gerror-checker.cpp
@@ -679,7 +679,8 @@ GErrorChecker::_gerror_new (const Expr *call_expr,
}
/* Fill the region with the initialization value. */
- state = state->bindDefault (*allocated_sval, UndefinedVal ());
+ state = state->bindDefaultInitial (*allocated_sval, UndefinedVal (),
+ context.getLocationContext ());
const MemRegion *allocated_region = allocated_sval->getAsRegion ();
assert (allocated_region);
@@ -732,7 +733,7 @@ GErrorChecker::_gerror_free (SVal error_location, ProgramStateRef state,
/* Fill the MemRegion with rubbish. */
if (error_location.getAs<Loc> ()) {
state = state->bindLoc (error_location.castAs<Loc> (),
- UndefinedVal ());
+ UndefinedVal (), context.getLocationContext ());
assert (state != NULL);
}
@@ -1004,7 +1005,8 @@ GErrorChecker::_set_gerror (SVal error_location,
const SourceRange &source_range) const
{
/* Bind the error location to the new error. */
- state = state->bindLoc (error_location, new_error);
+ state = state->bindLoc (error_location, new_error,
+ context.getLocationContext ());
assert (state != NULL);
/* Constrain the GError* location (lvalue) and rvalue to be non-NULL. */
@@ -1040,7 +1042,8 @@ GErrorChecker::_clear_gerror (SVal error_location,
/* Bind the GError* to NULL. */
SValBuilder &sval_builder = context.getSValBuilder ();
- state = state->bindLoc (error_location, sval_builder.makeNull ());
+ state = state->bindLoc (error_location, sval_builder.makeNull (),
+ context.getLocationContext ());
assert (state != NULL);
/* Constrain the GError* location (lvalue) to be NULL. */
diff --git a/clang-plugin/gir-attributes.cpp b/clang-plugin/gir-attributes.cpp
index a245e92..d38e515 100644
--- a/clang-plugin/gir-attributes.cpp
+++ b/clang-plugin/gir-attributes.cpp
@@ -207,7 +207,7 @@ GirAttributesConsumer::_handle_function_decl (FunctionDecl& func)
break;
}
- std::vector<unsigned int> non_null_args;
+ std::vector<ParamIdx> non_null_args;
unsigned int j;
NonNullAttr* nonnull_attr = func.getAttr<NonNullAttr> ();
@@ -230,11 +230,6 @@ GirAttributesConsumer::_handle_function_decl (FunctionDecl& func)
transfer = g_arg_info_get_ownership_transfer (&arg);
type_tag = g_type_info_get_tag (&type_info);
- DEBUG_CODE (int array_type =
- (g_type_info_get_tag (&type_info) ==
- GI_TYPE_TAG_ARRAY) ?
- g_type_info_get_array_type (&type_info) :
- -1);
DEBUG ("GirAttributes: " << func_name << "(" << j <<
")\n"
"\tTransfer: " << transfer << "\n"
@@ -250,7 +245,9 @@ GirAttributesConsumer::_handle_function_decl (FunctionDecl& func)
g_type_tag_to_string (
g_type_info_get_tag (&type_info)) << "\n"
"\tArray type: " <<
- array_type << "\n"
+ ((g_type_info_get_tag (&type_info) == GI_TYPE_TAG_ARRAY) ?
+ g_type_info_get_array_type (&type_info) :
+ -1) << "\n"
"\tArray length: " <<
g_type_info_get_array_length (&type_info) << "\n"
"\tArray fixed size: " <<
@@ -259,7 +256,8 @@ GirAttributesConsumer::_handle_function_decl (FunctionDecl& func)
if (_arg_is_nonnull (arg, type_info)) {
DEBUG ("Got nonnull arg " << obj_params + j <<
" from GIR.");
- non_null_args.push_back (obj_params + j);
+ /* ParamIdx is 1-based. */
+ non_null_args.push_back (ParamIdx (obj_params + j + 1, &func));
}
if (_type_should_be_const (transfer, type_tag)) {
diff --git a/clang-plugin/gsignal-checker.cpp b/clang-plugin/gsignal-checker.cpp
index e9d3d06..74db5c4 100644
--- a/clang-plugin/gsignal-checker.cpp
+++ b/clang-plugin/gsignal-checker.cpp
@@ -617,7 +617,7 @@ calling_convention_is_safe (CallingConv conv)
{
switch (conv) {
case CC_C: /* cdecl */
- case CC_X86_64Win64: /* x86-64 */
+ case CC_Win64: /* x86-64 */
case CC_X86_64SysV: /* x86-64 */
case CC_AAPCS: /* ARM */
case CC_AAPCS_VFP: /* ARM with VFP registers */
diff --git a/clang-plugin/nullability-checker.cpp b/clang-plugin/nullability-checker.cpp
index 1a38e34..2bdd05b 100644
--- a/clang-plugin/nullability-checker.cpp
+++ b/clang-plugin/nullability-checker.cpp
@@ -118,7 +118,7 @@ NullabilityVisitor::TraverseFunctionDecl (FunctionDecl* func)
DEBUG ("nonnull attribute indices:");
for (NonNullAttr::args_iterator it = nonnull_attr->args_begin (),
ie = nonnull_attr->args_end (); it != ie; ++it) {
- DEBUG ("\t" << *it);
+ DEBUG ("\t" << it->getSourceIndex ());
}
} else {
DEBUG ("No nonnull attribute.");
diff --git a/configure.ac b/configure.ac
index 3837e8b..1c26797 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,7 +30,7 @@ LT_INIT([])
PKG_PROG_PKG_CONFIG
# Requirements
-LLVM_REQS=4.0
+LLVM_REQS=7.0
GLIB_REQS=2.38 # TODO
GIO_REQS=2.38 # TODO
GIR_REQS=1.38.0 # TODO
diff --git a/tests/gsignal-connect.c b/tests/gsignal-connect.c
index abbcb94..43e361f 100644
--- a/tests/gsignal-connect.c
+++ b/tests/gsignal-connect.c
@@ -35,9 +35,6 @@
* Could not check type of handler for signal ‘GObject::notify’. Callback function declaration does not contain parameter types.
* (GCallback) object_notify_no_proto_cb,
* ^
- * note: expanded from macro 'g_signal_connect'
- * g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, (GConnectFlags) 0)
- * ^
*/
{
GObject *some_object = g_malloc (5); // only checking the type