Skip to content

Do not use c_qualifiers on goto-program expressions #2299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/analyses/does_remove_const.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <util/expr.h>
#include <util/std_code.h>
#include <util/base_type.h>
#include <ansi-c/c_qualifiers.h>

/// A naive analysis to look for casts that remove const-ness from pointers.
/// \param goto_program: the goto program to check
Expand Down Expand Up @@ -163,8 +162,6 @@ bool does_remove_constt::does_type_preserve_const_correctness(
bool does_remove_constt::is_type_at_least_as_const_as(
const typet &type_more_const, const typet &type_compare) const
{
const c_qualifierst type_compare_qualifiers(type_compare);
const c_qualifierst more_constant_qualifiers(type_more_const);
return !type_compare_qualifiers.is_constant ||
more_constant_qualifiers.is_constant;
return !type_compare.get_bool(ID_C_constant) ||
type_more_const.get_bool(ID_C_constant);
}
1 change: 0 additions & 1 deletion src/analyses/module_dependencies.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
analyses
ansi-c # should go away
goto-programs
langapi # should go away
pointer-analysis
Expand Down
16 changes: 4 additions & 12 deletions src/goto-programs/remove_const_function_pointers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Author: Thomas Kiley, [email protected]
#include <util/std_expr.h>
#include <util/symbol_table.h>

#include <ansi-c/c_qualifiers.h>

#include "goto_functions.h"

#define LOG(message, irep) \
Expand Down Expand Up @@ -786,16 +784,10 @@ bool remove_const_function_pointerst::is_const_expression(
/// arrays are implicitly const in C.
bool remove_const_function_pointerst::is_const_type(const typet &type) const
{
c_qualifierst qualifers(type);
if(type.id()==ID_array)
{
c_qualifierst array_type_qualifers(type.subtype());
return qualifers.is_constant || array_type_qualifers.is_constant;
}
else
{
return qualifers.is_constant;
}
if(type.id() == ID_array && type.subtype().get_bool(ID_C_constant))
return true;

return type.get_bool(ID_C_constant);
}

/// To extract the value of the specific component within a struct
Expand Down
2 changes: 1 addition & 1 deletion src/goto-programs/remove_function_pointers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Author: Daniel Kroening, [email protected]
#include <util/type_eq.h>
#include <util/message.h>
#include <util/base_type.h>
#include <ansi-c/c_qualifiers.h>

#include <analyses/does_remove_const.h>
#include <util/invariant.h>

Expand Down