namespace spvtools {
-// A message consumer that ignores all messages.
-inline void IgnoreMessage(spv_message_level_t, const char*,
- const spv_position_t&, const char*) {}
-
// A helper function to compose and return a string from the message in the
// following format:
// "<level>: <source>:<line>:<column>:<index>: <message>"
// The constructed instance will have an empty message consumer, which just
// ignores all messages from the library. Use SetMessageConsumer() to supply
// one if messages are of concern.
- Pass() : consumer_(IgnoreMessage) {}
+ Pass() : consumer_(nullptr) {}
// Returns a descriptive name for this pass.
virtual const char* name() const = 0;
// The constructed instance will have an empty message consumer, which just
// ignores all messages from the library. Use SetMessageConsumer() to supply
// one if messages are of concern.
- PassManager() : consumer_(IgnoreMessage) {}
+ PassManager() : consumer_(nullptr) {}
// Sets the message consumer to the given |consumer|.
void SetMessageConsumer(MessageConsumer c) { consumer_ = std::move(c); }
class PassTest : public TestT {
public:
PassTest()
- : consumer_(IgnoreMessage),
+ : consumer_(nullptr),
tools_(SPV_ENV_UNIVERSAL_1_1),
manager_(new opt::PassManager()) {}
assert(manager_->NumPasses());
std::unique_ptr<ir::Module> module =
- BuildModule(SPV_ENV_UNIVERSAL_1_1, IgnoreMessage, original);
+ BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, original);
ASSERT_NE(nullptr, module);
manager_->Run(module.get());
// Build module.
const std::vector<const char*> text = {tc.text};
std::unique_ptr<ir::Module> module =
- BuildModule(SPV_ENV_UNIVERSAL_1_1, IgnoreMessage, JoinAllInsts(text));
+ BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, JoinAllInsts(text));
ASSERT_NE(nullptr, module);
// Analyze def and use.
- opt::analysis::DefUseManager manager(IgnoreMessage, module.get());
+ opt::analysis::DefUseManager manager(nullptr, module.get());
CheckDef(tc.du, manager.id_to_defs());
CheckUse(tc.du, manager.id_to_uses());
// Build module.
const std::vector<const char*> text = {tc.before};
std::unique_ptr<ir::Module> module =
- BuildModule(SPV_ENV_UNIVERSAL_1_1, IgnoreMessage, JoinAllInsts(text));
+ BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, JoinAllInsts(text));
ASSERT_NE(nullptr, module);
// Analyze def and use.
- opt::analysis::DefUseManager manager(IgnoreMessage, module.get());
+ opt::analysis::DefUseManager manager(nullptr, module.get());
// Do the substitution.
for (const auto& candiate : tc.candidates) {
// Build module.
const std::vector<const char*> text = {tc.before};
std::unique_ptr<ir::Module> module =
- BuildModule(SPV_ENV_UNIVERSAL_1_1, IgnoreMessage, JoinAllInsts(text));
+ BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, JoinAllInsts(text));
ASSERT_NE(nullptr, module);
// Analyze def and use.
- opt::analysis::DefUseManager manager(IgnoreMessage, module.get());
+ opt::analysis::DefUseManager manager(nullptr, module.get());
// Do the substitution.
for (const auto id : tc.ids_to_kill) manager.KillDef(id);
" OpFunctionEnd";
std::unique_ptr<ir::Module> module =
- BuildModule(SPV_ENV_UNIVERSAL_1_1, IgnoreMessage, original_text);
+ BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, original_text);
ASSERT_NE(nullptr, module);
// Analyze def and use.
- opt::analysis::DefUseManager manager(IgnoreMessage, module.get());
+ opt::analysis::DefUseManager manager(nullptr, module.get());
// Do a bunch replacements.
manager.ReplaceAllUsesWith(9, 900); // to unused id
// Build module.
std::unique_ptr<ir::Module> module =
- BuildModule(SPV_ENV_UNIVERSAL_1_1, IgnoreMessage, tc.module_text);
+ BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.module_text);
ASSERT_NE(nullptr, module);
// Analyze the instructions.
- opt::analysis::DefUseManager manager(IgnoreMessage, module.get());
+ opt::analysis::DefUseManager manager(nullptr, module.get());
for (ir::Instruction& inst : tc.insts) {
manager.AnalyzeInstDefUse(&inst);
}
// Build module.
std::unique_ptr<ir::Module> module =
- BuildModule(SPV_ENV_UNIVERSAL_1_1, IgnoreMessage, tc.before);
+ BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.before);
ASSERT_NE(nullptr, module);
// KillInst
uint32_t index = 0;
- opt::analysis::DefUseManager manager(IgnoreMessage, module.get());
+ opt::analysis::DefUseManager manager(nullptr, module.get());
module->ForEachInst([&index, &tc, &manager](ir::Instruction* inst) {
if (tc.indices_for_inst_to_kill.count(index) != 0) {
manager.KillInst(inst);
// Build module.
std::unique_ptr<ir::Module> module =
- BuildModule(SPV_ENV_UNIVERSAL_1_1, IgnoreMessage, tc.code);
+ BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.code);
ASSERT_NE(nullptr, module);
// Get annotations
- opt::analysis::DefUseManager manager(IgnoreMessage, module.get());
+ opt::analysis::DefUseManager manager(nullptr, module.get());
auto insts = manager.GetAnnotations(tc.id);
// Check
void DoRoundTripCheck(const std::string& text) {
SpirvTools t(SPV_ENV_UNIVERSAL_1_1);
std::unique_ptr<ir::Module> module =
- BuildModule(SPV_ENV_UNIVERSAL_1_1, IgnoreMessage, text);
+ BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text);
ASSERT_NE(nullptr, module) << "Failed to assemble\n" << text;
std::vector<uint32_t> binary;
SpirvTools t(SPV_ENV_UNIVERSAL_1_1);
std::unique_ptr<ir::Module> module =
- BuildModule(SPV_ENV_UNIVERSAL_1_1, IgnoreMessage, text);
+ BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text);
ASSERT_NE(nullptr, module);
const auto opundef_count = std::count_if(
// Returns a module formed by assembling the given text,
// then loading the result.
inline std::unique_ptr<Module> BuildModule(std::string text) {
- return spvtools::BuildModule(SPV_ENV_UNIVERSAL_1_1, spvtools::IgnoreMessage,
- text);
+ return spvtools::BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text);
}
TEST(ModuleTest, ComputeIdBound) {
};
std::unique_ptr<ir::Module> module =
- BuildModule(SPV_ENV_UNIVERSAL_1_1, IgnoreMessage, text);
- opt::analysis::TypeManager manager(IgnoreMessage, *module);
+ BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text);
+ opt::analysis::TypeManager manager(nullptr, *module);
EXPECT_EQ(type_id_strs.size(), manager.NumTypes());
EXPECT_EQ(2u, manager.NumForwardPointers());
%struct7 = OpTypeStruct %f32 ; no decoration
)";
std::unique_ptr<ir::Module> module =
- BuildModule(SPV_ENV_UNIVERSAL_1_1, IgnoreMessage, text);
- opt::analysis::TypeManager manager(IgnoreMessage, *module);
+ BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text);
+ opt::analysis::TypeManager manager(nullptr, *module);
ASSERT_EQ(7u, manager.NumTypes());
ASSERT_EQ(0u, manager.NumForwardPointers());
%struct10 = OpTypeStruct %u32 %f32 ; no member decoration
)";
std::unique_ptr<ir::Module> module =
- BuildModule(SPV_ENV_UNIVERSAL_1_1, IgnoreMessage, text);
- opt::analysis::TypeManager manager(IgnoreMessage, *module);
+ BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text);
+ opt::analysis::TypeManager manager(nullptr, *module);
ASSERT_EQ(10u, manager.NumTypes());
ASSERT_EQ(0u, manager.NumForwardPointers());
%struct5 = OpTypeStruct %f32
)";
std::unique_ptr<ir::Module> module =
- BuildModule(SPV_ENV_UNIVERSAL_1_1, IgnoreMessage, text);
- opt::analysis::TypeManager manager(IgnoreMessage, *module);
+ BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text);
+ opt::analysis::TypeManager manager(nullptr, *module);
ASSERT_EQ(5u, manager.NumTypes());
ASSERT_EQ(0u, manager.NumForwardPointers());