Commit 7f57220e authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

fixing clang warnings in quantum package


Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent b52c27aa
......@@ -15,7 +15,7 @@
#include "Function.hpp"
#include "DWQMI.hpp"
#include "Utils.hpp"
#include "XACC.hpp"
namespace xacc {
namespace quantum {
......@@ -37,6 +37,7 @@ public:
/**
* The constructor, takes the function unique id and its name.
*
*
* @param id
* @param name
*/
......@@ -48,11 +49,13 @@ public:
}
virtual InstPtr getInstruction(const int idx) {
InstPtr i;
if (instructions.size() > idx) {
return *std::next(instructions.begin(), idx);
i = *std::next(instructions.begin(), idx);
} else {
XACCLogger::instance()->error("Invalid instruction index.");
xacc::error("DWKernel getInstruction invalid instruction index - " + std::to_string(idx) + ".");
}
return i;
}
virtual std::list<InstPtr> getInstructions() {
......@@ -149,19 +152,21 @@ public:
}
virtual InstructionParameter getParameter(const int idx) const {
XACCLogger::instance()->error("DWKernel does not contain runtime parameters.");
xacc::error("DWKernel does not contain runtime parameters.");
return InstructionParameter(0);
}
virtual void setParameter(const int idx, InstructionParameter& p) {
XACCLogger::instance()->error("DWKernel does not contain runtime parameters.");
xacc::error("DWKernel does not contain runtime parameters.");
}
virtual std::vector<InstructionParameter> getParameters() {
XACCLogger::instance()->error("DWKernel does not contain runtime parameters.");
xacc::error("DWKernel does not contain runtime parameters.");
return {};
}
virtual void addParameter(InstructionParameter instParam) {
XACCLogger::instance()->error("DWKernel does not contain runtime parameters.");
xacc::error("DWKernel does not contain runtime parameters.");
}
virtual bool isParameterized() {
......@@ -173,7 +178,7 @@ public:
}
virtual void evaluateVariableParameters(std::vector<InstructionParameter> parameters) {
XACCLogger::instance()->error("DWKernel does not contain runtime parameters.");
xacc::error("DWKernel does not contain runtime parameters.");
}
......
......@@ -15,7 +15,7 @@
#include "Registry.hpp"
#include "Function.hpp"
#include "Utils.hpp"
#include "XACC.hpp"
namespace xacc {
namespace quantum {
......@@ -90,11 +90,13 @@ public:
}
virtual InstPtr getInstruction(const int idx) {
InstPtr i;
if (instructions.size() > idx) {
return *std::next(instructions.begin(), idx);
i = *std::next(instructions.begin(), idx);
} else {
XACCLogger::instance()->error("Invalid instruction index.");
xacc::error("GateFunction getInstruction invalid instruction index - " + std::to_string(idx) + ".");
}
return i;
}
virtual std::list<InstPtr> getInstructions() {
......
......@@ -106,12 +106,16 @@ public:
}
virtual std::shared_ptr<Function> getKernel(const std::string& name) {
std::shared_ptr<Function> ret;
for (auto f : kernels) {
if (f->getName() == name) {
return f;
ret = f;
}
}
XACCLogger::instance()->error("Invalid kernel name.");
if (!ret) {
xacc::error("Invalid kernel name.");
}
return ret;
}
virtual bool kernelExists(const std::string& name) {
......
......@@ -28,6 +28,7 @@ std::shared_ptr<AcceleratorBufferPostprocessor> ReadoutErrorIRPreprocessor::proc
int nQubits = 0;//std::stoi(xacc::getOption("n-qubits")); //ir.maxBit() + 1;
auto gateRegistry = GateInstructionRegistry::instance();
// Get the true number of qubits
std::set<int> qubits;
for (auto kernel : ir.getKernels()) {
......
......@@ -14,7 +14,7 @@
#define XACC_UTILS_REGISTRY_HPP_
#include "Singleton.hpp"
#include "Utils.hpp"
#include "XACC.hpp"
#include "RuntimeOptions.hpp"
#include <map>
#include <iostream>
......@@ -61,11 +61,11 @@ public:
if (RuntimeOptions::instance()->exists("verbose-registry")) XACCLogger::instance()->info("Registry adding " + id);
bool s = registry.emplace(std::make_pair(id, f)).second;
if (!s) {
XACCLogger::instance()->error("Could not add " + id + " to the Registry.");
} else {
return s;
if (s) {
return true;
}
xacc::error("Could not add " + id + " to the Registry.");
return false;
}
/**
......@@ -81,14 +81,14 @@ public:
bool add(const std::string& id,
CreatorFunctionPtr f, std::shared_ptr<options_description> options) {
if (registry.find(id) != registry.end()) {
XACCLogger::instance()->info(id + " already exists in Registry. Ignoring and retaining previous Registry entry");
return true;
}
if (RuntimeOptions::instance()->exists("verbose-registry")) XACCLogger::instance()->info("Registry adding " + id);
bool s = registry.emplace(std::make_pair(id, f)).second;
bool s2 = registryOptions.insert(std::make_pair(id, std::move(options))).second;
if (!s || ! s2) {
XACCLogger::instance()->error("Could not add " + id + " to the Registry.");
xacc::error("Could not add " + id + " to the Registry.");
return false;
} else {
return true;
}
......@@ -110,7 +110,8 @@ public:
registryOptions.insert(std::make_pair(id, std::move(options))).second;
bool s3 = registryOptionHandlers.insert(std::make_pair(id, std::move(optionsHandler))).second;
if (!s || !s2) {
XACCLogger::instance()->error("Could not add " + id + " to the Registry.");
xacc::error("Could not add " + id + " to the Registry.");
return false;
} else {
return true;
}
......@@ -128,7 +129,8 @@ public:
if (search != registry.end()) {
return registry[id]->operator()(args...);
} else {
XACCLogger::instance()->error("Invalid Registry map id string - " + id);
xacc::error("Invalid Registry map id string - " + id);
return std::make_shared<T>(args...);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment