summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Chimento <philip.chimento@gmail.com>2019-12-10 13:22:05 -0800
committerPhilip Chimento <philip.chimento@gmail.com>2019-12-16 15:26:29 -0500
commitaa19a533cb55d1fcaa8d47429aba2fd1372defd8 (patch)
treec107d4e64e1056bf0d6aa10b7ca74f9e05987b02
parent80455713d6f37d22c35f8a04dc75bd4495789691 (diff)
clang-plugin: Require LLVM 4.0 or later
Remove all the guards that checked for earlier versions. See: #5
-rw-r--r--README2
-rw-r--r--clang-plugin/debug.cpp4
-rw-r--r--clang-plugin/gassert-attributes.cpp8
-rw-r--r--clang-plugin/gerror-checker.cpp36
-rw-r--r--clang-plugin/gir-attributes.cpp70
-rw-r--r--clang-plugin/gsignal-checker.cpp30
-rw-r--r--clang-plugin/plugin.cpp34
-rw-r--r--clang-plugin/type-manager.cpp8
-rw-r--r--configure.ac22
-rwxr-xr-xtests/wrapper-compiler-errors15
10 files changed, 7 insertions, 222 deletions
diff --git a/README b/README
index 7150191..6606552 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 ≥ 3.5
+ • llvm ≥ 4.0
Licensing
=========
diff --git a/clang-plugin/debug.cpp b/clang-plugin/debug.cpp
index de14658..05d2fe5 100644
--- a/clang-plugin/debug.cpp
+++ b/clang-plugin/debug.cpp
@@ -37,11 +37,7 @@ void
Debug::emit_bug_report (std::unique_ptr<BugReport> report,
CheckerContext &context)
{
- #ifndef HAVE_LLVM_3_7
- context.emitReport (report.get ());
- #else
context.emitReport (std::move (report));
- #endif
}
/* Build and emit a warning or error report about the user’s code. */
diff --git a/clang-plugin/gassert-attributes.cpp b/clang-plugin/gassert-attributes.cpp
index 29f97ef..0a6b89e 100644
--- a/clang-plugin/gassert-attributes.cpp
+++ b/clang-plugin/gassert-attributes.cpp
@@ -96,19 +96,11 @@ _handle_assertion (FunctionDecl& func, Expr& assertion_expr,
}
if (non_null_args.size () > 0) {
-#ifdef HAVE_LLVM_3_5
nonnull_attr = ::new (func.getASTContext ())
NonNullAttr (func.getSourceRange (),
func.getASTContext (),
non_null_args.data (),
non_null_args.size (), 0);
-#else /* if !HAVE_LLVM_3_5 */
- nonnull_attr = ::new (func.getASTContext ())
- NonNullAttr (func.getSourceRange (),
- func.getASTContext (),
- non_null_args.data (),
- non_null_args.size ());
-#endif /* !HAVE_LLVM_3_5 */
func.addAttr (nonnull_attr);
}
}
diff --git a/clang-plugin/gerror-checker.cpp b/clang-plugin/gerror-checker.cpp
index f11133f..0b6b917 100644
--- a/clang-plugin/gerror-checker.cpp
+++ b/clang-plugin/gerror-checker.cpp
@@ -764,11 +764,7 @@ GErrorChecker::_assert_gerror_set (SVal error_location,
const SourceRange &source_range) const
{
if (error_location.getAs<UndefinedVal> ()) {
-#if HAVE_LLVM_3_8
ExplodedNode *error_node = context.generateErrorNode (state);
-#else
- ExplodedNode *error_node = context.generateSink (state);
-#endif
this->_initialise_bug_reports ();
auto R = llvm::make_unique<BugReport> (*this->_use_uninitialised,
@@ -793,11 +789,7 @@ GErrorChecker::_assert_gerror_set (SVal error_location,
state->assume (error_location.castAs<DefinedOrUnknownSVal> ());
if (null_state && !not_null_state && !null_allowed) {
/* Definitely NULL. */
-#if HAVE_LLVM_3_8
ExplodedNode *error_node = context.generateErrorNode (state);
-#else
- ExplodedNode *error_node = context.generateSink (state);
-#endif
this->_initialise_bug_reports ();
auto R = llvm::make_unique<BugReport> (*this->_free_cleared,
@@ -826,11 +818,7 @@ GErrorChecker::_assert_gerror_set (SVal error_location,
const ErrorState *error_state = _error_map_get (state, error_sym);
if (error_state != NULL && error_state->isFreed ()) {
-#if HAVE_LLVM_3_8
ExplodedNode *error_node = context.generateErrorNode (state);
-#else
- ExplodedNode *error_node = context.generateSink (state);
-#endif
this->_initialise_bug_reports ();
auto R = llvm::make_unique<BugReport> (*this->_double_free,
@@ -842,13 +830,7 @@ GErrorChecker::_assert_gerror_set (SVal error_location,
return false;
} else if (error_state != NULL && !error_state->isSet ()) {
-#if HAVE_LLVM_3_8
ExplodedNode *error_node = context.generateErrorNode (state);
-#else
- ExplodedNode *error_node = context.generateSink (state);
-#endif
-
-
this->_initialise_bug_reports ();
auto R = llvm::make_unique<BugReport> (*this->_free_cleared,
@@ -929,13 +911,7 @@ GErrorChecker::_assert_gerror_unset (SVal error_location,
/* Branch on whether the GError* is NULL. If it isn’t NULL, there’s a
* bug. */
if (error_location.getAs<UndefinedVal> () && !undef_allowed) {
-#if HAVE_LLVM_3_8
ExplodedNode *error_node = context.generateErrorNode (state);
-#else
- ExplodedNode *error_node = context.generateSink (state);
-#endif
-
-
this->_initialise_bug_reports ();
auto R = llvm::make_unique<BugReport> (*this->_use_uninitialised,
@@ -970,13 +946,7 @@ GErrorChecker::_assert_gerror_unset (SVal error_location,
const ErrorState *error_state = _error_map_get (state, error_sym);
if (error_state != NULL && error_state->isSet ()) {
-#if HAVE_LLVM_3_8
ExplodedNode *error_node = context.generateErrorNode (state);
-#else
- ExplodedNode *error_node = context.generateSink (state);
-#endif
-
-
this->_initialise_bug_reports ();
auto R = llvm::make_unique<BugReport> (*this->_overwrite_set,
@@ -989,13 +959,7 @@ GErrorChecker::_assert_gerror_unset (SVal error_location,
return false;
} else if (error_state != NULL && error_state->isFreed () &&
!undef_allowed) {
-#if HAVE_LLVM_3_8
ExplodedNode *error_node = context.generateErrorNode (state);
-#else
- ExplodedNode *error_node = context.generateSink (state);
-#endif
-
-
this->_initialise_bug_reports ();
auto R = llvm::make_unique<BugReport> (*this->_overwrite_freed,
diff --git a/clang-plugin/gir-attributes.cpp b/clang-plugin/gir-attributes.cpp
index 8309eca..a245e92 100644
--- a/clang-plugin/gir-attributes.cpp
+++ b/clang-plugin/gir-attributes.cpp
@@ -72,12 +72,7 @@ _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 */
-
QualType canonical_type = type.getCanonicalType ();
const PointerType* pointer_type = dyn_cast<PointerType> (canonical_type);
@@ -105,11 +100,7 @@ _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)
@@ -131,13 +122,7 @@ _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 */
+ ArrayRef<QualType> param_types = f_p_type->getParamTypes ();
t = context.getFunctionType (new_result_type,
param_types,
@@ -288,19 +273,11 @@ GirAttributesConsumer::_handle_function_decl (FunctionDecl& func)
if (non_null_args.size () > 0 &&
!_ignore_glib_internal_func (func_name)) {
-#ifdef HAVE_LLVM_3_5
nonnull_attr = ::new (func.getASTContext ())
NonNullAttr (func.getSourceRange (),
func.getASTContext (),
non_null_args.data (),
non_null_args.size (), 0);
-#else /* if !HAVE_LLVM_3_5 */
- nonnull_attr = ::new (func.getASTContext ())
- NonNullAttr (func.getSourceRange (),
- func.getASTContext (),
- non_null_args.data (),
- non_null_args.size ());
-#endif /* !HAVE_LLVM_3_5 */
func.addAttr (nonnull_attr);
}
@@ -316,17 +293,10 @@ GirAttributesConsumer::_handle_function_decl (FunctionDecl& func)
return_type_tag = g_type_info_get_tag (&return_type_info);
if (return_transfer != GI_TRANSFER_NOTHING) {
-#ifdef HAVE_LLVM_3_5
WarnUnusedAttr* warn_unused_attr =
::new (func.getASTContext ())
WarnUnusedAttr (func.getSourceRange (),
func.getASTContext (), 0);
-#else /* if !HAVE_LLVM_3_5 */
- WarnUnusedAttr* warn_unused_attr =
- ::new (func.getASTContext ())
- WarnUnusedAttr (func.getSourceRange (),
- func.getASTContext ());
-#endif /* !HAVE_LLVM_3_5 */
func.addAttr (warn_unused_attr);
} else if (_type_should_be_const (return_transfer,
return_type_tag)) {
@@ -338,33 +308,16 @@ GirAttributesConsumer::_handle_function_decl (FunctionDecl& func)
* or replacement function so we can’t make use of them. */
if (g_base_info_is_deprecated (info) &&
!func.hasAttr<DeprecatedAttr> ()) {
-#ifdef HAVE_LLVM_3_8
DeprecatedAttr* deprecated_attr =
::new (func.getASTContext ())
DeprecatedAttr (func.getSourceRange (),
func.getASTContext (),
0);
-#elif HAVE_LLVM_3_5
- DeprecatedAttr* deprecated_attr =
- ::new (func.getASTContext ())
- DeprecatedAttr (func.getSourceRange (),
- func.getASTContext (),
- "Deprecated using the gtk-doc "
- "attribute.", 0);
-#else /* if !HAVE_LLVM_3_5 */
- DeprecatedAttr* deprecated_attr =
- ::new (func.getASTContext ())
- DeprecatedAttr (func.getSourceRange (),
- func.getASTContext (),
- "Deprecated using the gtk-doc "
- "attribute.");
-#endif /* !HAVE_LLVM_3_5 */
func.addAttr (deprecated_attr);
}
/* Mark the function as allocating memory if it’s a
* constructor. */
-#if defined(HAVE_LLVM_3_7)
if (g_function_info_get_flags (info) &
GI_FUNCTION_IS_CONSTRUCTOR &&
!func.hasAttr<RestrictAttr> ()) {
@@ -374,27 +327,6 @@ GirAttributesConsumer::_handle_function_decl (FunctionDecl& func)
func.getASTContext (), 0);
func.addAttr (malloc_attr);
}
-#elif defined(HAVE_LLVM_3_6)
- if (g_function_info_get_flags (info) &
- GI_FUNCTION_IS_CONSTRUCTOR &&
- !func.hasAttr<MallocAttr> ()) {
- MallocAttr* malloc_attr =
- ::new (func.getASTContext ())
- MallocAttr (func.getSourceRange (),
- func.getASTContext (), 0);
- func.addAttr (malloc_attr);
- }
-#else
- if (g_function_info_get_flags (info) &
- GI_FUNCTION_IS_CONSTRUCTOR &&
- !func.hasAttr<MallocAttr> ()) {
- MallocAttr* malloc_attr =
- ::new (func.getASTContext ())
- MallocAttr (func.getSourceRange (),
- func.getASTContext ());
- func.addAttr (malloc_attr);
- }
-#endif
break;
}
diff --git a/clang-plugin/gsignal-checker.cpp b/clang-plugin/gsignal-checker.cpp
index 2a2be1c..e9d3d06 100644
--- a/clang-plugin/gsignal-checker.cpp
+++ b/clang-plugin/gsignal-checker.cpp
@@ -621,41 +621,27 @@ calling_convention_is_safe (CallingConv conv)
case CC_X86_64SysV: /* x86-64 */
case CC_AAPCS: /* ARM */
case CC_AAPCS_VFP: /* ARM with VFP registers */
-#ifndef HAVE_LLVM_3_7
- case CC_PnaclCall: /* Chromium PNC — equivalent to cdecl */
-#endif
-#ifdef HAVE_LLVM_3_9
case CC_Swift: /* Swift — lowered to C calling conventions */
case CC_PreserveMost: /* arguments passed identically to cdecl */
case CC_PreserveAll: /* arguments passed identically to cdecl */
-#endif
-#ifdef HAVE_LLVM_4_0
case CC_X86RegCall:
-#endif
return true;
case CC_X86StdCall:
case CC_X86FastCall:
case CC_X86ThisCall:
case CC_X86Pascal:
-#ifdef HAVE_LLVM_3_7
case CC_X86VectorCall:
-#endif
return false;
case CC_IntelOclBicc:
/* Intel OpenCL Built-Ins. I can’t find any documentation about
* this, so let’s consider it unsafe. */
-#ifdef HAVE_LLVM_3_9
case CC_SpirFunction:
case CC_OpenCLKernel:
-#elif HAVE_LLVM_3_8
- case CC_SpirFunction:
- case CC_SpirKernel:
/* OpenCL SPIR calling conventions. These are ‘defined’ in §3.7
* of
* https://www.khronos.org/files/opencl-spir-12-provisional.pdf,
* but without enough information to classify them as safe or
* unsafe. */
-#endif
default:
return false;
}
@@ -783,13 +769,7 @@ _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;
-
-#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 */
+ guint n_callback_args = callback_type->getNumParams ();
GITypeInfo expected_type_info;
QualType actual_type, expected_type;
@@ -818,11 +798,7 @@ _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)) {
@@ -1058,11 +1034,7 @@ _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 ()) {
diff --git a/clang-plugin/plugin.cpp b/clang-plugin/plugin.cpp
index a2544db..8e8b5b8 100644
--- a/clang-plugin/plugin.cpp
+++ b/clang-plugin/plugin.cpp
@@ -69,7 +69,6 @@ protected:
* of the ASTConsumer. The TartanAction object is destroyed immediately
* after this function call returns, so must be careful not to retain
* state which is needed by the consumers. */
-#ifdef HAVE_LLVM_3_6
std::unique_ptr<ASTConsumer>
CreateASTConsumer (CompilerInstance &compiler, llvm::StringRef in_file)
{
@@ -118,39 +117,6 @@ protected:
return llvm::make_unique<MultiplexConsumer> (std::move (consumers));
}
-#else /* if !HAVE_LLVM_3_6 */
- ASTConsumer *
- CreateASTConsumer (CompilerInstance &compiler, llvm::StringRef in_file)
- {
- std::vector<ASTConsumer*> consumers;
-
- /* Annotaters. */
- consumers.push_back (
- new GirAttributesConsumer (global_gir_manager));
- consumers.push_back (
- new GAssertAttributesConsumer ());
-
- /* Checkers. */
- consumers.push_back (
- new NullabilityConsumer (compiler,
- global_gir_manager,
- this->_disabled_checkers));
- consumers.push_back (
- new GVariantConsumer (compiler,
- global_gir_manager,
- this->_disabled_checkers));
- consumers.push_back (
- new GSignalConsumer (compiler,
- global_gir_manager,
- this->_disabled_checkers));
- consumers.push_back (
- new GirAttributesChecker (compiler,
- global_gir_manager,
- this->_disabled_checkers));
-
- return new MultiplexConsumer (consumers);
- }
-#endif /* !HAVE_LLVM_3_6 */
private:
bool
diff --git a/clang-plugin/type-manager.cpp b/clang-plugin/type-manager.cpp
index ae6593d..46c7319 100644
--- a/clang-plugin/type-manager.cpp
+++ b/clang-plugin/type-manager.cpp
@@ -47,16 +47,8 @@ TypeManager::find_type_by_name (const std::string name)
return (*cached).second;
}
-#ifdef HAVE_LLVM_3_8
for (SmallVectorImpl<Type *>::const_iterator it = this->_context.getTypes ().begin (),
ie = this->_context.getTypes ().end (); it != ie; ++it) {
-#elif HAVE_LLVM_3_5
- for (SmallVectorImpl<Type *>::const_iterator it = this->_context.types ().begin (),
- ie = this->_context.types ().end (); it != ie; ++it) {
-#else /* if !HAVE_LLVM_3_5 */
- for (ASTContext::const_type_iterator it = this->_context.types_begin (),
- ie = this->_context.types_end (); it != ie; ++it) {
-#endif /* !HAVE_LLVM_3_5 */
const Type *t = *it;
const TypedefType *tt = t->getAs<TypedefType> ();
diff --git a/configure.ac b/configure.ac
index c2a0862..3837e8b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,7 +30,7 @@ LT_INIT([])
PKG_PROG_PKG_CONFIG
# Requirements
-LLVM_REQS=3.5
+LLVM_REQS=4.0
GLIB_REQS=2.38 # TODO
GIO_REQS=2.38 # TODO
GIR_REQS=1.38.0 # TODO
@@ -87,26 +87,6 @@ AC_SUBST([LLVM_VERSION])
AC_DEFINE_UNQUOTED([LLVM_CONFIG_VERSION],"$llvm_version",
[Configured LLVM version])
-# LLVM-specific version definitions
-AS_IF([test "$major" -gt 3 -o "$major" -eq 3 -a "$minor" -ge 5],[
- AC_DEFINE([HAVE_LLVM_3_5], [1], [Whether LLVM ≥ 3.5 is available])
-])
-AS_IF([test "$major" -gt 3 -o "$major" -eq 3 -a "$minor" -ge 6],[
- AC_DEFINE([HAVE_LLVM_3_6], [1], [Whether LLVM ≥ 3.6 is available])
-])
-AS_IF([test "$major" -gt 3 -o "$major" -eq 3 -a "$minor" -ge 7],[
- AC_DEFINE([HAVE_LLVM_3_7], [1], [Whether LLVM ≥ 3.7 is available])
-])
-AS_IF([test "$major" -gt 3 -o "$major" -eq 3 -a "$minor" -ge 8],[
- AC_DEFINE([HAVE_LLVM_3_8], [1], [Whether LLVM ≥ 3.8 is available])
-])
-AS_IF([test "$major" -gt 3 -o "$major" -eq 3 -a "$minor" -ge 9],[
- AC_DEFINE([HAVE_LLVM_3_9], [1], [Whether LLVM ≥ 3.9 is available])
-])
-AS_IF([test "$major" -gt 4 -o "$major" -eq 4 -a "$minor" -ge 0],[
- AC_DEFINE([HAVE_LLVM_4_0], [1], [Whether LLVM ≥ 4.0 is available])
-])
-
# Clang dependency (e.g. the clang-devel package on Fedora)
AC_LANG_PUSH([C++])
old_cppflags="$CPPFLAGS"
diff --git a/tests/wrapper-compiler-errors b/tests/wrapper-compiler-errors
index a9c5024..941024a 100755
--- a/tests/wrapper-compiler-errors
+++ b/tests/wrapper-compiler-errors
@@ -109,20 +109,11 @@ while [[ -f `printf "${temp_dir}/${input_filename}_%02d.c" ${num}` ]]; do
while read line
do
- # Check the string and the string with ‘which’ for
- # ‘that’ against the actual errors. This is a hack
- # needed to support testing against LLVM 3.4 and 3.5
- # from the same test vectors.
- #
- # See commit 0743df4033967c18a5009e4f01ccf709f7c06c86
- # for details.
+ # Check the string against the actual errors.
grep -F "${line}" "${actual_error_filename}" >/dev/null
- grep_status1=$?
+ grep_status=$?
- grep -F "${line//that/which}" "${actual_error_filename}" >/dev/null
- grep_status2=$?
-
- if [ $grep_status1 -ne 0 -a $grep_status2 -ne 0 ]; then
+ if [ $grep_status -ne 0 ]; then
echo " * Non-matching line:" 1>&2
echo "${line}" 1>&2
grep_failed=1