5 changes: 2 additions & 3 deletions mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2334,9 +2334,8 @@ std::string mlir::linalg::generateLibraryCallName(Operation *op) {
return std::string();
ss << "_";
}
std::string res = ss.str();
res.pop_back();
return res;
name.pop_back();
return name;
}

//===----------------------------------------------------------------------===//
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ DiagnosedSilenceableFailure transform::MatchStructuredBodyOp::matchOperation(
os);
if (result)
return DiagnosedSilenceableFailure::success();
return emitSilenceableError() << "contraction: " << os.str();
return emitSilenceableError() << "contraction: " << message;
}
return emitDefiniteFailure() << "unknown body condition";
}
Expand All @@ -226,7 +226,7 @@ LogicalResult transform::MatchStructuredBodyOp::verify() {
getElementwiseAttrName(),
getContractionAttrName()},
os);
return emitOpError() << "only one of {" << os.str() << "} is allowed";
return emitOpError() << "only one of {" << attributeNames << "} is allowed";
}

if (std::optional<ArrayAttr> contractionAttr = getContraction()) {
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@ static void printCaptureType(OpAsmPrinter &p, Operation *op,
typeCap << "VLAType";
if (mapCaptureType.getValue() == mlir::omp::VariableCaptureKind::This)
typeCap << "This";
p << typeCap.str();
p << typeCapStr;
}

static ParseResult parseCaptureType(OpAsmParser &parser,
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/SparseTensor/IR/Detail/Var.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ std::string Var::str() const {
std::string str;
llvm::raw_string_ostream os(str);
print(os);
return os.str();
return str;
}

void Var::print(AsmPrinter &printer) const { print(printer.getStream()); }
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/Traits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ static std::string getShapeString(ArrayRef<int64_t> shape) {
},
"x");
ss << '\'';
return ss.str();
return ret;
}

LogicalResult OpTrait::impl::verifyCompatibleOperandBroadcast(Operation *op) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ DiagnosedSilenceableFailure transform::DebugEmitParamAsRemarkOp::apply(
os << *getMessage() << " ";
llvm::interleaveComma(state.getParams(getParam()), os);
if (!getAnchor()) {
emitRemark() << os.str();
emitRemark() << str;
return DiagnosedSilenceableFailure::success();
}
for (Operation *payload : state.getPayloadOps(getAnchor()))
::mlir::emitRemark(payload->getLoc()) << os.str();
::mlir::emitRemark(payload->getLoc()) << str;
return DiagnosedSilenceableFailure::success();
}
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/Transform/IR/TransformOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1967,7 +1967,7 @@ transform::MatchParamCmpIOp::apply(transform::TransformRewriter &rewriter,
std::string str;
llvm::raw_string_ostream os(str);
value.print(os, /*isSigned=*/true);
return os.str();
return str;
};

ArrayRef<Attribute> params = state.getParams(getParam());
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/ExecutionEngine/ExecutionEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ Expected<void *> ExecutionEngine::lookup(StringRef name) const {
llvm::raw_string_ostream os(errorMessage);
llvm::handleAllErrors(expectedSymbol.takeError(),
[&os](llvm::ErrorInfoBase &ei) { ei.log(os); });
return makeStringError(os.str());
return makeStringError(errorMessage);
}

if (void *fptr = expectedSymbol->toPtr<void *>())
Expand Down
12 changes: 6 additions & 6 deletions mlir/lib/IR/Diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ Diagnostic &Diagnostic::appendOp(Operation &op, const OpPrintingFlags &flags) {
// multiple lines.
if (str.find('\n') != std::string::npos)
*this << '\n';
return *this << os.str();
return *this << str;
}

/// Stream in a Value.
Diagnostic &Diagnostic::operator<<(Value val) {
std::string str;
llvm::raw_string_ostream os(str);
val.print(os, adjustPrintingFlags(OpPrintingFlags(), severity));
return *this << os.str();
return *this << str;
}

/// Outputs this diagnostic to a stream.
Expand All @@ -168,7 +168,7 @@ std::string Diagnostic::str() const {
std::string str;
llvm::raw_string_ostream os(str);
print(os);
return os.str();
return str;
}

/// Attaches a note to this diagnostic. A new location may be optionally
Expand Down Expand Up @@ -451,7 +451,7 @@ void SourceMgrDiagnosticHandler::emitDiagnostic(Location loc, Twine message,
if (!llvm::isa<UnknownLoc>(loc))
strOS << loc << ": ";
strOS << message;
return mgr.PrintMessage(os, SMLoc(), getDiagKind(kind), strOS.str());
return mgr.PrintMessage(os, SMLoc(), getDiagKind(kind), str);
}

// Otherwise if we are displaying the source line, try to convert the file
Expand All @@ -469,7 +469,7 @@ void SourceMgrDiagnosticHandler::emitDiagnostic(Location loc, Twine message,
llvm::raw_string_ostream locOS(locStr);
locOS << fileLoc.getFilename().getValue() << ":" << fileLoc.getLine() << ":"
<< fileLoc.getColumn();
llvm::SMDiagnostic diag(locOS.str(), getDiagKind(kind), message.str());
llvm::SMDiagnostic diag(locStr, getDiagKind(kind), message.str());
diag.print(nullptr, os);
}

Expand Down Expand Up @@ -637,7 +637,7 @@ struct ExpectedDiag {
regexOS << '(' << regexStr << ')';
strToProcess = strToProcess.drop_front(regexEndIt + 2);
}
substringRegex = llvm::Regex(regexOS.str());
substringRegex = llvm::Regex(regexStr);
return success();
}

Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Interfaces/DataLayoutInterfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ using namespace mlir;
os << "neither the scoping op nor the type class provide data layout "
"information for "
<< type;
llvm::report_fatal_error(Twine(os.str()));
llvm::report_fatal_error(Twine(message));
}

/// Returns the bitwidth of the index type if specified in the param list.
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Interfaces/RuntimeVerifiableOpInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ RuntimeVerifiableOpInterface::generateErrorMessage(Operation *op,
stream << "\n^ " << msg;
stream << "\nLocation: ";
op->getLoc().print(stream);
return stream.str();
return buffer;
}
} // namespace mlir

Expand Down
3 changes: 1 addition & 2 deletions mlir/lib/Pass/Pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ LogicalResult Pass::initializeOptions(
std::string errStr;
llvm::raw_string_ostream os(errStr);
if (failed(passOptions.parseFromString(options, os))) {
os.flush();
return errorHandler(errStr);
}
return success();
Expand Down Expand Up @@ -700,7 +699,7 @@ std::string OpToOpPassAdaptor::getAdaptorName() {
os << '\'' << pm.getOpAnchorName() << '\'';
});
os << ']';
return os.str();
return name;
}

void OpToOpPassAdaptor::runOnOperation() {
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Pass/PassCrashRecovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ void PassCrashReproducerGenerator::prepareReproducerFor(Pass *pass,
passOS << ")";

impl->activeContexts.push_back(std::make_unique<RecoveryReproducerContext>(
passOS.str(), op, impl->streamFactory, impl->pmFlagVerifyPasses));
passStr, op, impl->streamFactory, impl->pmFlagVerifyPasses));
}
void PassCrashReproducerGenerator::prepareReproducerFor(
iterator_range<PassManager::pass_iterator> passes, Operation *op) {
Expand All @@ -331,7 +331,7 @@ void PassCrashReproducerGenerator::prepareReproducerFor(
passes, passOS, [&](Pass &pass) { pass.printAsTextualPipeline(passOS); });

impl->activeContexts.push_back(std::make_unique<RecoveryReproducerContext>(
passOS.str(), op, impl->streamFactory, impl->pmFlagVerifyPasses));
passStr, op, impl->streamFactory, impl->pmFlagVerifyPasses));
}

void PassCrashReproducerGenerator::removeLastReproducerFor(Pass *pass,
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Query/Matcher/RegistryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ RegistryManager::getMatcherCompletions(llvm::ArrayRef<ArgKind> acceptedTypes,
else if (argKinds[0][0] == ArgKind::String)
typedText += "\"";

completions.emplace_back(typedText, os.str());
completions.emplace_back(typedText, decl);
}

return completions;
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Query/QueryParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ makeInvalidQueryFromDiagnostics(const matcher::internal::Diagnostics &diag) {
std::string errStr;
llvm::raw_string_ostream os(errStr);
diag.print(os);
return new InvalidQuery(os.str());
return new InvalidQuery(errStr);
}
} // namespace

Expand Down