Avoid calling `quoteSymbol` multiple times. (#7307)
authorAbdalrhman Mohamed <32971963+abdoo8080@users.noreply.github.com>
Wed, 6 Oct 2021 00:41:05 +0000 (19:41 -0500)
committerGitHub <noreply@github.com>
Wed, 6 Oct 2021 00:41:05 +0000 (00:41 +0000)
Calling `quoteSymbol(...)` twice on an empty string `""` returns `"|__|"`.

src/printer/smt2/smt2_printer.cpp

index 507937b2d5c6f811d302a312473dec6d6033a911..32b195be2c38ae5a95291e282b3a7dcc7b3a83cb 100644 (file)
@@ -1223,12 +1223,6 @@ static bool tryToStream(std::ostream& out, const Command* c);
 template <class T>
 static bool tryToStream(std::ostream& out, const Command* c, Variant v);
 
-static std::string quoteSymbol(TNode n) {
-  std::stringstream ss;
-  ss << n;
-  return cvc5::quoteSymbol(ss.str());
-}
-
 template <class T>
 static bool tryToStream(std::ostream& out, const CommandStatus* s, Variant v);
 
@@ -1317,8 +1311,7 @@ void Smt2Printer::toStreamModelSort(std::ostream& out,
           || options::modelUninterpPrint()
                  == options::ModelUninterpPrintMode::DeclFun)
       {
-        out << "(declare-fun " << quoteSymbol(trn) << " () " << tn << ")"
-            << endl;
+        out << "(declare-fun " << trn << " () " << tn << ")" << endl;
       }
     }
     else
@@ -1543,11 +1536,8 @@ void Smt2Printer::toStreamCmdDeclareType(std::ostream& out,
                                          TypeNode type) const
 {
   Assert(type.isSort() || type.isSortConstructor());
-  std::stringstream id;
-  id << type;
   size_t arity = type.isSortConstructor() ? type.getSortConstructorArity() : 0;
-  out << "(declare-sort " << cvc5::quoteSymbol(id.str()) << " " << arity << ")"
-      << std::endl;
+  out << "(declare-sort " << type << " " << arity << ")" << std::endl;
 }
 
 void Smt2Printer::toStreamCmdDefineType(std::ostream& out,
@@ -1814,11 +1804,7 @@ void Smt2Printer::toStreamCmdSynthFun(std::ostream& out,
                                       bool isInv,
                                       TypeNode sygusType) const
 {
-  std::stringstream sym;
-  sym << f;
-  out << '(' << (isInv ? "synth-inv " : "synth-fun ")
-      << cvc5::quoteSymbol(sym.str()) << ' ';
-  out << '(';
+  out << '(' << (isInv ? "synth-inv " : "synth-fun ") << f << ' ' << '(';
   if (!vars.empty())
   {
     // print variable list