From 62a7217b1a848fadeca15d868aa7abe15a321b52 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sat, 17 Oct 2009 23:52:50 +0000 Subject: [PATCH] Avoid std::string concatenation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84378 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Parse/ParseInit.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/Parse/ParseInit.cpp b/lib/Parse/ParseInit.cpp index 6ab23fd42d..71e9dee561 100644 --- a/lib/Parse/ParseInit.cpp +++ b/lib/Parse/ParseInit.cpp @@ -15,6 +15,7 @@ #include "clang/Parse/Parser.h" #include "clang/Parse/ParseDiagnostic.h" #include "llvm/ADT/SmallString.h" +#include "llvm/Support/raw_ostream.h" using namespace clang; @@ -65,9 +66,9 @@ Parser::OwningExprResult Parser::ParseInitializerWithPotentialDesignator() { if (Tok.is(tok::identifier)) { const IdentifierInfo *FieldName = Tok.getIdentifierInfo(); - std::string NewSyntax("."); - NewSyntax += FieldName->getName(); - NewSyntax += " = "; + llvm::SmallString<256> NewSyntax; + llvm::raw_svector_ostream(NewSyntax) << '.' << FieldName->getNameStr() + << " = "; SourceLocation NameLoc = ConsumeToken(); // Eat the identifier. @@ -77,7 +78,7 @@ Parser::OwningExprResult Parser::ParseInitializerWithPotentialDesignator() { Diag(Tok, diag::ext_gnu_old_style_field_designator) << CodeModificationHint::CreateReplacement(SourceRange(NameLoc, ColonLoc), - NewSyntax); + NewSyntax.str()); Designation D; D.AddDesignator(Designator::getField(FieldName, SourceLocation(), NameLoc)); -- 2.40.0