[analyzer] Fix a crash in plist-html generation introduced in r162939.

Basically, do the correct thing to fix the XML generation error, rather
than making it even worse by unilaterally dereferencing a null pointer.

llvm-svn: 162964
This commit is contained in:
Jordan Rose 2012-08-31 00:36:20 +00:00
parent e423e865fe
commit 7444f5d826
1 changed files with 13 additions and 12 deletions

View File

@ -500,21 +500,22 @@ void PlistDiagnostics::FlushDiagnosticsImpl(
if (!filesMade->empty()) {
StringRef lastName;
PDFileEntry::ConsumerFiles *files = filesMade->getFiles(*D);
for (PDFileEntry::ConsumerFiles::const_iterator CI = files->begin(),
CE = files->end(); CI != CE; ++CI) {
StringRef newName = CI->first;
if (newName != lastName) {
if (!lastName.empty()) {
o << " </array>\n";
if (files) {
for (PDFileEntry::ConsumerFiles::const_iterator CI = files->begin(),
CE = files->end(); CI != CE; ++CI) {
StringRef newName = CI->first;
if (newName != lastName) {
if (!lastName.empty()) {
o << " </array>\n";
}
lastName = newName;
o << " <key>" << lastName << "_files</key>\n";
o << " <array>\n";
}
lastName = newName;
o << " <key>" << lastName << "_files</key>\n";
o << " <array>\n";
o << " <string>" << CI->second << "</string>\n";
}
o << " <string>" << CI->second << "</string>\n";
}
if (!lastName.empty())
o << " </array>\n";
}
}
// Close up the entry.