summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseExpr.cpp
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2013-12-24 09:48:30 +0000
committerAlp Toker <alp@nuanti.com>2013-12-24 09:48:30 +0000
commitec543279db99283f711c92c37f37b05a243dcf4d (patch)
tree03698109ecc933f59566d8c95a3f2f68b96046b9 /clang/lib/Parse/ParseExpr.cpp
parent090a7cd76df5805b13a34d1b6b4ee8dae084b528 (diff)
downloadbcm5719-llvm-ec543279db99283f711c92c37f37b05a243dcf4d.tar.gz
bcm5719-llvm-ec543279db99283f711c92c37f37b05a243dcf4d.zip
Support and use token kinds as diagnostic arguments
Introduce proper facilities to render token spellings using the diagnostic formatter. Replaces most of the hard-coded diagnostic messages related to expected tokens, which all shared the same semantics but had to be multiply defined due to variations in token order or quote marks. The associated parser changes are largely mechanical but they expose commonality in whole chunks of the parser that can now be factored away. This commit uses C++11 typed enums along with a speculative legacy fallback until the transition is complete. Requires corresponding changes in LLVM r197895. llvm-svn: 197972
Diffstat (limited to 'clang/lib/Parse/ParseExpr.cpp')
-rw-r--r--clang/lib/Parse/ParseExpr.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index db66ac52ffc..9abc5a3aefa 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -294,7 +294,7 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) {
Diag(Tok, diag::err_expected_colon)
<< FixItHint::CreateInsertion(FILoc, FIText);
- Diag(OpToken, diag::note_matching) << "?";
+ Diag(OpToken, diag::note_matching) << tok::question;
ColonLoc = Tok.getLocation();
}
}
@@ -915,7 +915,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
case tok::ampamp: { // unary-expression: '&&' identifier
SourceLocation AmpAmpLoc = ConsumeToken();
if (Tok.isNot(tok::identifier))
- return ExprError(Diag(Tok, diag::err_expected_ident));
+ return ExprError(Diag(Tok, diag::err_expected) << tok::identifier);
if (getCurScope()->getFnParent() == 0)
return ExprError(Diag(Tok, diag::err_address_of_label_outside_fn));
@@ -1289,8 +1289,8 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
SkipUntil(tok::greatergreatergreater, StopAtSemi);
} else {
// There was an error closing the brackets
- Diag(Tok, diag::err_expected_ggg);
- Diag(OpenLoc, diag::note_matching) << "<<<";
+ Diag(Tok, diag::err_expected) << tok::greatergreatergreater;
+ Diag(OpenLoc, diag::note_matching) << tok::lesslessless;
SkipUntil(tok::greatergreatergreater, StopAtSemi);
LHS = ExprError();
}
@@ -1512,7 +1512,8 @@ Parser::ParseExprAfterUnaryExprOrTypeTrait(const Token &OpTok,
isCastExpr = false;
if (OpTok.is(tok::kw_typeof) && !getLangOpts().CPlusPlus) {
- Diag(Tok,diag::err_expected_lparen_after_id) << OpTok.getIdentifierInfo();
+ Diag(Tok, diag::err_expected_after) << OpTok.getIdentifierInfo()
+ << tok::l_paren;
return ExprError();
}
@@ -1684,8 +1685,8 @@ ExprResult Parser::ParseBuiltinPrimaryExpression() {
// All of these start with an open paren.
if (Tok.isNot(tok::l_paren))
- return ExprError(Diag(Tok, diag::err_expected_lparen_after_id)
- << BuiltinII);
+ return ExprError(Diag(Tok, diag::err_expected_after) << BuiltinII
+ << tok::l_paren);
BalancedDelimiterTracker PT(*this, tok::l_paren);
PT.consumeOpen();
@@ -1703,7 +1704,7 @@ ExprResult Parser::ParseBuiltinPrimaryExpression() {
TypeResult Ty = ParseTypeName();
if (Tok.isNot(tok::r_paren)) {
- Diag(Tok, diag::err_expected_rparen);
+ Diag(Tok, diag::err_expected) << tok::r_paren;
Expr = ExprError();
}
@@ -1726,7 +1727,7 @@ ExprResult Parser::ParseBuiltinPrimaryExpression() {
// We must have at least one identifier here.
if (Tok.isNot(tok::identifier)) {
- Diag(Tok, diag::err_expected_ident);
+ Diag(Tok, diag::err_expected) << tok::identifier;
SkipUntil(tok::r_paren, StopAtSemi);
return ExprError();
}
@@ -1748,7 +1749,7 @@ ExprResult Parser::ParseBuiltinPrimaryExpression() {
Comps.back().LocStart = ConsumeToken();
if (Tok.isNot(tok::identifier)) {
- Diag(Tok, diag::err_expected_ident);
+ Diag(Tok, diag::err_expected) << tok::identifier;
SkipUntil(tok::r_paren, StopAtSemi);
return ExprError();
}
@@ -1814,7 +1815,7 @@ ExprResult Parser::ParseBuiltinPrimaryExpression() {
return Expr2;
}
if (Tok.isNot(tok::r_paren)) {
- Diag(Tok, diag::err_expected_rparen);
+ Diag(Tok, diag::err_expected) << tok::r_paren;
return ExprError();
}
Res = Actions.ActOnChooseExpr(StartLoc, Cond.take(), Expr1.take(),
@@ -1840,7 +1841,7 @@ ExprResult Parser::ParseBuiltinPrimaryExpression() {
// Attempt to consume the r-paren.
if (Tok.isNot(tok::r_paren)) {
- Diag(Tok, diag::err_expected_rparen);
+ Diag(Tok, diag::err_expected) << tok::r_paren;
SkipUntil(tok::r_paren, StopAtSemi);
return ExprError();
}
@@ -1868,7 +1869,7 @@ ExprResult Parser::ParseBuiltinPrimaryExpression() {
// Attempt to consume the r-paren.
if (Tok.isNot(tok::r_paren)) {
- Diag(Tok, diag::err_expected_rparen);
+ Diag(Tok, diag::err_expected) << tok::r_paren;
SkipUntil(tok::r_paren, StopAtSemi);
return ExprError();
}
OpenPOWER on IntegriCloud