From 50de5e3247a20e0e548dc47022a011250e6e4e8f Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 16 May 2012 16:11:17 +0000 Subject: [PATCH] Use a llvm::SmallString rather than std::string for duplicate-case errors git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156922 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaStmt.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 295068c9f2..f64fc96c0e 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -30,6 +30,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" using namespace clang; using namespace sema; @@ -778,17 +779,18 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, if (DeclRefExpr *DeclRef = dyn_cast(CurrCase)) { CurrString = DeclRef->getDecl()->getName(); } - std::string CaseValStr = CaseVals[i-1].first.toString(10); + llvm::SmallString<16> CaseValStr; + CaseVals[i-1].first.toString(CaseValStr); if (PrevString == CurrString) Diag(CaseVals[i].second->getLHS()->getLocStart(), diag::err_duplicate_case) << - (PrevString.empty() ? CaseValStr : PrevString.str()); + (PrevString.empty() ? CaseValStr.str() : PrevString); else Diag(CaseVals[i].second->getLHS()->getLocStart(), diag::err_duplicate_case_differing_expr) << - (PrevString.empty() ? CaseValStr : PrevString.str()) << - (CurrString.empty() ? CaseValStr : CurrString.str()) << + (PrevString.empty() ? CaseValStr.str() : PrevString) << + (CurrString.empty() ? CaseValStr.str() : CurrString) << CaseValStr; Diag(CaseVals[i-1].second->getLHS()->getLocStart(), -- 2.40.0