summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2022-05-16 23:34:45 +0200
committerJan Tojnar <jtojnar@gmail.com>2022-05-17 05:35:22 +0200
commitef32f6b1e85aa10df4dc56b487085f5b3eee0cac (patch)
tree07c3fb03ad42c707a71aa61516c67e606d452720
parentbd4ea95d8b3ce1258491e9fac7fcc37d2b241a16 (diff)
Update for LLVM 10
- It switched to C++14 In file included from /nix/store/ida6b9zgxsw5xa7z8s1y0n42z60lzw2q-llvm-11.1.0-dev/include/llvm/ADT/APInt.h:19, from /nix/store/ida6b9zgxsw5xa7z8s1y0n42z60lzw2q-llvm-11.1.0-dev/include/llvm/ADT/APSInt.h:17, from /nix/store/w9pancs07lxapsnv8llwkzx73xc1x29l-clang-11.1.0-dev/include/clang/Basic/FixedPoint.h:19, from /nix/store/w9pancs07lxapsnv8llwkzx73xc1x29l-clang-11.1.0-dev/include/clang/AST/APValue.h:16, from /nix/store/w9pancs07lxapsnv8llwkzx73xc1x29l-clang-11.1.0-dev/include/clang/AST/Expr.h:16, from /build/tartan/build/meson-private/tmp46ad89j3/testfile.cpp:2: /nix/store/ida6b9zgxsw5xa7z8s1y0n42z60lzw2q-llvm-11.1.0-dev/include/llvm/Support/MathExtras.h:396:23: error: 'enable_if_t' in namespace 'std' does not name a template type 396 | constexpr inline std::enable_if_t<(N < 64), bool> isUInt(uint64_t X) { | ^~~~~~~~~~~ /nix/store/ida6b9zgxsw5xa7z8s1y0n42z60lzw2q-llvm-11.1.0-dev/include/llvm/Support/MathExtras.h:396:18: note: 'std::enable_if_t' is only available from C++14 onwards - It uses std::make_unique https://reviews.llvm.org/D66259 ../clang-plugin/plugin.cpp:123:30: error: 'make_unique' is not a member of 'llvm'; did you mean 'std::make_unique'? 123 | return llvm::make_unique<MultiplexConsumer> (std::move (consumers)); | ^~~~~~~~~~~ - CheckName type was renamed: https://github.com/llvm/llvm-project/commit/72649423c043341c770516cd73aecde281730260 ../clang-plugin/gerror-checker.h:58:17: error: 'CheckName' does not name a type 58 | CheckName check_name_overwrite_set; | ^~~~~~~~~ - ASTContext::getConstantArrayType takes an extra argument: https://github.com/llvm/llvm-project/commit/772e266fbff40a566c9ef2d805c057c4692ac028 ../clang-plugin/gsignal-checker.cpp:346:61: error: no matching function for call to 'clang::ASTContext::getConstantArrayType(clang::QualType&, llvm::APInt, clang::ArrayType::ArraySizeModifier, int) const' 346 | return context.getConstantArrayType (element_type, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~ 347 | llvm::APInt (32, fixed_size), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 348 | ArrayType::ArraySizeModifier::Static, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 349 | 0); - BugReport was renamed to BasicBugReport https://github.com/llvm/llvm-project/commit/2f169e7cdd9973d2aa4cba6b0a09126a5e7268ec ../clang-plugin/gerror-checker.cpp:781:40: required from here /nix/store/i633yj06994wbb89b88nm5kb4pbm8h4r-gcc-11.3.0/include/c++/11.3.0/bits/unique_ptr.h:962:30: error: invalid new-expression of abstract class type 'clang::ento::BugReport' 962 | { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); } | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Constructors for attributes changed: https://github.com/llvm/llvm-project/commit/6a24e8068052cd6b48295959ec4c44eb2ef819c5 ../clang-plugin/gir-attributes.cpp:297:73: error: no matching function for call to 'clang::WarnUnusedAttr::WarnUnusedAttr(clang::SourceRange, clang::ASTContext&, int)' 297 | func.getASTContext (), 0); | ^ Using the `Create` method instead of the previos dump since it will set the 0 `spellingListIndex` for us automatically when needed.
-rw-r--r--clang-plugin/gassert-attributes.cpp11
-rw-r--r--clang-plugin/gerror-checker.cpp14
-rw-r--r--clang-plugin/gerror-checker.h12
-rw-r--r--clang-plugin/gir-attributes.cpp32
-rw-r--r--clang-plugin/gsignal-checker.cpp1
-rw-r--r--clang-plugin/plugin.cpp4
-rw-r--r--meson.build4
7 files changed, 41 insertions, 37 deletions
diff --git a/clang-plugin/gassert-attributes.cpp b/clang-plugin/gassert-attributes.cpp
index 362a120..bb67c56 100644
--- a/clang-plugin/gassert-attributes.cpp
+++ b/clang-plugin/gassert-attributes.cpp
@@ -97,11 +97,12 @@ _handle_assertion (FunctionDecl& func, Expr& assertion_expr,
}
if (non_null_args.size () > 0) {
- nonnull_attr = ::new (func.getASTContext ())
- NonNullAttr (func.getSourceRange (),
- func.getASTContext (),
- non_null_args.data (),
- non_null_args.size (), 0);
+ AttributeCommonInfo info (func.getSourceRange ());
+ nonnull_attr =
+ NonNullAttr::Create (func.getASTContext (),
+ non_null_args.data (),
+ non_null_args.size (),
+ info);
func.addAttr (nonnull_attr);
}
}
diff --git a/clang-plugin/gerror-checker.cpp b/clang-plugin/gerror-checker.cpp
index 0717eff..3a75b6d 100644
--- a/clang-plugin/gerror-checker.cpp
+++ b/clang-plugin/gerror-checker.cpp
@@ -778,7 +778,7 @@ GErrorChecker::_assert_gerror_set (SVal error_location,
ExplodedNode *error_node = context.generateErrorNode (state);
this->_initialise_bug_reports ();
- auto R = llvm::make_unique<BugReport> (*this->_use_uninitialised,
+ auto R = std::make_unique<PathSensitiveBugReport> (*this->_use_uninitialised,
"Using uninitialized GError",
error_node);
#if 0
@@ -803,7 +803,7 @@ GErrorChecker::_assert_gerror_set (SVal error_location,
ExplodedNode *error_node = context.generateErrorNode (state);
this->_initialise_bug_reports ();
- auto R = llvm::make_unique<BugReport> (*this->_free_cleared,
+ auto R = std::make_unique<PathSensitiveBugReport> (*this->_free_cleared,
"Freeing non-set GError",
error_node);
#if 0
@@ -832,7 +832,7 @@ GErrorChecker::_assert_gerror_set (SVal error_location,
ExplodedNode *error_node = context.generateErrorNode (state);
this->_initialise_bug_reports ();
- auto R = llvm::make_unique<BugReport> (*this->_double_free,
+ auto R = std::make_unique<PathSensitiveBugReport> (*this->_double_free,
"Freeing already-freed GError",
error_node);
R->addRange (source_range);
@@ -844,7 +844,7 @@ GErrorChecker::_assert_gerror_set (SVal error_location,
ExplodedNode *error_node = context.generateErrorNode (state);
this->_initialise_bug_reports ();
- auto R = llvm::make_unique<BugReport> (*this->_free_cleared,
+ auto R = std::make_unique<PathSensitiveBugReport> (*this->_free_cleared,
"Freeing non-set GError",
error_node);
R->addRange (source_range);
@@ -925,7 +925,7 @@ GErrorChecker::_assert_gerror_unset (SVal error_location,
ExplodedNode *error_node = context.generateErrorNode (state);
this->_initialise_bug_reports ();
- auto R = llvm::make_unique<BugReport> (*this->_use_uninitialised,
+ auto R = std::make_unique<PathSensitiveBugReport> (*this->_use_uninitialised,
"Using uninitialized GError",
error_node);
#if 0
@@ -960,7 +960,7 @@ GErrorChecker::_assert_gerror_unset (SVal error_location,
ExplodedNode *error_node = context.generateErrorNode (state);
this->_initialise_bug_reports ();
- auto R = llvm::make_unique<BugReport> (*this->_overwrite_set,
+ auto R = std::make_unique<PathSensitiveBugReport> (*this->_overwrite_set,
"Overwriting already-set GError",
error_node);
R->addRange (source_range);
@@ -973,7 +973,7 @@ GErrorChecker::_assert_gerror_unset (SVal error_location,
ExplodedNode *error_node = context.generateErrorNode (state);
this->_initialise_bug_reports ();
- auto R = llvm::make_unique<BugReport> (*this->_overwrite_freed,
+ auto R = std::make_unique<PathSensitiveBugReport> (*this->_overwrite_freed,
"Overwriting already-freed GError",
error_node);
R->addRange (source_range);
diff --git a/clang-plugin/gerror-checker.h b/clang-plugin/gerror-checker.h
index 1d7ce80..9284535 100644
--- a/clang-plugin/gerror-checker.h
+++ b/clang-plugin/gerror-checker.h
@@ -55,12 +55,12 @@ public:
DefaultBool check_use_uninitialised;
DefaultBool check_memory_leak;
- CheckName check_name_overwrite_set;
- CheckName check_name_overwrite_freed;
- CheckName check_name_double_free;
- CheckName check_name_free_cleared;
- CheckName check_name_use_uninitialised;
- CheckName check_name_memory_leak;
+ CheckerNameRef check_name_overwrite_set;
+ CheckerNameRef check_name_overwrite_freed;
+ CheckerNameRef check_name_double_free;
+ CheckerNameRef check_name_free_cleared;
+ CheckerNameRef check_name_use_uninitialised;
+ CheckerNameRef check_name_memory_leak;
};
GErrorChecksFilter filter;
diff --git a/clang-plugin/gir-attributes.cpp b/clang-plugin/gir-attributes.cpp
index 49dd9ae..6cef7f6 100644
--- a/clang-plugin/gir-attributes.cpp
+++ b/clang-plugin/gir-attributes.cpp
@@ -271,11 +271,12 @@ GirAttributesConsumer::_handle_function_decl (FunctionDecl& func)
if (non_null_args.size () > 0 &&
!_ignore_glib_internal_func (func_name)) {
- nonnull_attr = ::new (func.getASTContext ())
- NonNullAttr (func.getSourceRange (),
- func.getASTContext (),
- non_null_args.data (),
- non_null_args.size (), 0);
+ AttributeCommonInfo info (func.getSourceRange ());
+ nonnull_attr =
+ NonNullAttr::Create (func.getASTContext (),
+ non_null_args.data (),
+ non_null_args.size (),
+ info);
func.addAttr (nonnull_attr);
}
@@ -291,10 +292,10 @@ GirAttributesConsumer::_handle_function_decl (FunctionDecl& func)
return_type_tag = g_type_info_get_tag (&return_type_info);
if (return_transfer != GI_TRANSFER_NOTHING) {
+ AttributeCommonInfo info (func.getSourceRange ());
WarnUnusedAttr* warn_unused_attr =
- ::new (func.getASTContext ())
- WarnUnusedAttr (func.getSourceRange (),
- func.getASTContext (), 0);
+ WarnUnusedAttr::Create (func.getASTContext (),
+ info);
func.addAttr (warn_unused_attr);
} else if (_type_should_be_const (return_transfer,
return_type_tag)) {
@@ -306,11 +307,12 @@ 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> ()) {
+ AttributeCommonInfo info (func.getSourceRange ());
DeprecatedAttr* deprecated_attr =
- ::new (func.getASTContext ())
- DeprecatedAttr (func.getSourceRange (),
- func.getASTContext (),
- 0);
+ DeprecatedAttr::Create (func.getASTContext (),
+ /* Message = */ "",
+ /* Replacement = */ "",
+ info);
func.addAttr (deprecated_attr);
}
@@ -319,10 +321,10 @@ GirAttributesConsumer::_handle_function_decl (FunctionDecl& func)
if (g_function_info_get_flags (info) &
GI_FUNCTION_IS_CONSTRUCTOR &&
!func.hasAttr<RestrictAttr> ()) {
+ AttributeCommonInfo info (func.getSourceRange ());
+ info.setAttributeSpellingListIndex (RestrictAttr::Declspec_restrict);
RestrictAttr* malloc_attr =
- ::new (func.getASTContext ())
- RestrictAttr (func.getSourceRange (),
- func.getASTContext (), 0);
+ RestrictAttr::Create (func.getASTContext (), info);
func.addAttr (malloc_attr);
}
diff --git a/clang-plugin/gsignal-checker.cpp b/clang-plugin/gsignal-checker.cpp
index 60f1f57..041e14b 100644
--- a/clang-plugin/gsignal-checker.cpp
+++ b/clang-plugin/gsignal-checker.cpp
@@ -345,6 +345,7 @@ _type_array_info_to_type (GITypeInfo *array_info,
if (fixed_size > -1) {
return context.getConstantArrayType (element_type,
llvm::APInt (32, fixed_size),
+ nullptr,
ArrayType::ArraySizeModifier::Static,
0);
} else {
diff --git a/clang-plugin/plugin.cpp b/clang-plugin/plugin.cpp
index 8a9ced1..9d0a697 100644
--- a/clang-plugin/plugin.cpp
+++ b/clang-plugin/plugin.cpp
@@ -91,7 +91,7 @@ protected:
"syntax-only or analysis modes.");
d.Report (id);
- return llvm::make_unique<ASTConsumer> ();
+ return std::make_unique<ASTConsumer> ();
}
std::vector<std::unique_ptr<ASTConsumer>> consumers;
@@ -120,7 +120,7 @@ protected:
global_gir_manager,
this->_disabled_checkers)));
- return llvm::make_unique<MultiplexConsumer> (std::move (consumers));
+ return std::make_unique<MultiplexConsumer> (std::move (consumers));
}
private:
diff --git a/meson.build b/meson.build
index 51b44f7..4d5d864 100644
--- a/meson.build
+++ b/meson.build
@@ -1,12 +1,12 @@
project('tartan', 'cpp', version: '0.4.0', license: 'GPL3',
meson_version: '>= 0.52',
- default_options: ['cpp_std=c++11', 'warning_level=3'])
+ default_options: ['cpp_std=c++14', 'warning_level=3'])
cxx = meson.get_compiler('cpp')
### Check for required libraries ###############################################
-llvm_requirement = '>= 7.0'
+llvm_requirement = '>= 10.0'
glib_requirement = '>= 2.38'
gir_requirement = '>= 1.38.0'