Skip to content

Commit

Permalink
datalog: Implement import*.dl via include
Browse files Browse the repository at this point in the history
Now the FactGenerator and Datalog code have the same source of truth about
relation and file names.
  • Loading branch information
langston-barrett committed Oct 6, 2022
1 parent 2010dcf commit c4ebcca
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 379 deletions.
20 changes: 10 additions & 10 deletions FactGenerator/include/predicates.inc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#endif

GROUP_BEGIN(basic_block)
PREDICATE(basic_block, predecessor, basicblock_preds)
PREDICATE(basic_block, predecessor, _basicblock_preds)
GROUP_END(basic_block)

GROUP_BEGIN(global_var)
Expand Down Expand Up @@ -61,7 +61,7 @@ GROUP_BEGIN(instruction)
PREDICATE(instruction, to, instruction_assigns_to)
PREDICATE(instruction, flag, instruction_has_flag)
PREDICATE(instruction, next, next_instruction)
PREDICATE(instruction, bb_entry, instruction_bb_entry)
PREDICATE(instruction, bb_entry, _instruction_bb_entry)
PREDICATE(instruction, function, instruction_in_function)
PREDICATE(instruction, pos, instruction_pos)
PREDICATE(instruction, unreachable, unreachable_instruction)
Expand Down Expand Up @@ -199,8 +199,8 @@ GROUP_BEGIN(switch_)
PREDICATE(switch_, instr, switch_instruction)
PREDICATE(switch_, operand, switch_instruction_operand)
PREDICATE(switch_, default_label, switch_instruction_default_label)
PREDICATE(switch_, case_value, switch_instruction_case_value)
PREDICATE(switch_, case_label, switch_instruction_case_label)
PREDICATE(switch_, case_value, _switch_instruction_case_value)
PREDICATE(switch_, case_label, _switch_instruction_case_label)
PREDICATE(switch_, ncases, switch_instruction_ncases)
GROUP_END(switch_)

Expand Down Expand Up @@ -420,8 +420,8 @@ GROUP_END(fcmp)
GROUP_BEGIN(phi)
PREDICATE(phi, instr, phi_instruction)
PREDICATE(phi, type, phi_instruction_type)
PREDICATE(phi, pair_value, phi_instruction_pair_value)
PREDICATE(phi, pair_label, phi_instruction_pair_label)
PREDICATE(phi, pair_value, _phi_instruction_pair_value)
PREDICATE(phi, pair_label, _phi_instruction_pair_label)
PREDICATE(phi, npairs, phi_instruction_npairs)
GROUP_END(phi)

Expand Down Expand Up @@ -454,8 +454,8 @@ GROUP_END(call)
GROUP_BEGIN(landingpad)
PREDICATE(landingpad, instr, landingpad_instruction)
PREDICATE(landingpad, type, landingpad_instruction_type)
PREDICATE(landingpad, catch_clause, landingpad_instruction_catch_clause)
PREDICATE(landingpad, filter_clause, landingpad_instruction_filter_clause)
PREDICATE(landingpad, catch_clause, _landingpad_instruction_catch_clause)
PREDICATE(landingpad, filter_clause, _landingpad_instruction_filter_clause)
PREDICATE(landingpad, nclauses, landingpad_instruction_nclauses)
PREDICATE(landingpad, cleanup, landingpad_instruction_is_cleanup)
GROUP_END(landingpad)
Expand Down Expand Up @@ -522,15 +522,15 @@ PREDICATE(variable, id, variable)
PREDICATE(variable, type, variable_has_type)
PREDICATE(variable, source_name, variable_has_debug_source_name)
PREDICATE(variable, pos, variable_has_debug_decl_pos)
PREDICATE(variable, in_function, variable_in_fn)
PREDICATE(variable, in_function, _variable_in_function)
PREDICATE(variable, name, variable_has_name)
GROUP_END(variable)

GROUP_BEGIN(constant)
PREDICATE(constant, id, constant)
PREDICATE(constant, type, constant_has_type)
PREDICATE(constant, value, constant_has_value)
PREDICATE(constant, in_function, constant_in_fn)
PREDICATE(constant, in_function, _constant_in_function)
PREDICATE(constant, expr, constant_expression)
PREDICATE(constant, hash, constant_hashes_to)
PREDICATE(constant, to_integer, constant_to_int)
Expand Down
6 changes: 4 additions & 2 deletions FactGenerator/src/predicate_groups.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#include "predicate_groups.hpp"
using namespace cclyzer::predicates;

// GROUP_BEGIN, GROUP_END not needed
//
// Try: gcc -I include -E src/predicate_groups.cpp
//
// GROUP_BEGIN, GROUP_END not needed
#define GROUP_BEGIN(g)
#define GROUP_END(group_end)
// TODO(lb): Derive filename from group and predicate, e.g.,
// #define PREDICATE(g, p, f) pred_t g::p (std::string(#g) + std::string("_") +
// std::string(#p));
#define Q(x) #x
#define QUOTE(x) Q(x)
#define PREDICATE(g, p, f) pred_t g::p(#f);
#include "predicates.inc"
3 changes: 1 addition & 2 deletions datalog/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
set(DL_SOURCES
${CMAKE_CURRENT_LIST_DIR}/import/import-entities.dl
${CMAKE_CURRENT_LIST_DIR}/import/import-predicates.dl
${CMAKE_CURRENT_LIST_DIR}/import/import.dl
${CMAKE_CURRENT_LIST_DIR}/import/todo.dl
${CMAKE_CURRENT_LIST_DIR}/symbol-lookup/resolve-function-calls.dl
${CMAKE_CURRENT_LIST_DIR}/points-to/allocations-globals.dl
Expand Down
94 changes: 0 additions & 94 deletions datalog/import/import-entities.dl

This file was deleted.

Loading

0 comments on commit c4ebcca

Please sign in to comment.