From: Argyrios Kyrtzidis Date: Sun, 24 Aug 2008 13:14:02 +0000 (+0000) Subject: Pass SourceRanges by reference to the various Diag methods. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a88b509d233d3f42382130c159c05cafa006b3e0;p=clang Pass SourceRanges by reference to the various Diag methods. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55284 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 6f9ca22ba9..5fa62050e7 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -246,7 +246,7 @@ private: const std::string &Msg = std::string()); bool Diag(SourceLocation Loc, unsigned DiagID, const SourceRange &R); bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg, - SourceRange R1); + const SourceRange& R1); bool Diag(const Token &Tok, unsigned DiagID, const std::string &M = std::string()) { return Diag(Tok.getLocation(), DiagID, M); diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index c6b0a80e02..7598ff7996 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -39,7 +39,7 @@ bool Parser::Diag(SourceLocation Loc, unsigned DiagID, } bool Parser::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg, - SourceRange Range) { + const SourceRange& Range) { Diags.Report(PP.getFullLoc(Loc), DiagID, &Msg, 1, &Range,1); return true; } diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index fa8ba5953c..30ada28d8b 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -160,19 +160,19 @@ bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1, return true; } -bool Sema::Diag(SourceLocation Loc, unsigned DiagID, SourceRange Range) { +bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const SourceRange& Range) { PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, 0, 0, &Range,1); return true; } bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg, - SourceRange Range) { + const SourceRange& Range) { PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, &Msg, 1, &Range,1); return true; } bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1, - const std::string &Msg2, SourceRange Range) { + const std::string &Msg2, const SourceRange& Range) { std::string MsgArr[] = { Msg1, Msg2 }; PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, MsgArr, 2, &Range, 1); return true; @@ -180,28 +180,29 @@ bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1, bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1, const std::string &Msg2, const std::string &Msg3, - SourceRange R1) { + const SourceRange& R1) { std::string MsgArr[] = { Msg1, Msg2, Msg3 }; PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, MsgArr, 3, &R1, 1); return true; } bool Sema::Diag(SourceLocation Loc, unsigned DiagID, - SourceRange R1, SourceRange R2) { + const SourceRange& R1, const SourceRange& R2) { SourceRange RangeArr[] = { R1, R2 }; PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, 0, 0, RangeArr, 2); return true; } bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg, - SourceRange R1, SourceRange R2) { + const SourceRange& R1, const SourceRange& R2) { SourceRange RangeArr[] = { R1, R2 }; PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, &Msg, 1, RangeArr, 2); return true; } bool Sema::Diag(SourceLocation Range, unsigned DiagID, const std::string &Msg1, - const std::string &Msg2, SourceRange R1, SourceRange R2) { + const std::string &Msg2, const SourceRange& R1, + const SourceRange& R2) { std::string MsgArr[] = { Msg1, Msg2 }; SourceRange RangeArr[] = { R1, R2 }; PP.getDiagnostics().Report(PP.getFullLoc(Range),DiagID, MsgArr,2,RangeArr, 2); diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index c5ab94a7e4..4bfbcb9939 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -179,20 +179,21 @@ public: const std::string &Msg2); /// More expressive diagnostic helpers for expressions (say that 6 times:-) - bool Diag(SourceLocation Loc, unsigned DiagID, SourceRange R1); + bool Diag(SourceLocation Loc, unsigned DiagID, const SourceRange& R1); bool Diag(SourceLocation Loc, unsigned DiagID, - SourceRange R1, SourceRange R2); + const SourceRange& R1, const SourceRange& R2); bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg, - SourceRange R1); + const SourceRange& R1); bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg, - SourceRange R1, SourceRange R2); + const SourceRange& R1, const SourceRange& R2); bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1, - const std::string &Msg2, SourceRange R1); + const std::string &Msg2, const SourceRange& R1); bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1, - const std::string &Msg2, const std::string &Msg3, SourceRange R1); + const std::string &Msg2, const std::string &Msg3, + const SourceRange& R1); bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1, const std::string &Msg2, - SourceRange R1, SourceRange R2); + const SourceRange& R1, const SourceRange& R2); virtual void DeleteExpr(ExprTy *E); virtual void DeleteStmt(StmtTy *S);