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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59494 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index 6495949..5ea27c9 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -176,13 +176,14 @@
}
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 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, 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;