summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clang-plugin/assertion-extracter.cpp57
-rw-r--r--clang-plugin/gassert-attributes.cpp11
-rw-r--r--clang-plugin/gerror-checker.cpp17
-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/gvariant-checker.cpp6
-rw-r--r--clang-plugin/plugin.cpp4
-rw-r--r--meson.build4
9 files changed, 72 insertions, 72 deletions
diff --git a/clang-plugin/assertion-extracter.cpp b/clang-plugin/assertion-extracter.cpp
index 9b64bfd..1e1a77d 100644
--- a/clang-plugin/assertion-extracter.cpp
+++ b/clang-plugin/assertion-extracter.cpp
@@ -67,33 +67,31 @@ _is_assertion_fail_func_name (const std::string& name)
static Expr*
_negation_expr (Expr* e, const ASTContext& context)
{
- return new (context)
- UnaryOperator (e, UnaryOperatorKind::UO_LNot,
- context.getLogicalOperationType (),
- VK_RValue, OK_Ordinary, SourceLocation (),
- /* can_overflow = */ false);
+ return UnaryOperator::Create (context, e, UnaryOperatorKind::UO_LNot,
+ context.getLogicalOperationType (),
+ VK_PRValue, OK_Ordinary, SourceLocation (),
+ /* can_overflow = */ false,
+ FPOptionsOverride());
}
/* Combine expressions A and B to give (A && B). */
static Expr*
_conjunction_expr (Expr* lhs, Expr* rhs, const ASTContext& context)
{
- return new (context)
- BinaryOperator (lhs, rhs, BinaryOperatorKind::BO_LAnd,
- context.getLogicalOperationType (),
- VK_RValue, OK_Ordinary, SourceLocation (),
- FPOptions ());
+ return BinaryOperator::Create (context, lhs, rhs, BinaryOperatorKind::BO_LAnd,
+ context.getLogicalOperationType (),
+ VK_PRValue, OK_Ordinary, SourceLocation (),
+ FPOptionsOverride ());
}
/* Combine expressions A and B to give (A || B). */
static Expr*
_disjunction_expr (Expr* lhs, Expr* rhs, const ASTContext& context)
{
- return new (context)
- BinaryOperator (lhs, rhs, BinaryOperatorKind::BO_LOr,
- context.getLogicalOperationType (),
- VK_RValue, OK_Ordinary, SourceLocation (),
- FPOptions ());
+ return BinaryOperator::Create (context, lhs, rhs, BinaryOperatorKind::BO_LOr,
+ context.getLogicalOperationType (),
+ VK_PRValue, OK_Ordinary, SourceLocation (),
+ FPOptionsOverride ());
}
/* Does the given statement look like:
@@ -189,12 +187,12 @@ AssertionExtracter::is_assertion_stmt (Stmt& stmt, const ASTContext& context)
Stmt* body = do_stmt.getBody ();
Stmt* cond = do_stmt.getCond ();
Expr* expr = dyn_cast<Expr> (cond);
- llvm::APSInt bool_expr;
+ Optional<llvm::APSInt> bool_expr;
if (body != NULL &&
expr != NULL &&
- expr->isIntegerConstantExpr (bool_expr, context) &&
- !bool_expr.getBoolValue ()) {
+ (bool_expr = expr->getIntegerConstantExpr (context)) &&
+ !bool_expr->getBoolValue ()) {
return is_assertion_stmt (*body, context);
}
@@ -578,11 +576,10 @@ _simplify_boolean_expr (Expr* expr, const ASTContext& context)
BinaryOperatorKind::BO_NE :
BinaryOperatorKind::BO_EQ;
- return new (context)
- BinaryOperator (lhs, rhs, opcode,
- context.getLogicalOperationType (),
- VK_RValue, OK_Ordinary, SourceLocation (),
- FPOptions ());
+ return BinaryOperator::Create (context, lhs, rhs, opcode,
+ context.getLogicalOperationType (),
+ VK_PRValue, OK_Ordinary, SourceLocation (),
+ FPOptionsOverride ());
}
/* ! (S1 op S2) ↦ ! (simplify(S1) op simplify(S2)) */
@@ -608,17 +605,17 @@ _simplify_boolean_expr (Expr* expr, const ASTContext& context)
return expr;
}
- llvm::APSInt bool_expr;
+ Optional<llvm::APSInt> bool_expr;
- if (lhs->isIntegerConstantExpr (bool_expr, context)) {
- if (is_or && bool_expr.getBoolValue ()) {
+ if (bool_expr = lhs->getIntegerConstantExpr (context)) {
+ if (is_or && bool_expr->getBoolValue ()) {
/* 1 || S2 ↦ 1 */
return new (context)
IntegerLiteral (context,
context.MakeIntValue (1, context.getLogicalOperationType ()),
context.getLogicalOperationType (),
SourceLocation ());
- } else if (is_and && !bool_expr.getBoolValue ()) {
+ } else if (is_and && !bool_expr->getBoolValue ()) {
/* 0 && S2 ↦ 0 */
return new (context)
IntegerLiteral (context,
@@ -631,15 +628,15 @@ _simplify_boolean_expr (Expr* expr, const ASTContext& context)
* 0 || S2 ↦ simplify(S2) */
return rhs;
}
- } else if (rhs->isIntegerConstantExpr (bool_expr, context)) {
- if (is_or && bool_expr.getBoolValue ()) {
+ } else if (bool_expr = rhs->getIntegerConstantExpr (context)) {
+ if (is_or && bool_expr->getBoolValue ()) {
/* S1 || 1 ↦ 1 */
return new (context)
IntegerLiteral (context,
context.MakeIntValue (1, context.getLogicalOperationType ()),
context.getLogicalOperationType (),
SourceLocation ());
- } else if (is_and && !bool_expr.getBoolValue ()) {
+ } else if (is_and && !bool_expr->getBoolValue ()) {
/* S2 && 0 ↦ 0 */
return new (context)
IntegerLiteral (context,
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..46960b5 100644
--- a/clang-plugin/gerror-checker.cpp
+++ b/clang-plugin/gerror-checker.cpp
@@ -78,6 +78,7 @@
#include <clang/StaticAnalyzer/Core/Checker.h>
#include <clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h>
#include <clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h>
+#include <clang/StaticAnalyzer/Core/PathSensitive/DynamicExtent.h>
#include "gerror-checker.h"
#include "type-manager.h"
@@ -704,7 +705,7 @@ GErrorChecker::_gerror_new (const Expr *call_expr,
assert (this->_initialise_identifiers (ast_context));
DefinedOrUnknownSVal extent =
- symbolic_allocated_region->getExtent (sval_builder);
+ getDynamicExtent (state, symbolic_allocated_region, sval_builder);
const uint64_t _gerror_size =
ast_context.getTypeSize (this->_gerror_type);
DefinedOrUnknownSVal gerror_size =
@@ -778,7 +779,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 +804,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 +833,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 +845,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 +926,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 +961,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 +974,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/gvariant-checker.cpp b/clang-plugin/gvariant-checker.cpp
index 1557235..2518fd5 100644
--- a/clang-plugin/gvariant-checker.cpp
+++ b/clang-plugin/gvariant-checker.cpp
@@ -341,11 +341,9 @@ _consume_variadic_argument (QualType expected_type,
Expr::NPC_ValueDependentIsNull);
/* Check for int → uint promotions. */
- llvm::APSInt int_constant_value;
- bool is_int_constant = arg->isIntegerConstantExpr (int_constant_value,
- context);
+ Optional<llvm::APSInt> int_constant_value = arg->getIntegerConstantExpr (context);
- if (is_int_constant && int_constant_value.isNonNegative () &&
+ if (int_constant_value && int_constant_value->isNonNegative () &&
expected_type->isUnsignedIntegerType () &&
actual_type->hasSignedIntegerRepresentation ()) {
/* Magically promote the int to a uint. */
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..aa19d1d 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 = '>= 13.0'
glib_requirement = '>= 2.38'
gir_requirement = '>= 1.38.0'