Remove diff pedantic mode.

llvm-svn: 305818
This commit is contained in:
Zachary Turner 2017-06-20 18:50:30 +00:00
parent 7a482e2302
commit ed130b6ac0
3 changed files with 95 additions and 195 deletions

View File

@ -198,17 +198,6 @@ Error DiffStyle::diffSuperBlock() {
File2.getBlockCount());
Diffs |= diffAndPrint("Unknown 1", File1, File2, File1.getUnknown1(),
File2.getUnknown1());
if (opts::diff::Pedantic) {
Diffs |= diffAndPrint("Free Block Map", File1, File2,
File1.getFreeBlockMapBlock(),
File2.getFreeBlockMapBlock());
Diffs |= diffAndPrint("Directory Size", File1, File2,
File1.getNumDirectoryBytes(),
File2.getNumDirectoryBytes());
Diffs |= diffAndPrint("Block Map Addr", File1, File2,
File1.getBlockMapOffset(), File2.getBlockMapOffset());
}
if (!Diffs)
outs() << "MSF Super Block: No differences detected...\n";
return Error::success();
@ -222,47 +211,6 @@ Error DiffStyle::diffStreamDirectory() {
outs() << "Stream Directory: Searching for differences...\n";
bool HasDifferences = false;
if (opts::diff::Pedantic) {
size_t Min = std::min(P.size(), Q.size());
for (size_t I = 0; I < Min; ++I) {
StringRef Names[] = {P[I], Q[I]};
uint32_t Sizes[] = {File1.getStreamByteSize(I),
File2.getStreamByteSize(I)};
bool NamesDiffer = Names[0] != Names[1];
bool SizesDiffer = Sizes[0] != Sizes[1];
if (NamesDiffer) {
HasDifferences = true;
outs().indent(2) << formatv("Stream {0} - {1}: {2}, {3}: {4}\n", I,
File1.getFilePath(), Names[0],
File2.getFilePath(), Names[1]);
continue;
}
if (SizesDiffer) {
HasDifferences = true;
outs().indent(2) << formatv(
"Stream {0} ({1}): {2}: {3} bytes, {4}: {5} bytes\n", I, Names[0],
File1.getFilePath(), Sizes[0], File2.getFilePath(), Sizes[1]);
continue;
}
}
ArrayRef<std::string> MaxNames = (P.size() > Q.size() ? P : Q);
size_t Max = std::max(P.size(), Q.size());
PDBFile &MaxFile = (P.size() > Q.size() ? File1 : File2);
StringRef MinFileName =
(P.size() < Q.size() ? File1.getFilePath() : File2.getFilePath());
for (size_t I = Min; I < Max; ++I) {
HasDifferences = true;
StringRef StreamName = MaxNames[I];
outs().indent(2) << formatv(
"Stream {0} - {1}: <not present>, {2}: Index {3}, {4} bytes\n",
StreamName, MinFileName, MaxFile.getFilePath(), I,
MaxFile.getStreamByteSize(I));
}
if (!HasDifferences)
outs() << "Stream Directory: No differences detected...\n";
} else {
auto PI = to_vector<32>(enumerate(P));
auto QI = to_vector<32>(enumerate(Q));
@ -291,8 +239,8 @@ Error DiffStyle::diffStreamDirectory() {
if (!OnlyQ.empty()) {
HasDifferences = true;
outs().indent(2) << formatv("{0} Streams(s) only in ({1})\n",
OnlyQ.size(), File2.getFilePath());
outs().indent(2) << formatv("{0} Streams(s) only in ({1})\n", OnlyQ.size(),
File2.getFilePath());
for (auto &Item : OnlyQ) {
outs().indent(4) << formatv("Stream {0} - {1}\n", Item.index(),
Item.value());
@ -320,8 +268,8 @@ Error DiffStyle::diffStreamDirectory() {
HasDifferences = true;
HasCommonDifferences = true;
outs().indent(4) << formatv("{0} ({1}: {2} bytes, {3}: {4} bytes)\n",
Left.value(), File1.getFilePath(),
LeftSize, File2.getFilePath(), RightSize);
Left.value(), File1.getFilePath(), LeftSize,
File2.getFilePath(), RightSize);
}
}
if (!HasCommonDifferences)
@ -329,7 +277,6 @@ Error DiffStyle::diffStreamDirectory() {
}
if (!HasDifferences)
outs() << "Stream Directory: No differences detected!\n";
}
return Error::success();
}
@ -384,43 +331,6 @@ Error DiffStyle::diffStringTable() {
auto IdList1 = ST1.name_ids();
auto IdList2 = ST2.name_ids();
if (opts::diff::Pedantic) {
// In pedantic mode, we compare index by index (i.e. the strings are in the
// same order
// in both tables.
uint32_t Max = std::max(IdList1.size(), IdList2.size());
for (uint32_t I = 0; I < Max; ++I) {
Optional<uint32_t> Id1, Id2;
StringRef S1, S2;
if (I < IdList1.size()) {
Id1 = IdList1[I];
if (auto Result = ST1.getStringForID(*Id1))
S1 = *Result;
else
return Result.takeError();
}
if (I < IdList2.size()) {
Id2 = IdList2[I];
if (auto Result = ST2.getStringForID(*Id2))
S2 = *Result;
else
return Result.takeError();
}
if (Id1 == Id2 && S1 == S2)
continue;
std::string OutId1 =
Id1 ? formatv("{0}", *Id1).str() : "(index not present)";
std::string OutId2 =
Id2 ? formatv("{0}", *Id2).str() : "(index not present)";
outs() << formatv(" String {0}\n", I);
outs() << formatv(" {0}: Hash - {1}, Value - {2}\n",
File1.getFilePath(), OutId1, S1);
outs() << formatv(" {0}: Hash - {1}, Value - {2}\n",
File2.getFilePath(), OutId2, S2);
HasDiff = true;
}
} else {
std::vector<StringRef> Strings1, Strings2;
Strings1.reserve(IdList1.size());
Strings2.reserve(IdList2.size());
@ -455,7 +365,6 @@ Error DiffStyle::diffStringTable() {
outs() << formatv(" {0} had {1} more empty strings than {2}\n",
MoreF.getFilePath(), Difference, LessF.getFilePath());
}
}
if (!HasDiff)
outs() << "String Table: No differences detected!\n";
return Error::success();

View File

@ -256,11 +256,6 @@ cl::opt<bool> NoEnumDefs("no-enum-definitions",
}
namespace diff {
cl::opt<bool> Pedantic("pedantic",
cl::desc("Finds all differences (even structural ones "
"that produce otherwise identical PDBs)"),
cl::sub(DiffSubcommand));
cl::list<std::string> InputFilenames(cl::Positional,
cl::desc("<first> <second>"),
cl::OneOrMore, cl::sub(DiffSubcommand));

View File

@ -127,10 +127,6 @@ extern llvm::cl::opt<bool> DumpModuleFiles;
extern llvm::cl::opt<bool> RawAll;
}
namespace diff {
extern llvm::cl::opt<bool> Pedantic;
}
namespace pdb2yaml {
extern llvm::cl::opt<bool> All;
extern llvm::cl::opt<bool> NoFileHeaders;