diff options
author | Chris Lattner <sabre@nondot.org> | 2008-11-18 07:48:38 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-11-18 07:48:38 +0000 |
commit | 1ab3b96de160e4fbffec2a776e284a48a3bb543d (patch) | |
tree | 9ab728aaab0602c9e14a93602a50d62932a74f5e /lib/Parse/ParseObjc.cpp | |
parent | d3b64655fa81ff1e1d5f944198239e4908035d79 (diff) |
Change a couple of the Parser::Diag methods to return DiagnosticInfo
and let the clients push whatever they want into the DiagnosticInfo
instead of hard coding a few forms. Also switch various clients to
use Diag(Tok, ...) instead of Diag(Tok.getLocation(), ...) as the
canonical form to simplify the code a bit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59509 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseObjc.cpp')
-rw-r--r-- | lib/Parse/ParseObjc.cpp | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index f6d77cfb50..45ce3e1d92 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -412,7 +412,7 @@ void Parser::ParseObjCPropertyAttribute(ObjCDeclSpec &DS) { return; if (Tok.isNot(tok::identifier)) { - Diag(Tok.getLocation(), diag::err_expected_ident); + Diag(Tok, diag::err_expected_ident); SkipUntil(tok::r_paren); return; } @@ -431,7 +431,7 @@ void Parser::ParseObjCPropertyAttribute(ObjCDeclSpec &DS) { ConsumeToken(); // consume method name } } else { - Diag(AttrName, diag::err_objc_expected_property_attr, II->getName()); + Diag(AttrName, diag::err_objc_expected_property_attr) << II->getName(); SkipUntil(tok::r_paren); return; } @@ -625,7 +625,7 @@ Parser::TypeTy *Parser::ParseObjCTypeName(ObjCDeclSpec &DS) { ConsumeParen(); else if (Tok.getLocation() == TypeStartLoc) { // If we didn't eat any tokens, then this isn't a type. - Diag(Tok.getLocation(), diag::err_expected_type); + Diag(Tok, diag::err_expected_type); SkipUntil(tok::r_paren); } else { // Otherwise, we found *something*, but didn't get a ')' in the right @@ -678,8 +678,8 @@ Parser::DeclTy *Parser::ParseObjCMethodDecl(SourceLocation mLoc, IdentifierInfo *SelIdent = ParseObjCSelector(selLoc); if (!SelIdent) { // missing selector name. - Diag(Tok.getLocation(), diag::err_expected_selector_for_method, - SourceRange(mLoc, Tok.getLocation())); + Diag(Tok, diag::err_expected_selector_for_method) + << SourceRange(mLoc, Tok.getLocation()); // Skip until we get a ; or {}. SkipUntil(tok::r_brace); return 0; @@ -1089,7 +1089,7 @@ Parser::DeclTy *Parser::ParseObjCAtAliasDeclaration(SourceLocation atLoc) { IdentifierInfo *classId = Tok.getIdentifierInfo(); SourceLocation classLoc = ConsumeToken(); // consume class-name; if (Tok.isNot(tok::semi)) { - Diag(Tok, diag::err_expected_semi_after, "@compatibility_alias"); + Diag(Tok, diag::err_expected_semi_after) << "@compatibility_alias"; return 0; } DeclTy *ClsType = Actions.ActOnCompatiblityAlias(atLoc, @@ -1138,7 +1138,7 @@ Parser::DeclTy *Parser::ParseObjCPropertySynthesize(SourceLocation atLoc) { ConsumeToken(); // consume ',' } if (Tok.isNot(tok::semi)) - Diag(Tok, diag::err_expected_semi_after, "@synthesize"); + Diag(Tok, diag::err_expected_semi_after) << "@synthesize"; return 0; } @@ -1168,7 +1168,7 @@ Parser::DeclTy *Parser::ParseObjCPropertyDynamic(SourceLocation atLoc) { ConsumeToken(); // consume ',' } if (Tok.isNot(tok::semi)) - Diag(Tok, diag::err_expected_semi_after, "@dynamic"); + Diag(Tok, diag::err_expected_semi_after) << "@dynamic"; return 0; } @@ -1195,7 +1195,7 @@ Parser::StmtResult Parser::ParseObjCThrowStmt(SourceLocation atLoc) { Parser::StmtResult Parser::ParseObjCSynchronizedStmt(SourceLocation atLoc) { ConsumeToken(); // consume synchronized if (Tok.isNot(tok::l_paren)) { - Diag (Tok, diag::err_expected_lparen_after, "@synchronized"); + Diag(Tok, diag::err_expected_lparen_after) << "@synchronized"; return true; } ConsumeParen(); // '(' @@ -1205,12 +1205,12 @@ Parser::StmtResult Parser::ParseObjCSynchronizedStmt(SourceLocation atLoc) { return true; } if (Tok.isNot(tok::r_paren)) { - Diag (Tok, diag::err_expected_lbrace); + Diag(Tok, diag::err_expected_lbrace); return true; } ConsumeParen(); // ')' if (Tok.isNot(tok::l_brace)) { - Diag (Tok, diag::err_expected_lbrace); + Diag(Tok, diag::err_expected_lbrace); return true; } // Enter a scope to hold everything within the compound stmt. Compound @@ -1241,7 +1241,7 @@ Parser::StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) { ConsumeToken(); // consume try if (Tok.isNot(tok::l_brace)) { - Diag (Tok, diag::err_expected_lbrace); + Diag(Tok, diag::err_expected_lbrace); return true; } StmtResult CatchStmts; @@ -1299,8 +1299,8 @@ Parser::StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) { FirstPart, CatchBody.Val, CatchStmts.Val); ExitScope(); } else { - Diag(AtCatchFinallyLoc, diag::err_expected_lparen_after, - "@catch clause"); + Diag(AtCatchFinallyLoc, diag::err_expected_lparen_after) + << "@catch clause"; return true; } catch_or_finally_seen = true; @@ -1411,7 +1411,7 @@ Parser::ExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) { case tok::objc_selector: return ParsePostfixExpressionSuffix(ParseObjCSelectorExpression(AtLoc)); default: - return Diag(AtLoc, diag::err_unexpected_at); + return Diag(AtLoc, diag::err_unexpected_at); } } } @@ -1604,7 +1604,7 @@ Parser::ExprResult Parser::ParseObjCEncodeExpression(SourceLocation AtLoc) { SourceLocation EncLoc = ConsumeToken(); if (Tok.isNot(tok::l_paren)) - return Diag(Tok, diag::err_expected_lparen_after, "@encode"); + return Diag(Tok, diag::err_expected_lparen_after) << "@encode"; SourceLocation LParenLoc = ConsumeParen(); @@ -1619,12 +1619,11 @@ Parser::ExprResult Parser::ParseObjCEncodeExpression(SourceLocation AtLoc) { /// objc-protocol-expression /// @protocol ( protocol-name ) -Parser::ExprResult Parser::ParseObjCProtocolExpression(SourceLocation AtLoc) -{ +Parser::ExprResult Parser::ParseObjCProtocolExpression(SourceLocation AtLoc) { SourceLocation ProtoLoc = ConsumeToken(); if (Tok.isNot(tok::l_paren)) - return Diag(Tok, diag::err_expected_lparen_after, "@protocol"); + return Diag(Tok, diag::err_expected_lparen_after) << "@protocol"; SourceLocation LParenLoc = ConsumeParen(); @@ -1642,12 +1641,11 @@ Parser::ExprResult Parser::ParseObjCProtocolExpression(SourceLocation AtLoc) /// objc-selector-expression /// @selector '(' objc-keyword-selector ')' -Parser::ExprResult Parser::ParseObjCSelectorExpression(SourceLocation AtLoc) -{ +Parser::ExprResult Parser::ParseObjCSelectorExpression(SourceLocation AtLoc) { SourceLocation SelectorLoc = ConsumeToken(); if (Tok.isNot(tok::l_paren)) - return Diag(Tok, diag::err_expected_lparen_after, "@selector"); + return Diag(Tok, diag::err_expected_lparen_after) << "@selector"; llvm::SmallVector<IdentifierInfo *, 12> KeyIdents; SourceLocation LParenLoc = ConsumeParen(); |