Skip to content
Snippets Groups Projects
Commit d5e04a5d authored by Alp Toker's avatar Alp Toker
Browse files

Fix another misuse of getCustomDiagID()

There's no need to escape strings and generate new DiagIDs for each message.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197915 91177308-0d34-0410-b5e6-96231b3b80d8
parent 13573a93
No related branches found
No related tags found
No related merge requests found
...@@ -103,35 +103,25 @@ public: ...@@ -103,35 +103,25 @@ public:
IncludePath = true; IncludePath = true;
} }
void emitDiag(SourceLocation L, unsigned DiagID, const DiagnosticBuilder &addRanges(const DiagnosticBuilder &DB,
ArrayRef<SourceRange> Ranges) { ArrayRef<SourceRange> Ranges) {
DiagnosticBuilder DiagBuilder = Diag.Report(L, DiagID);
for (ArrayRef<SourceRange>::iterator I = Ranges.begin(), E = Ranges.end(); for (ArrayRef<SourceRange>::iterator I = Ranges.begin(), E = Ranges.end();
I != E; ++I) { I != E; ++I)
DiagBuilder << *I; DB << *I;
} return DB;
} }
void FlushDiagnosticsImpl(std::vector<const PathDiagnostic *> &Diags, void FlushDiagnosticsImpl(std::vector<const PathDiagnostic *> &Diags,
FilesMade *filesMade) { FilesMade *filesMade) {
unsigned WarnID = Diag.getCustomDiagID(DiagnosticsEngine::Warning, "%0");
unsigned NoteID = Diag.getCustomDiagID(DiagnosticsEngine::Note, "%0");
for (std::vector<const PathDiagnostic*>::iterator I = Diags.begin(), for (std::vector<const PathDiagnostic*>::iterator I = Diags.begin(),
E = Diags.end(); I != E; ++I) { E = Diags.end(); I != E; ++I) {
const PathDiagnostic *PD = *I; const PathDiagnostic *PD = *I;
StringRef desc = PD->getShortDescription(); SourceLocation WarnLoc = PD->getLocation().asLocation();
SmallString<512> TmpStr; addRanges(Diag.Report(WarnLoc, WarnID) << PD->getShortDescription(),
llvm::raw_svector_ostream Out(TmpStr); PD->path.back()->getRanges());
for (StringRef::iterator I=desc.begin(), E=desc.end(); I!=E; ++I) {
if (*I == '%')
Out << "%%";
else
Out << *I;
}
Out.flush();
unsigned ErrorDiag = Diag.getCustomDiagID(DiagnosticsEngine::Warning,
TmpStr);
SourceLocation L = PD->getLocation().asLocation();
emitDiag(L, ErrorDiag, PD->path.back()->getRanges());
if (!IncludePath) if (!IncludePath)
continue; continue;
...@@ -140,11 +130,9 @@ public: ...@@ -140,11 +130,9 @@ public:
for (PathPieces::const_iterator PI = FlatPath.begin(), for (PathPieces::const_iterator PI = FlatPath.begin(),
PE = FlatPath.end(); PE = FlatPath.end();
PI != PE; ++PI) { PI != PE; ++PI) {
unsigned NoteID = Diag.getCustomDiagID(DiagnosticsEngine::Note,
(*PI)->getString());
SourceLocation NoteLoc = (*PI)->getLocation().asLocation(); SourceLocation NoteLoc = (*PI)->getLocation().asLocation();
emitDiag(NoteLoc, NoteID, (*PI)->getRanges()); addRanges(Diag.Report(NoteLoc, NoteID) << (*PI)->getString(),
(*PI)->getRanges());
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment