[llvm] r305818 - Remove diff pedantic mode.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 20 11:50:31 PDT 2017
Author: zturner
Date: Tue Jun 20 13:50:30 2017
New Revision: 305818
URL: http://llvm.org/viewvc/llvm-project?rev=305818&view=rev
Log:
Remove diff pedantic mode.
Modified:
llvm/trunk/tools/llvm-pdbutil/Diff.cpp
llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp
llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h
Modified: llvm/trunk/tools/llvm-pdbutil/Diff.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/Diff.cpp?rev=305818&r1=305817&r2=305818&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/Diff.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/Diff.cpp Tue Jun 20 13:50:30 2017
@@ -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,114 +211,72 @@ 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;
- }
- }
+ auto PI = to_vector<32>(enumerate(P));
+ auto QI = to_vector<32>(enumerate(Q));
- 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));
-
- typedef decltype(PI) ContainerType;
- typedef typename ContainerType::value_type value_type;
-
- auto Comparator = [](const value_type &I1, const value_type &I2) {
- return I1.value() < I2.value();
- };
-
- decltype(PI) OnlyP;
- decltype(QI) OnlyQ;
- decltype(PI) Common;
-
- set_differences(PI, QI, &OnlyP, &OnlyQ, &Common, Comparator);
-
- if (!OnlyP.empty()) {
- HasDifferences = true;
- outs().indent(2) << formatv("{0} Stream(s) only in ({1})\n", OnlyP.size(),
- File1.getFilePath());
- for (auto &Item : OnlyP) {
- outs().indent(4) << formatv("Stream {0} - {1}\n", Item.index(),
- Item.value());
- }
+ typedef decltype(PI) ContainerType;
+ typedef typename ContainerType::value_type value_type;
+
+ auto Comparator = [](const value_type &I1, const value_type &I2) {
+ return I1.value() < I2.value();
+ };
+
+ decltype(PI) OnlyP;
+ decltype(QI) OnlyQ;
+ decltype(PI) Common;
+
+ set_differences(PI, QI, &OnlyP, &OnlyQ, &Common, Comparator);
+
+ if (!OnlyP.empty()) {
+ HasDifferences = true;
+ outs().indent(2) << formatv("{0} Stream(s) only in ({1})\n", OnlyP.size(),
+ File1.getFilePath());
+ for (auto &Item : OnlyP) {
+ outs().indent(4) << formatv("Stream {0} - {1}\n", Item.index(),
+ Item.value());
}
+ }
- if (!OnlyQ.empty()) {
- HasDifferences = true;
- 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());
- }
+ if (!OnlyQ.empty()) {
+ HasDifferences = true;
+ 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());
}
- if (!Common.empty()) {
- outs().indent(2) << formatv("Found {0} common streams. Searching for "
- "intra-stream differences.\n",
- Common.size());
- bool HasCommonDifferences = false;
- for (const auto &Left : Common) {
- // Left was copied from the first range so its index refers to a stream
- // index in the first file. Find the corresponding stream index in the
- // second file.
- auto Range =
- std::equal_range(QI.begin(), QI.end(), Left,
- [](const value_type &L, const value_type &R) {
- return L.value() < R.value();
- });
- const auto &Right = *Range.first;
- assert(Left.value() == Right.value());
- uint32_t LeftSize = File1.getStreamByteSize(Left.index());
- uint32_t RightSize = File2.getStreamByteSize(Right.index());
- if (LeftSize != RightSize) {
- HasDifferences = true;
- HasCommonDifferences = true;
- outs().indent(4) << formatv("{0} ({1}: {2} bytes, {3}: {4} bytes)\n",
- Left.value(), File1.getFilePath(),
- LeftSize, File2.getFilePath(), RightSize);
- }
+ }
+ if (!Common.empty()) {
+ outs().indent(2) << formatv("Found {0} common streams. Searching for "
+ "intra-stream differences.\n",
+ Common.size());
+ bool HasCommonDifferences = false;
+ for (const auto &Left : Common) {
+ // Left was copied from the first range so its index refers to a stream
+ // index in the first file. Find the corresponding stream index in the
+ // second file.
+ auto Range =
+ std::equal_range(QI.begin(), QI.end(), Left,
+ [](const value_type &L, const value_type &R) {
+ return L.value() < R.value();
+ });
+ const auto &Right = *Range.first;
+ assert(Left.value() == Right.value());
+ uint32_t LeftSize = File1.getStreamByteSize(Left.index());
+ uint32_t RightSize = File2.getStreamByteSize(Right.index());
+ if (LeftSize != RightSize) {
+ HasDifferences = true;
+ HasCommonDifferences = true;
+ outs().indent(4) << formatv("{0} ({1}: {2} bytes, {3}: {4} bytes)\n",
+ Left.value(), File1.getFilePath(), LeftSize,
+ File2.getFilePath(), RightSize);
}
- if (!HasCommonDifferences)
- outs().indent(2) << "Common Streams: No differences detected!\n";
}
- if (!HasDifferences)
- outs() << "Stream Directory: No differences detected!\n";
+ if (!HasCommonDifferences)
+ outs().indent(2) << "Common Streams: No differences detected!\n";
}
+ if (!HasDifferences)
+ outs() << "Stream Directory: No differences detected!\n";
return Error::success();
}
@@ -384,77 +331,39 @@ 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());
- for (auto ID : IdList1) {
- auto S = ST1.getStringForID(ID);
- if (!S)
- return S.takeError();
- Strings1.push_back(*S);
- }
- for (auto ID : IdList2) {
- auto S = ST2.getStringForID(ID);
- if (!S)
- return S.takeError();
- Strings2.push_back(*S);
- }
+ std::vector<StringRef> Strings1, Strings2;
+ Strings1.reserve(IdList1.size());
+ Strings2.reserve(IdList2.size());
+ for (auto ID : IdList1) {
+ auto S = ST1.getStringForID(ID);
+ if (!S)
+ return S.takeError();
+ Strings1.push_back(*S);
+ }
+ for (auto ID : IdList2) {
+ auto S = ST2.getStringForID(ID);
+ if (!S)
+ return S.takeError();
+ Strings2.push_back(*S);
+ }
- SmallVector<StringRef, 64> OnlyP;
- SmallVector<StringRef, 64> OnlyQ;
- auto End1 = std::remove(Strings1.begin(), Strings1.end(), "");
- auto End2 = std::remove(Strings2.begin(), Strings2.end(), "");
- uint32_t Empty1 = std::distance(End1, Strings1.end());
- uint32_t Empty2 = std::distance(End2, Strings2.end());
- Strings1.erase(End1, Strings1.end());
- Strings2.erase(End2, Strings2.end());
- set_differences(Strings1, Strings2, &OnlyP, &OnlyQ);
- printSymmetricDifferences(File1, File2, OnlyP, OnlyQ, "String");
-
- if (Empty1 != Empty2) {
- PDBFile &MoreF = (Empty1 > Empty2) ? File1 : File2;
- PDBFile &LessF = (Empty1 < Empty2) ? File1 : File2;
- uint32_t Difference = AbsoluteDifference(Empty1, Empty2);
- outs() << formatv(" {0} had {1} more empty strings than {2}\n",
- MoreF.getFilePath(), Difference, LessF.getFilePath());
- }
+ SmallVector<StringRef, 64> OnlyP;
+ SmallVector<StringRef, 64> OnlyQ;
+ auto End1 = std::remove(Strings1.begin(), Strings1.end(), "");
+ auto End2 = std::remove(Strings2.begin(), Strings2.end(), "");
+ uint32_t Empty1 = std::distance(End1, Strings1.end());
+ uint32_t Empty2 = std::distance(End2, Strings2.end());
+ Strings1.erase(End1, Strings1.end());
+ Strings2.erase(End2, Strings2.end());
+ set_differences(Strings1, Strings2, &OnlyP, &OnlyQ);
+ printSymmetricDifferences(File1, File2, OnlyP, OnlyQ, "String");
+
+ if (Empty1 != Empty2) {
+ PDBFile &MoreF = (Empty1 > Empty2) ? File1 : File2;
+ PDBFile &LessF = (Empty1 < Empty2) ? File1 : File2;
+ uint32_t Difference = AbsoluteDifference(Empty1, Empty2);
+ 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";
Modified: llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp?rev=305818&r1=305817&r2=305818&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp Tue Jun 20 13:50:30 2017
@@ -256,11 +256,6 @@ cl::opt<bool> NoEnumDefs("no-enum-defini
}
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));
Modified: llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h?rev=305818&r1=305817&r2=305818&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h (original)
+++ llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h Tue Jun 20 13:50:30 2017
@@ -127,10 +127,6 @@ extern llvm::cl::opt<bool> DumpModuleFil
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;
More information about the llvm-commits
mailing list