diff options
author | Chris Lattner <sabre@nondot.org> | 2008-11-18 07:04:44 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-11-18 07:04:44 +0000 |
commit | 0a14eee528a901c16f0e288fbc10a3abc1660d87 (patch) | |
tree | 1c6a7acf8be19bebf1f390638bfa52045a7dcf97 /lib | |
parent | 46bbacac37141ed9d01d5b6473e8211554b02710 (diff) |
This reworks some of the Diagnostic interfaces a bit to change how diagnostics
are formed. In particular, a diagnostic with all its strings and ranges is now
packaged up and sent to DiagnosticClients as a DiagnosticInfo instead of as a
ton of random stuff. This has the benefit of simplifying the interface, making
it more extensible, and allowing us to do more checking for things like access
past the end of the various arrays passed in.
In addition to introducing DiagnosticInfo, this also substantially changes how
Diagnostic::Report works. Instead of being passed in all of the info required
to issue a diagnostic, Report now takes only the required info (a location and
ID) and returns a fresh DiagnosticInfo *by value*. The caller is then free to
stuff strings and ranges into the DiagnosticInfo with the << operator. When
the dtor runs on the DiagnosticInfo object (which should happen at the end of
the statement), the diagnostic is actually emitted with all of the accumulated
information. This is a somewhat tricky dance, but it means that the
accumulated DiagnosticInfo is allowed to keep pointers to other expression
temporaries without those pointers getting invalidated.
This is just the minimal change to get this stuff working, but this will allow
us to eliminate the zillions of variant "Diag" methods scattered throughout
(e.g.) sema. For example, instead of calling:
Diag(BuiltinLoc, diag::err_overload_no_match, typeNames,
SourceRange(BuiltinLoc, RParenLoc));
We will soon be able to just do:
Diag(BuiltinLoc, diag::err_overload_no_match)
<< typeNames << SourceRange(BuiltinLoc, RParenLoc));
This scales better to support arbitrary types being passed in (not just
strings) in a type-safe way. Go operator overloading?!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59502 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/BugReporter.cpp | 35 | ||||
-rw-r--r-- | lib/Analysis/PathDiagnostic.cpp | 23 | ||||
-rw-r--r-- | lib/Basic/Diagnostic.cpp | 52 | ||||
-rw-r--r-- | lib/CodeGen/CGObjC.cpp | 5 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 9 | ||||
-rw-r--r-- | lib/Driver/TextDiagnosticBuffer.cpp | 25 | ||||
-rw-r--r-- | lib/Driver/TextDiagnosticPrinter.cpp | 22 | ||||
-rw-r--r-- | lib/Lex/Preprocessor.cpp | 12 | ||||
-rw-r--r-- | lib/Parse/DeclSpec.cpp | 5 | ||||
-rw-r--r-- | lib/Parse/Parser.cpp | 9 | ||||
-rw-r--r-- | lib/Sema/Sema.cpp | 36 |
11 files changed, 94 insertions, 139 deletions
diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp index bf99e6ba63..0074a93b5b 100644 --- a/lib/Analysis/BugReporter.cpp +++ b/lib/Analysis/BugReporter.cpp @@ -773,21 +773,26 @@ void BugReporter::EmitWarning(BugReport& R) { D->push_back(piece); PD->HandlePathDiagnostic(D.take()); + return; } else { - std::ostringstream os; + std::string str; if (D->empty()) - os << R.getDescription(); + str = R.getDescription(); else - os << D->back()->getString(); - + str = D->back()->getString(); Diagnostic& Diag = getDiagnostic(); - unsigned ErrorDiag = Diag.getCustomDiagID(Diagnostic::Warning, - os.str().c_str()); - - Diag.Report(L, ErrorDiag, NULL, 0, Beg, End - Beg); + unsigned ErrorDiag = Diag.getCustomDiagID(Diagnostic::Warning, str.c_str()); + + switch (End-Beg) { + default: assert(0 && "Don't handle this many ranges yet!"); + case 0: Diag.Report(L, ErrorDiag); break; + case 1: Diag.Report(L, ErrorDiag) << Beg[0]; break; + case 2: Diag.Report(L, ErrorDiag) << Beg[0] << Beg[1]; break; + case 3: Diag.Report(L, ErrorDiag) << Beg[0] << Beg[1] << Beg[2]; break; + } } } @@ -807,9 +812,17 @@ void BugReporter::EmitBasicReport(const char* name, const char* category, DiagnosticClient *OldClient = Diag.getClient(); Diag.setClient(&C); - Diag.Report(getContext().getFullLoc(Loc), - Diag.getCustomDiagID(Diagnostic::Warning, str), - 0, 0, RBeg, NumRanges); + FullSourceLoc L = getContext().getFullLoc(Loc); + unsigned DiagID = Diag.getCustomDiagID(Diagnostic::Warning, str); + + switch (NumRanges) { + default: assert(0 && "Don't handle this many ranges yet!"); + case 0: Diag.Report(L, DiagID); break; + case 1: Diag.Report(L, DiagID) << RBeg[0]; break; + case 2: Diag.Report(L, DiagID) << RBeg[0] << RBeg[1]; break; + case 3: Diag.Report(L, DiagID) << RBeg[0] << RBeg[1] << RBeg[2]; break; + } + Diag.setClient(OldClient); for (DiagCollector::iterator I = C.begin(), E = C.end(); I != E; ++I) diff --git a/lib/Analysis/PathDiagnostic.cpp b/lib/Analysis/PathDiagnostic.cpp index 02cfe1e341..aed83ea84f 100644 --- a/lib/Analysis/PathDiagnostic.cpp +++ b/lib/Analysis/PathDiagnostic.cpp @@ -20,14 +20,8 @@ PathDiagnostic::~PathDiagnostic() { for (iterator I = begin(), E = end(); I != E; ++I) delete &*I; } -void PathDiagnosticClient::HandleDiagnostic(Diagnostic &Diags, - Diagnostic::Level DiagLevel, - FullSourceLoc Pos, - diag::kind ID, - const std::string **Strs, - unsigned NumStrs, - const SourceRange *Ranges, - unsigned NumRanges) { +void PathDiagnosticClient::HandleDiagnostic(Diagnostic::Level DiagLevel, + const DiagnosticInfo &Info) { // Create a PathDiagnostic with a single piece. @@ -42,16 +36,13 @@ void PathDiagnosticClient::HandleDiagnostic(Diagnostic &Diags, case Diagnostic::Fatal: LevelStr = "fatal error: "; break; } - std::string Msg = FormatDiagnostic(Diags, DiagLevel, ID, Strs, NumStrs); + std::string Msg = FormatDiagnostic(Info); - PathDiagnosticPiece* P = new PathDiagnosticPiece(Pos, LevelStr+Msg); - - while (NumRanges) { - P->addRange(*Ranges); - --NumRanges; - ++Ranges; - } + PathDiagnosticPiece *P = + new PathDiagnosticPiece(Info.getLocation(), LevelStr+Msg); + for (unsigned i = 0, e = Info.getNumRanges(); i != e; ++i) + P->addRange(Info.getRange(i)); D->push_front(P); HandlePathDiagnostic(D); diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp index 2076b16db0..a202a55f26 100644 --- a/lib/Basic/Diagnostic.cpp +++ b/lib/Basic/Diagnostic.cpp @@ -127,6 +127,7 @@ Diagnostic::Diagnostic(DiagnosticClient *client) : Client(client) { NumDiagnostics = 0; NumErrors = 0; CustomDiagInfo = 0; + NumDiagArgs = -1; } Diagnostic::~Diagnostic() { @@ -154,7 +155,7 @@ bool Diagnostic::isBuiltinNoteWarningOrExtension(unsigned DiagID) { /// getDescription - Given a diagnostic ID, return a description of the /// issue. -const char *Diagnostic::getDescription(unsigned DiagID) { +const char *Diagnostic::getDescription(unsigned DiagID) const { if (DiagID < diag::NUM_BUILTIN_DIAGNOSTICS) return DiagnosticText[DiagID]; else @@ -210,66 +211,51 @@ Diagnostic::Level Diagnostic::getDiagnosticLevel(unsigned DiagID) const { } } -/// Report - Issue the message to the client. -/// DiagID is a member of the diag::kind enum. -void Diagnostic::Report(DiagnosticClient* C, - FullSourceLoc Loc, unsigned DiagID, - const std::string **Strs, unsigned NumStrs, - const SourceRange *Ranges, unsigned NumRanges) { - +/// ProcessDiag - This is the method used to report a diagnostic that is +/// finally fully formed. +void Diagnostic::ProcessDiag(const DiagnosticInfo &Info) { // Figure out the diagnostic level of this message. - Diagnostic::Level DiagLevel = getDiagnosticLevel(DiagID); + Diagnostic::Level DiagLevel = getDiagnosticLevel(Info.getID()); // If the client doesn't care about this message, don't issue it. if (DiagLevel == Diagnostic::Ignored) return; - // Set the diagnostic client if it isn't set already. - if (!C) C = Client; - // If this is not an error and we are in a system header, ignore it. We - // have to check on the original DiagID here, because we also want to + // have to check on the original Diag ID here, because we also want to // ignore extensions and warnings in -Werror and -pedantic-errors modes, // which *map* warnings/extensions to errors. if (SuppressSystemWarnings && - DiagID < diag::NUM_BUILTIN_DIAGNOSTICS && - getBuiltinDiagClass(DiagID) != ERROR && - Loc.isValid() && Loc.getPhysicalLoc().isInSystemHeader()) + Info.getID() < diag::NUM_BUILTIN_DIAGNOSTICS && + getBuiltinDiagClass(Info.getID()) != ERROR && + Info.getLocation().isValid() && + Info.getLocation().getPhysicalLoc().isInSystemHeader()) return; if (DiagLevel >= Diagnostic::Error) { ErrorOccurred = true; - if (C != 0 && C == Client) - ++NumErrors; + ++NumErrors; } // Finally, report it. - - if (C != 0) - C->HandleDiagnostic(*this, DiagLevel, Loc, (diag::kind)DiagID, - Strs, NumStrs, Ranges, NumRanges); - - if (C != 0 && C == Client) - ++NumDiagnostics; + Client->HandleDiagnostic(DiagLevel, Info); + ++NumDiagnostics; } DiagnosticClient::~DiagnosticClient() {} -std::string DiagnosticClient::FormatDiagnostic(Diagnostic &Diags, - Diagnostic::Level Level, - diag::kind ID, - const std::string **Strs, - unsigned NumStrs) { - std::string Msg = Diags.getDescription(ID); +std::string DiagnosticClient::FormatDiagnostic(const DiagnosticInfo &Info) { + std::string Msg = Info.getDiags()->getDescription(Info.getID()); - // Replace all instances of %0 in Msg with 'Extra'. + // Replace all instances of %0 in Msg with 'Extra'. This is a pretty horrible + // and inefficient way to do this, we could improve this a lot if we care. for (unsigned i = 0; i < Msg.size() - 1; ++i) { if (Msg[i] == '%' && isdigit(Msg[i + 1])) { unsigned StrNo = Msg[i + 1] - '0'; Msg = std::string(Msg.begin(), Msg.begin() + i) + - (StrNo < NumStrs ? *Strs[StrNo] : "<<<INTERNAL ERROR>>>") + + Info.getArgStr(StrNo) + std::string(Msg.begin() + i + 2, Msg.end()); } } diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp index 058278cfa4..044368c699 100644 --- a/lib/CodeGen/CGObjC.cpp +++ b/lib/CodeGen/CGObjC.cpp @@ -303,10 +303,9 @@ void CodeGenFunction::EmitObjCPropertySet(const ObjCPropertyRefExpr *E, S = Setter->getSelector(); } else { // FIXME: This should be diagnosed by sema. - SourceRange Range = E->getSourceRange(); CGM.getDiags().Report(getContext().getFullLoc(E->getLocStart()), - diag::err_typecheck_assign_const, 0, 0, - &Range, 1); + diag::err_typecheck_assign_const) + << E->getSourceRange(); return; } } else { diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index d7d732997b..3e146215f4 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -106,11 +106,9 @@ void CodeGenModule::ErrorUnsupported(const Stmt *S, const char *Type, return; unsigned DiagID = getDiags().getCustomDiagID(Diagnostic::Error, "cannot codegen this %0 yet"); - SourceRange Range = S->getSourceRange(); std::string Msg = Type; - const std::string *Strs[] = { &Msg }; - getDiags().Report(Context.getFullLoc(S->getLocStart()), DiagID, - Strs, 1, &Range, 1); + getDiags().Report(Context.getFullLoc(S->getLocStart()), DiagID) + << Msg << S->getSourceRange(); } /// ErrorUnsupported - Print out an error that codegen doesn't support the @@ -122,8 +120,7 @@ void CodeGenModule::ErrorUnsupported(const Decl *D, const char *Type, unsigned DiagID = getDiags().getCustomDiagID(Diagnostic::Error, "cannot codegen this %0 yet"); std::string Msg = Type; - const std::string *Strs[] = { &Msg }; - getDiags().Report(Context.getFullLoc(D->getLocation()), DiagID, Strs, 1); + getDiags().Report(Context.getFullLoc(D->getLocation()), DiagID) << Msg; } /// setGlobalVisibility - Set the visibility for the given LLVM diff --git a/lib/Driver/TextDiagnosticBuffer.cpp b/lib/Driver/TextDiagnosticBuffer.cpp index ef7ac6d408..b138b1a24d 100644 --- a/lib/Driver/TextDiagnosticBuffer.cpp +++ b/lib/Driver/TextDiagnosticBuffer.cpp @@ -17,30 +17,21 @@ using namespace clang; /// HandleDiagnostic - Store the errors, warnings, and notes that are /// reported. /// -void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic &Diags, - Diagnostic::Level Level, - FullSourceLoc Pos, - diag::kind ID, - const std::string **Strs, - unsigned NumStrs, - const SourceRange *, - unsigned) { +void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic::Level Level, + const DiagnosticInfo &Info) { switch (Level) { default: assert(0 && "Diagnostic not handled during diagnostic buffering!"); case Diagnostic::Note: - Notes.push_back(std::make_pair(Pos.getLocation(), - FormatDiagnostic(Diags, Level, ID, - Strs, NumStrs))); + Notes.push_back(std::make_pair(Info.getLocation().getLocation(), + FormatDiagnostic(Info))); break; case Diagnostic::Warning: - Warnings.push_back(std::make_pair(Pos.getLocation(), - FormatDiagnostic(Diags, Level, ID, - Strs, NumStrs))); + Warnings.push_back(std::make_pair(Info.getLocation().getLocation(), + FormatDiagnostic(Info))); break; case Diagnostic::Error: - Errors.push_back(std::make_pair(Pos.getLocation(), - FormatDiagnostic(Diags, Level, ID, - Strs, NumStrs))); + Errors.push_back(std::make_pair(Info.getLocation().getLocation(), + FormatDiagnostic(Info))); break; } } diff --git a/lib/Driver/TextDiagnosticPrinter.cpp b/lib/Driver/TextDiagnosticPrinter.cpp index e03588b989..3b8ec10ec8 100644 --- a/lib/Driver/TextDiagnosticPrinter.cpp +++ b/lib/Driver/TextDiagnosticPrinter.cpp @@ -34,7 +34,7 @@ PrintIncludeStack(FullSourceLoc Pos) { /// HighlightRange - Given a SourceRange and a line number, highlight (with ~'s) /// any characters in LineNo that intersect the SourceRange. void TextDiagnosticPrinter::HighlightRange(const SourceRange &R, - SourceManager& SourceMgr, + const SourceManager& SourceMgr, unsigned LineNo, unsigned FileID, std::string &CaretLine, const std::string &SourceLine) { @@ -92,17 +92,12 @@ void TextDiagnosticPrinter::HighlightRange(const SourceRange &R, CaretLine[i] = '~'; } -void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic &Diags, - Diagnostic::Level Level, - FullSourceLoc Pos, - diag::kind ID, - const std::string **Strs, - unsigned NumStrs, - const SourceRange *Ranges, - unsigned NumRanges) { +void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, + const DiagnosticInfo &Info) { unsigned LineNo = 0, ColNo = 0; unsigned FileID = 0; const char *LineStart = 0, *LineEnd = 0; + const FullSourceLoc &Pos = Info.getLocation(); if (Pos.isValid()) { FullSourceLoc LPos = Pos.getLogicalLoc(); @@ -146,9 +141,10 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic &Diags, break; } - OS << FormatDiagnostic(Diags, Level, ID, Strs, NumStrs) << "\n"; + OS << FormatDiagnostic(Info) << "\n"; - if (CaretDiagnostics && Pos.isValid() && ((LastLoc != Pos) || Ranges)) { + if (CaretDiagnostics && Pos.isValid() && ((LastLoc != Pos) || + Info.getNumRanges())) { // Cache the LastLoc, it allows us to omit duplicate source/caret spewage. LastLoc = Pos; @@ -160,8 +156,8 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic &Diags, std::string CaretLine(LineEnd-LineStart, ' '); // Highlight all of the characters covered by Ranges with ~ characters. - for (unsigned i = 0; i != NumRanges; ++i) - HighlightRange(Ranges[i], Pos.getManager(), LineNo, FileID, + for (unsigned i = 0; i != Info.getNumRanges(); ++i) + HighlightRange(Info.getRange(i), Pos.getManager(), LineNo, FileID, CaretLine, SourceLine); // Next, insert the caret itself. diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index dc4dd877b6..3357791b6c 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -124,28 +124,24 @@ void Preprocessor::Diag(SourceLocation Loc, unsigned DiagID) { void Preprocessor::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg) { - const std::string *Strs[] = { &Msg }; - Diags.Report(getFullLoc(Loc), DiagID, Strs, 1); + Diags.Report(getFullLoc(Loc), DiagID) << Msg; } void Preprocessor::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg, const SourceRange &R1, const SourceRange &R2) { - const std::string *Strs[] = { &Msg }; - SourceRange R[] = {R1, R2}; - Diags.Report(getFullLoc(Loc), DiagID, Strs, 1, R, 2); + Diags.Report(getFullLoc(Loc), DiagID) << Msg << R1 << R2; } void Preprocessor::Diag(SourceLocation Loc, unsigned DiagID, const SourceRange &R) { - Diags.Report(getFullLoc(Loc), DiagID, 0, 0, &R, 1); + Diags.Report(getFullLoc(Loc), DiagID) << R; } void Preprocessor::Diag(SourceLocation Loc, unsigned DiagID, const SourceRange &R1, const SourceRange &R2) { - SourceRange R[] = {R1, R2}; - Diags.Report(getFullLoc(Loc), DiagID, 0, 0, R, 2); + Diags.Report(getFullLoc(Loc), DiagID) << R1 << R2; } diff --git a/lib/Parse/DeclSpec.cpp b/lib/Parse/DeclSpec.cpp index 733c37cb4f..c497108471 100644 --- a/lib/Parse/DeclSpec.cpp +++ b/lib/Parse/DeclSpec.cpp @@ -311,7 +311,6 @@ void DeclSpec::Diag(Diagnostic &D, SourceLocation Loc, SourceManager& SrcMgr, } void DeclSpec::Diag(Diagnostic &D, SourceLocation Loc, SourceManager& SrcMgr, - unsigned DiagID, const std::string &Info) { - const std::string *Strs[] = { &Info }; - D.Report(FullSourceLoc(Loc,SrcMgr), DiagID, Strs, 1); + unsigned DiagID, const std::string &Info) { + D.Report(FullSourceLoc(Loc,SrcMgr), DiagID) << Info; } diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index dfabc9b16a..a9ce22d047 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -43,21 +43,18 @@ Action::~Action() {} bool Parser::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg) { - const std::string *Strs[] = { &Msg }; - Diags.Report(FullSourceLoc(Loc,PP.getSourceManager()), DiagID, Strs, 1); + Diags.Report(FullSourceLoc(Loc,PP.getSourceManager()), DiagID) << Msg; return true; } bool Parser::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg, const SourceRange& Range) { - const std::string *Strs[] = { &Msg }; - Diags.Report(PP.getFullLoc(Loc), DiagID, Strs, 1, &Range,1); + Diags.Report(PP.getFullLoc(Loc), DiagID) << Msg << Range; return true; } bool Parser::Diag(SourceLocation Loc, unsigned DiagID, const SourceRange &R) { - Diags.Report(FullSourceLoc(Loc,PP.getSourceManager()), DiagID, 0, 0, - &R, 1); + Diags.Report(FullSourceLoc(Loc,PP.getSourceManager()), DiagID) << R; return true; } diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 5ea27c979b..c064e2448b 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -18,11 +18,9 @@ #include "clang/AST/Expr.h" #include "clang/Lex/Preprocessor.h" #include "clang/Basic/Diagnostic.h" - using namespace clang; -static inline RecordDecl *CreateStructDecl(ASTContext &C, const char *Name) -{ +static inline RecordDecl *CreateStructDecl(ASTContext &C, const char *Name) { if (C.getLangOptions().CPlusPlus) return CXXRecordDecl::Create(C, TagDecl::TK_struct, C.getTranslationUnitDecl(), @@ -176,66 +174,58 @@ bool Sema::Diag(SourceLocation Loc, unsigned DiagID) { } bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg) { - const std::string *Strs[] = { &Msg }; - PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, Strs, 1); + PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID) << Msg; return true; } bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1, const std::string &Msg2) { - const std::string *MsgArr[] = { &Msg1, &Msg2 }; - PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, MsgArr, 2); + PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID) << Msg1 << Msg2; return true; } bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const SourceRange& Range) { - PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, 0, 0, &Range,1); + PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID) << Range; return true; } bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg, const SourceRange& Range) { - const std::string *Strs[] = { &Msg }; - PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, Strs, 1, &Range,1); + PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID) << Msg << Range; return true; } bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1, - const std::string &Msg2, const SourceRange& Range) { - const std::string *MsgArr[] = { &Msg1, &Msg2 }; - PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, MsgArr, 2, &Range, 1); + const std::string &Msg2, const SourceRange &R) { + PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID) << Msg1 << Msg2 << R; return true; } bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1, const std::string &Msg2, const std::string &Msg3, const SourceRange &R1) { - const std::string *MsgArr[] = { &Msg1, &Msg2, &Msg3 }; - PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, MsgArr, 3, &R1, 1); + PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID) + << Msg1 << Msg2 << Msg3 << R1; return true; } bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const SourceRange& R1, const SourceRange& R2) { - SourceRange RangeArr[] = { R1, R2 }; - PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, 0, 0, RangeArr, 2); + PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID) << R1 << R2; return true; } bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg, const SourceRange& R1, const SourceRange& R2) { - SourceRange RangeArr[] = { R1, R2 }; - const std::string *Strs[] = { &Msg }; - PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, Strs, 1, RangeArr, 2); + PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID) << Msg << R1 << R2; return true; } bool Sema::Diag(SourceLocation Range, unsigned DiagID, const std::string &Msg1, const std::string &Msg2, const SourceRange& R1, const SourceRange& R2) { - const std::string *MsgArr[] = { &Msg1, &Msg2 }; - SourceRange RangeArr[] = { R1, R2 }; - PP.getDiagnostics().Report(PP.getFullLoc(Range),DiagID, MsgArr,2,RangeArr, 2); + PP.getDiagnostics().Report(PP.getFullLoc(Range),DiagID) + << Msg1 << Msg2 << R1 << R2; return true; } |