diff options
| author | Chris Lattner <sabre@nondot.org> | 2007-05-16 17:49:37 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2007-05-16 17:49:37 +0000 |
| commit | 36982e4367adbc477d6dd88c2e3d68fa26cd420b (patch) | |
| tree | c40702695a8aa7655345dff4b21c1284b7e362cf /clang/Driver/clang.cpp | |
| parent | f8a28c5379c0a8d4b9276101e0116d79d0162550 (diff) | |
| download | bcm5719-llvm-36982e4367adbc477d6dd88c2e3d68fa26cd420b.tar.gz bcm5719-llvm-36982e4367adbc477d6dd88c2e3d68fa26cd420b.zip | |
Add support for inserting up to 10 strings in a diagnostic, with %0, %1, %2,
etc.
llvm-svn: 39447
Diffstat (limited to 'clang/Driver/clang.cpp')
| -rw-r--r-- | clang/Driver/clang.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/clang/Driver/clang.cpp b/clang/Driver/clang.cpp index 14256cbf400..dfc7a2af3be 100644 --- a/clang/Driver/clang.cpp +++ b/clang/Driver/clang.cpp @@ -347,7 +347,8 @@ public: virtual void HandleDiagnostic(Diagnostic::Level DiagLevel, SourceLocation Pos, - diag::kind ID, const std::string &Msg); + diag::kind ID, const std::string *Strs, + unsigned NumStrs); }; void DiagnosticPrinterSTDERR:: @@ -368,8 +369,9 @@ PrintIncludeStack(SourceLocation Pos) { void DiagnosticPrinterSTDERR::HandleDiagnostic(Diagnostic::Level Level, SourceLocation Pos, - diag::kind ID, - const std::string &Extra) { + diag::kind ID, + const std::string *Strs, + unsigned NumStrs) { unsigned LineNo = 0, FilePos = 0, FileID = 0, ColNo = 0; unsigned LineStart = 0, LineEnd = 0; const MemoryBuffer *Buffer = 0; @@ -432,14 +434,13 @@ void DiagnosticPrinterSTDERR::HandleDiagnostic(Diagnostic::Level Level, std::string Msg = Diagnostic::getDescription(ID); - // Replace all instances of %s in Msg with 'Extra'. - if (Msg.size() > 1) { - for (unsigned i = 0; i < Msg.size()-1; ++i) { - if (Msg[i] == '%' && Msg[i+1] == 's') { - Msg = std::string(Msg.begin(), Msg.begin()+i) + - Extra + - std::string(Msg.begin()+i+2, Msg.end()); - } + // Replace all instances of %0 in Msg with 'Extra'. + 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>>>") + + std::string(Msg.begin()+i+2, Msg.end()); } } std::cerr << Msg << "\n"; |

