Skip to content
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

cmake, docker, FactGenerator: iwyu #110

Closed
wants to merge 2 commits into from
Closed
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
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ endforeach()

# -----------------------------------------------------------------------------

find_program(IWYU NAMES include-what-you-use iwyu REQUIRED)
set_property(TARGET factgen-exe PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU})

# -----------------------------------------------------------------------------

if(NOT (DEFINED CLANG_VERSION))
set(CLANG_VERSION ${LLVM_MAJOR_VERSION})
endif()
Expand Down
66 changes: 42 additions & 24 deletions FactGenerator/include/FactGenerator.hpp
Original file line number Diff line number Diff line change
@@ -1,32 +1,50 @@
#ifndef CSV_GENERATOR_H__
#define CSV_GENERATOR_H__

#include <llvm/IR/Constants.h>
#include <llvm/IR/DataLayout.h>
#include <llvm/IR/GlobalValue.h>
#include <llvm/IR/GlobalVariable.h>
#include <llvm/IR/InlineAsm.h>
#include <llvm/IR/Type.h>
#include <llvm/IR/Value.h>
#include <llvm/Support/raw_ostream.h>

#include <boost/flyweight.hpp>
#include <boost/unordered_map.hpp>
#include <boost/unordered_set.hpp>
#include <set>
#include <string>

#include "ContextSensitivity.hpp"
#include "Demangler.hpp"
#include "FactWriter.hpp"
#include "ForwardingFactWriter.hpp"
#include "RefmodeEngine.hpp"
#include "Signatures.hpp"
#include "predicate_groups.hpp"

#include <llvm/ADT/Optional.h> // for Optional
#include <llvm/Support/JSON.h> // IWYU pragma: keep

#include <boost/container_hash/extensions.hpp> // for hash
#include <boost/filesystem/path.hpp> // for path
#include <boost/flyweight/flyweight.hpp> // for flyweight
#include <boost/unordered/unordered_map.hpp> // for unordered_map
#include <boost/unordered/unordered_set.hpp> // for unordered_set
#include <map> // for map
#include <regex> // for regex
#include <string> // for string, basic_string
#include <tuple> // for tuple
#include <vector> // for vector

#include "ContextSensitivity.hpp" // for ContextSensitivity
#include "Demangler.hpp" // for Demangler
#include "ForwardingFactWriter.hpp" // for ForwardingFactWriter
#include "RefmodeEngine.hpp" // for refmode_t, RefmodeEngine
#include "predicate_groups.hpp" // for pred_t

// Forward declarations
namespace cclyzer {
class FactGenerator;
class FactWriter;
}
namespace llvm {
class Constant;
class ConstantArray;
class ConstantExpr;
class ConstantStruct;
class ConstantVector;
class DataLayout;
class Function;
class GlobalAlias;
class GlobalVariable;
class InlineAsm;
class Module;
class NamedMDNode;
class Type;
class Value;
} // namespace llvm

namespace cclyzer {
class FactGenerator; // IWYU pragma: keep
} // namespace cclyzer

class cclyzer::FactGenerator : private RefmodeEngine,
private Demangler,
Expand Down
15 changes: 8 additions & 7 deletions FactGenerator/include/FactWriter.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#ifndef FACT_WRITER_H__
#define FACT_WRITER_H__

#include <boost/filesystem.hpp>
#include <boost/unordered_map.hpp>
#include <string>
// IWYU pragma: no_include "boost/unordered/detail/implementation.hpp"
#include <boost/filesystem/path.hpp> // for path
#include <boost/unordered/unordered_map.hpp> // for unordered_map
#include <string> // for string

#include "RefmodeEngine.hpp" // TODO replace
#include "csv_writer.hpp"
#include "predicate.hpp"
#include "RefmodeEngine.hpp" // for refmode_t
#include "csv_writer.hpp" // for csv_writer
#include "predicate.hpp" // for Predicate

namespace cclyzer {
class FactWriter;
class FactWriter; // IWYU pragma: keep
}

class cclyzer::FactWriter {
Expand Down
30 changes: 19 additions & 11 deletions FactGenerator/include/InstructionVisitor.hpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
#ifndef INSTR_VISITOR_H__
#define INSTR_VISITOR_H__

#include <llvm/IR/InstVisitor.h>

#include <string>

#include "FactGenerator.hpp"
#include "RefmodeEngine.hpp"

// Add to namespace
namespace cclyzer {
class InstructionVisitor;
}
#include <llvm/IR/InstVisitor.h> // for InstVisitor
#include <llvm/IR/InstrTypes.h> // for CastInst, BinaryOperator
#include <llvm/IR/Instructions.h> // for AllocaInst (ptr only), Atom...
#include <llvm/IR/LLVMContext.h> // for SingleThread
#include <llvm/Support/AtomicOrdering.h> // for AtomicOrdering
#include <llvm/Support/ErrorHandling.h> // for llvm

#include "FactGenerator.hpp" // for FactGenerator
#include "RefmodeEngine.hpp" // for refmode_t
#include "predicate_groups.hpp" // for instr, instr::flag

// Forward declares
namespace llvm {
class DbgDeclareInst;
class Instruction;
class Module;
class User;
class Value;
} // namespace llvm

// Processor of instructions
class cclyzer::InstructionVisitor
Expand Down
12 changes: 7 additions & 5 deletions FactGenerator/include/Options.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#ifndef OPTIONS_HPP__
#define OPTIONS_HPP__

#include <llvm/ADT/Optional.h>
#include <llvm/ADT/Optional.h> // for Optional

#include <boost/filesystem.hpp>
#include <string>
#include <algorithm> // for max
#include <boost/filesystem/path.hpp> // for path
#include <string> // for string
#include <vector> // for vector

#include "ContextSensitivity.hpp"
#include "ContextSensitivity.hpp" // for ContextSensitivity

namespace cclyzer {
class Options;
class Options; // IWYU pragma: keep
}

class cclyzer::Options {
Expand Down
22 changes: 12 additions & 10 deletions FactGenerator/include/RefmodeEngine.hpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#ifndef REFMODE_ENGINE_HPP__
#define REFMODE_ENGINE_HPP__

#include <llvm/IR/CallingConv.h>
#include <llvm/IR/Function.h>
#include <llvm/IR/GlobalValue.h>
#include <llvm/IR/GlobalVariable.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/Type.h>
#include <llvm/IR/Value.h>

#include <boost/flyweight.hpp>
#include <llvm/IR/CallingConv.h> // IWYU pragma: keep
#include <llvm/IR/GlobalValue.h> // IWYU pragma: keep
#include <llvm/IR/GlobalVariable.h> // IWYU pragma: keep
#include <llvm/IR/Instructions.h> // IWYU pragma: keep

#include <boost/flyweight.hpp> // IWYU pragma: keep
#include <string>

namespace llvm {
class Function;
class Module;
class Value;
} // namespace llvm

namespace cclyzer {

namespace refmode {
Expand Down
14 changes: 9 additions & 5 deletions FactGenerator/include/TypeAccumulator.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
#ifndef TYPE_ACCUMULATOR_HPP__
#define TYPE_ACCUMULATOR_HPP__

#include <llvm/IR/DerivedTypes.h>
#include <llvm/IR/Type.h>
#include <llvm/Support/raw_ostream.h>
#include <llvm/Config/llvm-config.h> // for LLVM_VERSION_MAJOR
#include <llvm/IR/DerivedTypes.h> // for StructType, FunctionType
#include <llvm/IR/Type.h> // for Type
#include <llvm/Support/Casting.h> // for cast, dyn_cast
#include <llvm/Support/raw_ostream.h> // for errs, raw_fd_ostream
#include <stddef.h> // for size_t

#include <boost/unordered_set.hpp>
#include <boost/container_hash/extensions.hpp> // for hash
#include <boost/unordered/unordered_set.hpp> // for unordered_set

namespace cclyzer::llvm_utils {
class TypeAccumulator;
class TypeAccumulator; // IWYU pragma: keep
} // namespace cclyzer::llvm_utils

class cclyzer::llvm_utils::TypeAccumulator {
Expand Down
13 changes: 10 additions & 3 deletions FactGenerator/include/TypeVisitor.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#include <llvm/IR/DataLayout.h>
#include <llvm/IR/DerivedTypes.h>
#include <llvm/IR/Type.h>
// Forward decls
namespace llvm {
class ArrayType;
class DataLayout;
class FunctionType;
class PointerType;
class StructType;
class Type;
class VectorType;
} // namespace llvm

namespace cclyzer {
// Forward declaration
Expand Down
10 changes: 5 additions & 5 deletions FactGenerator/include/llvm_enums.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#ifndef LLVM_ENUMS_HPP__
#define LLVM_ENUMS_HPP__

#include <llvm/IR/CallingConv.h>
#include <llvm/IR/GlobalValue.h>
#include <llvm/IR/GlobalVariable.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/CallingConv.h> // for ID
#include <llvm/IR/GlobalValue.h> // for GlobalValue, GlobalValue::L...
#include <llvm/IR/GlobalVariable.h> // for GlobalVariable
#include <llvm/Support/AtomicOrdering.h> // for AtomicOrdering

#include <string>
#include <string> // for string

namespace cclyzer::utils {
// Functions that convert the various LLVM enums to strings
Expand Down
4 changes: 1 addition & 3 deletions FactGenerator/include/predicate.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#ifndef PREDICATE_H__
#define PREDICATE_H__

#include <memory>
#include <iosfwd>
#include <set>
#include <string>
#include <utility>

#include "Singleton.hpp"

namespace cclyzer {
/* Forward declarations to be able to define actual registries */
class Predicate;
Expand Down
48 changes: 36 additions & 12 deletions FactGenerator/src/FactGenerator.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,41 @@
#include "FactGenerator.hpp"

#include <llvm/IR/CFG.h>
#include <llvm/IR/Constants.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/Operator.h>

#include <regex>
#include <string>

#include "ContextSensitivity.hpp"
#include "InstructionVisitor.hpp"
#include "Signatures.hpp"
#include "predicate_groups.hpp"
#include <llvm/ADT/SmallVector.h> // for SmallVector, SmallVectorTemplat...
#include <llvm/ADT/StringRef.h> // for StringRef
#include <llvm/ADT/ilist_iterator.h> // for operator!=, ilist_iterator
#include <llvm/IR/BasicBlock.h> // for BasicBlock
#include <llvm/IR/CFG.h> // for const_pred_iterator, pred_begin
#include <llvm/IR/DebugLoc.h> // for DebugLoc
#include <llvm/IR/Function.h> // for Function
#include <llvm/IR/GlobalAlias.h> // for GlobalAlias
#include <llvm/IR/GlobalVariable.h> // for GlobalVariable
#include <llvm/IR/Instruction.h> // for Instruction
#include <llvm/IR/Metadata.h> // for MDNode (ptr only), NamedMDNode
#include <llvm/IR/Module.h> // for Module, Module::const_alias_ite...
#include <llvm/IR/Type.h> // for Type
#include <llvm/Support/Casting.h> // for cast, isa
#include <llvm/Support/JSON.h> // for Array
#include <stddef.h> // for size_t

#include <RefmodeEngine.hpp> // for refmode_t
#include <boost/operators.hpp> // for operator++
#include <regex> // for regex, regex_search, match_resu...
#include <string> // for string, operator==, basic_string
#include <utility> // for pair

#include "ContextSensitivity.hpp" // for context_sensitivity_to_string
#include "InstructionVisitor.hpp" // for InstructionVisitor
#include "Signatures.hpp" // for emit_signatures, preprocess_sig...
#include "predicate_groups.hpp" // for instr, variable, block, block::...

// Forward declarations
namespace cclyzer {
class FactWriter;
}
namespace llvm {
class GlobalValue;
class Value;
} // namespace llvm

using cclyzer::FactGenerator;
using llvm::cast;
Expand Down
6 changes: 6 additions & 0 deletions FactGenerator/src/FactWriter.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
// IWYU pragma: no_include <boost/unordered/detail/implementation.hpp>
#include "FactWriter.hpp"

#include <algorithm>
#include <boost/filesystem/operations.hpp> // for create_directory
#include <boost/filesystem/path_traits.hpp> // for filesystem
#include <map> // for operator!=, _Rb...
#include <utility> // for move

#include "csv_writer.hpp" // for csv_writer
#include "predicate_groups.hpp"

namespace fs = boost::filesystem;
Expand Down
38 changes: 31 additions & 7 deletions FactGenerator/src/InstructionVisitor.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,36 @@
#include "InstructionVisitor.hpp"

#include <llvm/IR/DebugInfo.h>
#include <llvm/IR/Operator.h>

#include <cassert>
#include <string>

#include "predicate_groups.hpp"
#include <llvm/ADT/APInt.h> // for APInt
#include <llvm/ADT/SmallString.h> // for SmallString
#include <llvm/ADT/StringRef.h> // for StringRef
#include <llvm/ADT/iterator.h> // for iterator_facade_base
#include <llvm/ADT/iterator_range.h> // for iterator_range
#include <llvm/Config/llvm-config.h> // for LLVM_VERSION_MAJOR
#include <llvm/IR/BasicBlock.h> // for BasicBlock
#include <llvm/IR/CallingConv.h> // for C
#include <llvm/IR/Constant.h> // for Constant
#include <llvm/IR/Constants.h> // for UndefValue, ConstantInt
#include <llvm/IR/DebugInfoMetadata.h> // for DILocalVariable
#include <llvm/IR/DebugLoc.h> // for DebugLoc
#include <llvm/IR/Instruction.h> // for Instruction
#include <llvm/IR/IntrinsicInst.h> // for DbgDeclareInst
#include <llvm/IR/Operator.h> // for FPMathOperator, OverflowingBi...
#include <llvm/IR/User.h> // for User
#include <llvm/IR/Value.h> // for Value
#include <llvm/Support/Casting.h> // for dyn_cast, isa
#include <llvm/Support/raw_ostream.h> // for errs, raw_ostream, raw_fd_ost...

#include <FactGenerator.hpp> // for FactGenerator
#include <RefmodeEngine.hpp> // for refmode_t
#include <string> // for string, basic_string

#include "predicate_groups.hpp" // for instr, instr::flag, br, cmpxchg
namespace llvm {
class InlineAsm;
}
namespace llvm {
class Type;
}

namespace pred = cclyzer::predicates;

Expand Down
Loading