message: fixing bug in scaffold test
diff: @@ -49,7 +49,8 @@ void ScaffoldCompiler::modifySource() {
  kernelSource.erase(kernelSource.find("__qpu__"), 7);
  kernelSource = std::string("module ") + kernelSource;
  - std::string qubitAllocationLine, cbitAllocationLine;// = " qbit qreg[3];\n";
  + std::string qubitAllocationLine, cbitAllocationLine, cbitVarName;
  + std::map<int, int> cbitToQubit;
  std::regex qbitName("qbit\\s.*");
  qubitAllocationLine = (*std::sregex_iterator(kernelSource.begin(), kernelSource.end(),
  @@ -59,16 +60,20 @@ void ScaffoldCompiler::modifySource() {
  auto qbitVarName = splitQbit[1].substr(0, splitQbit[1].find_first_of("["));
  std::regex cbitName("cbit\\s.*");
  - cbitAllocationLine = (*std::sregex_iterator(kernelSource.begin(), kernelSource.end(),
  - cbitName)).str() + "\n";
  + auto it = std::sregex_iterator(kernelSource.begin(), kernelSource.end(),
  + cbitName);
  + if (it != std::sregex_iterator()) {
  + cbitAllocationLine = (*std::sregex_iterator(kernelSource.begin(),
  + kernelSource.end(), cbitName)).str() + "\n";
  std::vector<std::string> splitCbit;
  boost::split(splitCbit, cbitAllocationLine, boost::is_any_of(" "));
  - auto cbitVarName = splitCbit[1].substr(0, splitCbit[1].find_first_of("["));
  + cbitVarName = splitCbit[1].substr(0,
  + splitCbit[1].find_first_of("["));
  std::regex measurements(".*Meas.*");
  - std::map<int, int> cbitToQubit;
  - for (auto i = std::sregex_iterator(kernelSource.begin(), kernelSource.end(),
  - measurements); i != std::sregex_iterator(); ++i) {
  + for (auto i = std::sregex_iterator(kernelSource.begin(),
  + kernelSource.end(), measurements); i != std::sregex_iterator();
  + ++i) {
  auto measurement = (*i).str();
  boost::trim(measurement);
  @@ -88,7 +93,9 @@ void ScaffoldCompiler::modifySource() {
  boost::trim(cbit);
  boost::trim(qbit);
  - cbitToQubit.insert(std::make_pair(std::stoi(cbit), std::stoi(qbit)));
  + cbitToQubit.insert(
  + std::make_pair(std::stoi(cbit), std::stoi(qbit)));
  + }
  }
  // conditional on measurements
  