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/Parser.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/Parser.cpp')
-rw-r--r-- | lib/Parse/Parser.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index a9ce22d047..d0d1871829 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -41,10 +41,12 @@ Parser::Parser(Preprocessor &pp, Action &actions) Action::~Action() {} -bool Parser::Diag(SourceLocation Loc, unsigned DiagID, - const std::string &Msg) { - Diags.Report(FullSourceLoc(Loc,PP.getSourceManager()), DiagID) << Msg; - return true; +DiagnosticInfo Parser::Diag(SourceLocation Loc, unsigned DiagID) { + return Diags.Report(FullSourceLoc(Loc,PP.getSourceManager()), DiagID); +} + +DiagnosticInfo Parser::Diag(const Token &Tok, unsigned DiagID) { + return Diag(Tok.getLocation(), DiagID); } bool Parser::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg, @@ -81,7 +83,7 @@ SourceLocation Parser::MatchRHSPunctuation(tok::TokenKind RHSTok, case tok::greater: LHSName = "<"; DID = diag::err_expected_greater; break; } Diag(Tok, DID); - Diag(LHSLoc, diag::err_matching, LHSName); + Diag(LHSLoc, diag::err_matching) << LHSName; SkipUntil(RHSTok); return R; } @@ -99,7 +101,7 @@ bool Parser::ExpectAndConsume(tok::TokenKind ExpectedTok, unsigned DiagID, return false; } - Diag(Tok, DiagID, Msg); + Diag(Tok, DiagID) << Msg; if (SkipToTok != tok::unknown) SkipUntil(SkipToTok); return true; @@ -405,7 +407,7 @@ Parser::DeclTy *Parser::ParseDeclarationOrFunctionDefinition() { } const char *PrevSpec = 0; if (DS.SetTypeSpecType(DeclSpec::TST_unspecified, AtLoc, PrevSpec)) - Diag(AtLoc, diag::err_invalid_decl_spec_combination, PrevSpec); + Diag(AtLoc, diag::err_invalid_decl_spec_combination) << PrevSpec; if (Tok.isObjCAtKeyword(tok::objc_protocol)) return ParseObjCAtProtocolDeclaration(AtLoc, DS.getAttributes()); return ParseObjCAtInterfaceDeclaration(AtLoc, DS.getAttributes()); @@ -609,8 +611,8 @@ void Parser::ParseKNRParamDeclarations(Declarator &D) { // C99 6.9.1p6: those declarators shall declare only identifiers from // the identifier list. if (i == FTI.NumArgs) { - Diag(ParmDeclarator.getIdentifierLoc(), diag::err_no_matching_param, - ParmDeclarator.getIdentifier()->getName()); + Diag(ParmDeclarator.getIdentifierLoc(), diag::err_no_matching_param) + << ParmDeclarator.getIdentifier()->getName(); break; } @@ -618,8 +620,8 @@ void Parser::ParseKNRParamDeclarations(Declarator &D) { // Reject redefinitions of parameters. if (FTI.ArgInfo[i].Param) { Diag(ParmDeclarator.getIdentifierLoc(), - diag::err_param_redefinition, - ParmDeclarator.getIdentifier()->getName()); + diag::err_param_redefinition) + << ParmDeclarator.getIdentifier()->getName(); } else { FTI.ArgInfo[i].Param = Param; } @@ -689,7 +691,7 @@ Parser::ExprResult Parser::ParseSimpleAsm() { SourceLocation Loc = ConsumeToken(); if (Tok.isNot(tok::l_paren)) { - Diag(Tok, diag::err_expected_lparen_after, "asm"); + Diag(Tok, diag::err_expected_lparen_after) << "asm"; return true; } |