forked from OSchip/llvm-project
[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:
parent
ad17ea12e7
commit
08eb614e30
|
@ -73,7 +73,7 @@ struct TestClangConfig {
|
||||||
std::string Result;
|
std::string Result;
|
||||||
llvm::raw_string_ostream OS(Result);
|
llvm::raw_string_ostream OS(Result);
|
||||||
OS << "{ Language=" << Language << ", Target=" << Target << " }";
|
OS << "{ Language=" << Language << ", Target=" << Target << " }";
|
||||||
return OS.str();
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend std::ostream &operator<<(std::ostream &OS,
|
friend std::ostream &operator<<(std::ostream &OS,
|
||||||
|
|
|
@ -111,7 +111,7 @@ template <typename... NodeType> std::string dumpASTString(NodeType &&... N) {
|
||||||
|
|
||||||
Dumper.Visit(std::forward<NodeType &&>(N)...);
|
Dumper.Visit(std::forward<NodeType &&>(N)...);
|
||||||
|
|
||||||
return OS.str();
|
return Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... NodeType>
|
template <typename... NodeType>
|
||||||
|
@ -126,7 +126,7 @@ std::string dumpASTString(TraversalKind TK, NodeType &&... N) {
|
||||||
|
|
||||||
Dumper.Visit(std::forward<NodeType &&>(N)...);
|
Dumper.Visit(std::forward<NodeType &&>(N)...);
|
||||||
|
|
||||||
return OS.str();
|
return Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FunctionDecl *getFunctionNode(clang::ASTUnit *AST,
|
const FunctionDecl *getFunctionNode(clang::ASTUnit *AST,
|
||||||
|
|
|
@ -95,14 +95,14 @@ protected:
|
||||||
std::string Buf;
|
std::string Buf;
|
||||||
llvm::raw_string_ostream OS{Buf};
|
llvm::raw_string_ostream OS{Buf};
|
||||||
Ctx.dumpExpandedTextsToStream(OS);
|
Ctx.dumpExpandedTextsToStream(OS);
|
||||||
return OS.str();
|
return Buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string dumpExpansionRanges(const MacroExpansionContext &Ctx) {
|
static std::string dumpExpansionRanges(const MacroExpansionContext &Ctx) {
|
||||||
std::string Buf;
|
std::string Buf;
|
||||||
llvm::raw_string_ostream OS{Buf};
|
llvm::raw_string_ostream OS{Buf};
|
||||||
Ctx.dumpExpansionRangesToStream(OS);
|
Ctx.dumpExpansionRangesToStream(OS);
|
||||||
return OS.str();
|
return Buf;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -203,7 +203,7 @@ protected:
|
||||||
|
|
||||||
OS << "]";
|
OS << "]";
|
||||||
|
|
||||||
return OS.str();
|
return Storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string dumpNodes(ArrayRef<Node *> Nodes) {
|
std::string dumpNodes(ArrayRef<Node *> Nodes) {
|
||||||
|
@ -218,7 +218,7 @@ protected:
|
||||||
|
|
||||||
OS << "]";
|
OS << "]";
|
||||||
|
|
||||||
return OS.str();
|
return Storage;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue