[NFC][testing] Return underlying strings directly instead of OS.str()

This avoids an unnecessary copy required by 'return OS.str()', allowing
instead for NRVO or implicit move. The .str() call (which flushes the
stream) is no longer required since 65b13610a5,
which made raw_string_ostream unbuffered by default.

Differential Revision: https://reviews.llvm.org/D115374
This commit is contained in:
Logan Smith 2021-12-09 14:55:44 -08:00
parent ad17ea12e7
commit 08eb614e30
4 changed files with 7 additions and 7 deletions

View File

@ -73,7 +73,7 @@ struct TestClangConfig {
std::string Result;
llvm::raw_string_ostream OS(Result);
OS << "{ Language=" << Language << ", Target=" << Target << " }";
return OS.str();
return Result;
}
friend std::ostream &operator<<(std::ostream &OS,

View File

@ -111,7 +111,7 @@ template <typename... NodeType> std::string dumpASTString(NodeType &&... N) {
Dumper.Visit(std::forward<NodeType &&>(N)...);
return OS.str();
return Buffer;
}
template <typename... NodeType>
@ -126,7 +126,7 @@ std::string dumpASTString(TraversalKind TK, NodeType &&... N) {
Dumper.Visit(std::forward<NodeType &&>(N)...);
return OS.str();
return Buffer;
}
const FunctionDecl *getFunctionNode(clang::ASTUnit *AST,

View File

@ -95,14 +95,14 @@ protected:
std::string Buf;
llvm::raw_string_ostream OS{Buf};
Ctx.dumpExpandedTextsToStream(OS);
return OS.str();
return Buf;
}
static std::string dumpExpansionRanges(const MacroExpansionContext &Ctx) {
std::string Buf;
llvm::raw_string_ostream OS{Buf};
Ctx.dumpExpansionRangesToStream(OS);
return OS.str();
return Buf;
}
};

View File

@ -203,7 +203,7 @@ protected:
OS << "]";
return OS.str();
return Storage;
}
std::string dumpNodes(ArrayRef<Node *> Nodes) {
@ -218,7 +218,7 @@ protected:
OS << "]";
return OS.str();
return Storage;
}
};