Use perfect forwarding for diagnostic arguments.

While this should be a pointless performance tweak along a path where
we don't care about performance, it actually matters because we
occasionally end up copying SmallStrings or std::strings, then taking
StringRefs to the copies and holding on to them. This was manifesting
as occasional corruption in keyword-argument diagnostics.

Swift SVN r17811
This commit is contained in:
Doug Gregor
2014-05-09 22:38:01 +00:00
parent 666da96610
commit c1daf3fd7f
4 changed files with 11 additions and 9 deletions

View File

@@ -447,14 +447,15 @@ public:
template<typename ...DiagArgTypes, typename ...ArgTypes>
InFlightDiagnostic diagnose(SourceLoc Loc, Diag<DiagArgTypes...> DiagID,
ArgTypes... Args) {
return diagnose(Loc, Diagnostic(DiagID, Args...));
ArgTypes &&...Args) {
return diagnose(Loc, Diagnostic(DiagID, std::forward<ArgTypes>(Args)...));
}
template<typename ...DiagArgTypes, typename ...ArgTypes>
InFlightDiagnostic diagnose(Token Tok, Diag<DiagArgTypes...> DiagID,
ArgTypes... Args) {
return diagnose(Tok.getLoc(), Diagnostic(DiagID, Args...));
ArgTypes &&...Args) {
return diagnose(Tok.getLoc(),
Diagnostic(DiagID, std::forward<ArgTypes>(Args)...));
}
void diagnoseRedefinition(ValueDecl *Prev, ValueDecl *New);