On May 16, 2012, at 1:32, Douglas Gregor wrote: > Modified: cfe/trunk/lib/Sema/SemaStmt.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=156904&r1=156903&r2=156904&view=diff > ============================================================================== > --- cfe/trunk/lib/Sema/SemaStmt.cpp (original) > +++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed May 16 00:32:58 2012 > @@ -768,8 +768,29 @@ > > if (i != 0 && CaseVals[i].first == CaseVals[i-1].first) { > // If we have a duplicate, report it. > - Diag(CaseVals[i].second->getLHS()->getLocStart(), > - diag::err_duplicate_case) << CaseVals[i].first.toString(10); > + // First, determine if either case value has a name > + StringRef PrevString, CurrString; > + Expr *PrevCase = > CaseVals[i-1].second->getLHS()->IgnoreParenCasts(); > + Expr *CurrCase = CaseVals[i].second->getLHS()->IgnoreParenCasts(); > + if (DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(PrevCase)) { > + PrevString = DeclRef->getDecl()->getName(); > + } > + if (DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(CurrCase)) { > + CurrString = DeclRef->getDecl()->getName(); > + }
> + std::string CaseValStr = CaseVals[i-1].first.toString(10); Just saw this earlier today. APSInt has a toString method that takes a SmallString to print to (and defaults to base 10). SmallString<16> CaseValStr; CaseVals[i-1].first.toString(CaseValStr); Sorry for not getting that in before the commit! Jordy _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
