forked from OSchip/llvm-project
Change the diagnostics interface to take an array of pointers to
strings instead of array of strings. This reduces string copying in some not-very-important cases, but paves the way for future improvements. llvm-svn: 59494
This commit is contained in:
parent
95d3d1094f
commit
16ba91396a
|
@ -201,7 +201,7 @@ public:
|
|||
Diagnostic::Level DiagLevel,
|
||||
FullSourceLoc Pos,
|
||||
diag::kind ID,
|
||||
const std::string *Strs,
|
||||
const std::string **Strs,
|
||||
unsigned NumStrs,
|
||||
const SourceRange *Ranges,
|
||||
unsigned NumRanges);
|
||||
|
|
|
@ -307,7 +307,7 @@ public:
|
|||
Diagnostic::Level DiagLevel,
|
||||
FullSourceLoc Pos,
|
||||
diag::kind ID,
|
||||
const std::string *Strs,
|
||||
const std::string **Strs,
|
||||
unsigned NumStrs,
|
||||
const SourceRange *Ranges,
|
||||
unsigned NumRanges) {
|
||||
|
@ -322,7 +322,7 @@ public:
|
|||
R.addRange(*Ranges);
|
||||
|
||||
for ( ; NumStrs ; --NumStrs, ++Strs)
|
||||
R.addString(*Strs);
|
||||
R.addString(**Strs);
|
||||
}
|
||||
|
||||
// Iterators.
|
||||
|
|
|
@ -165,7 +165,7 @@ public:
|
|||
/// Report - Issue the message to the client. DiagID is a member of the
|
||||
/// diag::kind enum.
|
||||
void Report(FullSourceLoc Pos, unsigned DiagID,
|
||||
const std::string *Strs = 0, unsigned NumStrs = 0,
|
||||
const std::string **Strs = 0, unsigned NumStrs = 0,
|
||||
const SourceRange *Ranges = 0, unsigned NumRanges = 0) {
|
||||
Report(NULL, Pos, DiagID, Strs, NumStrs, Ranges, NumRanges);
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ public:
|
|||
/// Report - Issue the message to the client. DiagID is a member of the
|
||||
/// diag::kind enum.
|
||||
void Report(unsigned DiagID,
|
||||
const std::string *Strs = 0, unsigned NumStrs = 0,
|
||||
const std::string **Strs = 0, unsigned NumStrs = 0,
|
||||
const SourceRange *Ranges = 0, unsigned NumRanges = 0) {
|
||||
Report(FullSourceLoc(), DiagID, Strs, NumStrs, Ranges, NumRanges);
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ public:
|
|||
/// Report - Issue the message to the specified client.
|
||||
/// DiagID is a member of the diag::kind enum.
|
||||
void Report(DiagnosticClient* C, FullSourceLoc Pos, unsigned DiagID,
|
||||
const std::string *Strs = 0, unsigned NumStrs = 0,
|
||||
const std::string **Strs = 0, unsigned NumStrs = 0,
|
||||
const SourceRange *Ranges = 0, unsigned NumRanges = 0);
|
||||
};
|
||||
|
||||
|
@ -191,8 +191,7 @@ class DiagnosticClient {
|
|||
protected:
|
||||
std::string FormatDiagnostic(Diagnostic &Diags, Diagnostic::Level Level,
|
||||
diag::kind ID,
|
||||
const std::string *Strs,
|
||||
unsigned NumStrs);
|
||||
const std::string **Strs, unsigned NumStrs);
|
||||
public:
|
||||
virtual ~DiagnosticClient();
|
||||
|
||||
|
@ -202,7 +201,7 @@ public:
|
|||
Diagnostic::Level DiagLevel,
|
||||
FullSourceLoc Pos,
|
||||
diag::kind ID,
|
||||
const std::string *Strs,
|
||||
const std::string **Strs,
|
||||
unsigned NumStrs,
|
||||
const SourceRange *Ranges,
|
||||
unsigned NumRanges) = 0;
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
Diagnostic::Level DiagLevel,
|
||||
FullSourceLoc Pos,
|
||||
diag::kind ID,
|
||||
const std::string *Strs,
|
||||
const std::string **Strs,
|
||||
unsigned NumStrs,
|
||||
const SourceRange *Ranges,
|
||||
unsigned NumRanges);
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
Diagnostic::Level DiagLevel,
|
||||
FullSourceLoc Pos,
|
||||
diag::kind ID,
|
||||
const std::string *Strs,
|
||||
const std::string **Strs,
|
||||
unsigned NumStrs,
|
||||
const SourceRange *Ranges,
|
||||
unsigned NumRanges);
|
||||
|
|
|
@ -24,7 +24,7 @@ void PathDiagnosticClient::HandleDiagnostic(Diagnostic &Diags,
|
|||
Diagnostic::Level DiagLevel,
|
||||
FullSourceLoc Pos,
|
||||
diag::kind ID,
|
||||
const std::string *Strs,
|
||||
const std::string **Strs,
|
||||
unsigned NumStrs,
|
||||
const SourceRange *Ranges,
|
||||
unsigned NumRanges) {
|
||||
|
|
|
@ -214,7 +214,7 @@ Diagnostic::Level Diagnostic::getDiagnosticLevel(unsigned DiagID) const {
|
|||
/// 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 std::string **Strs, unsigned NumStrs,
|
||||
const SourceRange *Ranges, unsigned NumRanges) {
|
||||
|
||||
// Figure out the diagnostic level of this message.
|
||||
|
@ -260,7 +260,7 @@ DiagnosticClient::~DiagnosticClient() {}
|
|||
std::string DiagnosticClient::FormatDiagnostic(Diagnostic &Diags,
|
||||
Diagnostic::Level Level,
|
||||
diag::kind ID,
|
||||
const std::string *Strs,
|
||||
const std::string **Strs,
|
||||
unsigned NumStrs) {
|
||||
std::string Msg = Diags.getDescription(ID);
|
||||
|
||||
|
@ -269,7 +269,7 @@ std::string DiagnosticClient::FormatDiagnostic(Diagnostic &Diags,
|
|||
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>>>") +
|
||||
(StrNo < NumStrs ? *Strs[StrNo] : "<<<INTERNAL ERROR>>>") +
|
||||
std::string(Msg.begin() + i + 2, Msg.end());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,8 +108,9 @@ void CodeGenModule::ErrorUnsupported(const Stmt *S, const char *Type,
|
|||
"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,
|
||||
&Msg, 1, &Range, 1);
|
||||
Strs, 1, &Range, 1);
|
||||
}
|
||||
|
||||
/// ErrorUnsupported - Print out an error that codegen doesn't support the
|
||||
|
@ -121,8 +122,8 @@ void CodeGenModule::ErrorUnsupported(const Decl *D, const char *Type,
|
|||
unsigned DiagID = getDiags().getCustomDiagID(Diagnostic::Error,
|
||||
"cannot codegen this %0 yet");
|
||||
std::string Msg = Type;
|
||||
getDiags().Report(Context.getFullLoc(D->getLocation()), DiagID,
|
||||
&Msg, 1);
|
||||
const std::string *Strs[] = { &Msg };
|
||||
getDiags().Report(Context.getFullLoc(D->getLocation()), DiagID, Strs, 1);
|
||||
}
|
||||
|
||||
/// setGlobalVisibility - Set the visibility for the given LLVM
|
||||
|
|
|
@ -21,7 +21,7 @@ void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic &Diags,
|
|||
Diagnostic::Level Level,
|
||||
FullSourceLoc Pos,
|
||||
diag::kind ID,
|
||||
const std::string *Strs,
|
||||
const std::string **Strs,
|
||||
unsigned NumStrs,
|
||||
const SourceRange *,
|
||||
unsigned) {
|
||||
|
|
|
@ -96,7 +96,7 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic &Diags,
|
|||
Diagnostic::Level Level,
|
||||
FullSourceLoc Pos,
|
||||
diag::kind ID,
|
||||
const std::string *Strs,
|
||||
const std::string **Strs,
|
||||
unsigned NumStrs,
|
||||
const SourceRange *Ranges,
|
||||
unsigned NumRanges) {
|
||||
|
|
|
@ -124,14 +124,16 @@ void Preprocessor::Diag(SourceLocation Loc, unsigned DiagID) {
|
|||
|
||||
void Preprocessor::Diag(SourceLocation Loc, unsigned DiagID,
|
||||
const std::string &Msg) {
|
||||
Diags.Report(getFullLoc(Loc), DiagID, &Msg, 1);
|
||||
const std::string *Strs[] = { &Msg };
|
||||
Diags.Report(getFullLoc(Loc), DiagID, Strs, 1);
|
||||
}
|
||||
|
||||
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, &Msg, 1, R, 2);
|
||||
Diags.Report(getFullLoc(Loc), DiagID, Strs, 1, R, 2);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -311,6 +311,7 @@ void DeclSpec::Diag(Diagnostic &D, SourceLocation Loc, SourceManager& SrcMgr,
|
|||
}
|
||||
|
||||
void DeclSpec::Diag(Diagnostic &D, SourceLocation Loc, SourceManager& SrcMgr,
|
||||
unsigned DiagID, const std::string &info) {
|
||||
D.Report(FullSourceLoc(Loc,SrcMgr), DiagID, &info, 1);
|
||||
unsigned DiagID, const std::string &Info) {
|
||||
const std::string *Strs[] = { &Info };
|
||||
D.Report(FullSourceLoc(Loc,SrcMgr), DiagID, Strs, 1);
|
||||
}
|
||||
|
|
|
@ -43,13 +43,15 @@ Action::~Action() {}
|
|||
|
||||
bool Parser::Diag(SourceLocation Loc, unsigned DiagID,
|
||||
const std::string &Msg) {
|
||||
Diags.Report(FullSourceLoc(Loc,PP.getSourceManager()), DiagID, &Msg, 1);
|
||||
const std::string *Strs[] = { &Msg };
|
||||
Diags.Report(FullSourceLoc(Loc,PP.getSourceManager()), DiagID, Strs, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Parser::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg,
|
||||
const SourceRange& Range) {
|
||||
Diags.Report(PP.getFullLoc(Loc), DiagID, &Msg, 1, &Range,1);
|
||||
const std::string *Strs[] = { &Msg };
|
||||
Diags.Report(PP.getFullLoc(Loc), DiagID, Strs, 1, &Range,1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -176,13 +176,14 @@ bool Sema::Diag(SourceLocation Loc, unsigned DiagID) {
|
|||
}
|
||||
|
||||
bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg) {
|
||||
PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, &Msg, 1);
|
||||
const std::string *Strs[] = { &Msg };
|
||||
PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, Strs, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1,
|
||||
const std::string &Msg2) {
|
||||
std::string MsgArr[] = { Msg1, Msg2 };
|
||||
const std::string *MsgArr[] = { &Msg1, &Msg2 };
|
||||
PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, MsgArr, 2);
|
||||
return true;
|
||||
}
|
||||
|
@ -194,21 +195,22 @@ bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const SourceRange& Range) {
|
|||
|
||||
bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg,
|
||||
const SourceRange& Range) {
|
||||
PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, &Msg, 1, &Range,1);
|
||||
const std::string *Strs[] = { &Msg };
|
||||
PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, Strs, 1, &Range,1);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1,
|
||||
const std::string &Msg2, const SourceRange& Range) {
|
||||
std::string MsgArr[] = { Msg1, Msg2 };
|
||||
const std::string *MsgArr[] = { &Msg1, &Msg2 };
|
||||
PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, MsgArr, 2, &Range, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1,
|
||||
const std::string &Msg2, const std::string &Msg3,
|
||||
const SourceRange& R1) {
|
||||
std::string MsgArr[] = { Msg1, Msg2, Msg3 };
|
||||
const SourceRange &R1) {
|
||||
const std::string *MsgArr[] = { &Msg1, &Msg2, &Msg3 };
|
||||
PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, MsgArr, 3, &R1, 1);
|
||||
return true;
|
||||
}
|
||||
|
@ -223,14 +225,15 @@ bool Sema::Diag(SourceLocation Loc, unsigned DiagID,
|
|||
bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg,
|
||||
const SourceRange& R1, const SourceRange& R2) {
|
||||
SourceRange RangeArr[] = { R1, R2 };
|
||||
PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, &Msg, 1, RangeArr, 2);
|
||||
const std::string *Strs[] = { &Msg };
|
||||
PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, Strs, 1, RangeArr, 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Sema::Diag(SourceLocation Range, unsigned DiagID, const std::string &Msg1,
|
||||
const std::string &Msg2, const SourceRange& R1,
|
||||
const SourceRange& R2) {
|
||||
std::string MsgArr[] = { Msg1, Msg2 };
|
||||
const std::string *MsgArr[] = { &Msg1, &Msg2 };
|
||||
SourceRange RangeArr[] = { R1, R2 };
|
||||
PP.getDiagnostics().Report(PP.getFullLoc(Range),DiagID, MsgArr,2,RangeArr, 2);
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue