Skip to content

Commit 4c22fcd

Browse files
authored
Revert "Fix .swiftdeps file deterministic issues"
1 parent a5a84f1 commit 4c22fcd

File tree

4 files changed

+16
-56
lines changed

4 files changed

+16
-56
lines changed

lib/AST/Identifier.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,6 @@ int Identifier::compare(Identifier other) const {
9898
}
9999

100100
int DeclName::compare(DeclName other) const {
101-
// Fast equality comparsion.
102-
if (getOpaqueValue() == other.getOpaqueValue())
103-
return 0;
104-
105-
106101
// Compare base names.
107102
if (int result = getBaseName().compare(other.getBaseName()))
108103
return result;
@@ -116,13 +111,10 @@ int DeclName::compare(DeclName other) const {
116111
return result;
117112
}
118113

119-
if (argNames.size() != otherArgNames.size())
120-
return argNames.size() < otherArgNames.size() ? -1 : 1;
114+
if (argNames.size() == otherArgNames.size())
115+
return 0;
121116

122-
// Order based on if it is compound name or not.
123-
assert(isSimpleName() != other.isSimpleName() &&
124-
"equality should be covered by opaque value comparsion");
125-
return isSimpleName() ? -1 : 1;
117+
return argNames.size() < otherArgNames.size() ? -1 : 1;
126118
}
127119

128120
static bool equals(ArrayRef<Identifier> idents, ArrayRef<StringRef> strings) {

lib/AST/Module.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -694,17 +694,13 @@ void SourceLookupCache::lookupClassMembers(ImportPath::Access accessPath,
694694
VisibleDeclConsumer &consumer) {
695695
assert(accessPath.size() <= 1 && "can only refer to top-level decls");
696696

697-
std::vector<std::pair<DeclName, TinyPtrVector<ValueDecl *>>> OrderedMembers;
698-
for (auto &member : ClassMembers) {
699-
if (!member.first.isSimpleName())
700-
continue;
701-
OrderedMembers.emplace_back(member.first, member.second);
702-
}
703-
llvm::sort(OrderedMembers,
704-
[](auto &LHS, auto &RHS) { return LHS.first < RHS.first; });
705-
706697
if (!accessPath.empty()) {
707-
for (auto &member : OrderedMembers) {
698+
for (auto &member : ClassMembers) {
699+
// Non-simple names are also stored under their simple name, so make
700+
// sure to only report them once.
701+
if (!member.first.isSimpleName())
702+
continue;
703+
708704
for (ValueDecl *vd : member.second) {
709705
auto *nominal = vd->getDeclContext()->getSelfNominalTypeDecl();
710706
if (nominal && nominal->getName() == accessPath.front().Item)
@@ -716,7 +712,12 @@ void SourceLookupCache::lookupClassMembers(ImportPath::Access accessPath,
716712
return;
717713
}
718714

719-
for (auto &member : OrderedMembers) {
715+
for (auto &member : ClassMembers) {
716+
// Non-simple names are also stored under their simple name, so make sure to
717+
// only report them once.
718+
if (!member.first.isSimpleName())
719+
continue;
720+
720721
for (ValueDecl *vd : member.second)
721722
if (ABIRoleInfo(vd).matchesOptions(OptionSet<ModuleLookupFlags>())) // FIXME: figure this out
722723
consumer.foundDecl(vd, DeclVisibilityKind::DynamicLookup,

lib/FrontendTool/FrontendTool.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "swift/AST/ASTDumper.h"
2727
#include "swift/AST/ASTMangler.h"
2828
#include "swift/AST/AvailabilityScope.h"
29-
#include "swift/AST/DiagnosticConsumer.h"
3029
#include "swift/AST/DiagnosticsFrontend.h"
3130
#include "swift/AST/DiagnosticsSema.h"
3231
#include "swift/AST/FileSystem.h"
@@ -2101,11 +2100,6 @@ int swift::performFrontend(ArrayRef<const char *> Args,
21012100
// Setup a verfication instance to run.
21022101
std::unique_ptr<CompilerInstance> VerifyInstance =
21032102
std::make_unique<CompilerInstance>();
2104-
// Add a null diagnostic consumer to the diagnostic engine so the
2105-
// compilation will exercise all the diagnose code path but not emitting
2106-
// anything.
2107-
NullDiagnosticConsumer DC;
2108-
VerifyInstance->getDiags().addConsumer(DC);
21092103
std::string InstanceSetupError;
21102104
// This should not fail because it passed already.
21112105
(void)VerifyInstance->setup(Invocation, InstanceSetupError, Args);

test/Frontend/output_determinism_check.swift

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,4 @@
3737
// PCM_OUTPUT: remark: produced matching output file '{{.*}}{{/|\\}}test.pcm'
3838

3939
public var x = 1
40-
public func test() {
41-
precondition(x == 1, "dummy check")
42-
}
43-
44-
class A {
45-
var a = 0
46-
var b = 0
47-
var c = 0
48-
var d = 0
49-
}
50-
class B {
51-
var a = 0
52-
var b = 0
53-
var c = 0
54-
var d = 0
55-
}
56-
class C {
57-
var a = 0
58-
var b = 0
59-
var c = 0
60-
var d = 0
61-
}
62-
class D {
63-
var a = 0
64-
var b = 0
65-
var c = 0
66-
var d = 0
67-
}
40+
public func test() {}

0 commit comments

Comments
 (0)