Skip to content

Commit e18a6b6

Browse files
committed
---
yaml --- r: 348971 b: refs/heads/master c: adaf790 h: refs/heads/master i: 348969: 6921f5b 348967: 61d458c
1 parent 56f9db7 commit e18a6b6

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 5c092e79887da3f9b0a61fb4e098427e7f6ba809
2+
refs/heads/master: adaf790f4c6868f9f3100630f837fa6f40dbb61e
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/lib/Serialization/SerializeDoc.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "DocFormat.h"
1414
#include "Serialization.h"
1515
#include "SourceInfoFormat.h"
16+
#include "swift/Basic/Defer.h"
1617
#include "swift/AST/ASTContext.h"
1718
#include "swift/AST/ASTWalker.h"
1819
#include "swift/AST/DiagnosticsCommon.h"
@@ -556,6 +557,7 @@ class DeclUSRsTableWriter {
556557
llvm::OnDiskChainedHashTableGenerator<USRTableInfo> generator;
557558
uint32_t CurId = 0;
558559
public:
560+
uint32_t peekNextId() const { return CurId; }
559561
Optional<uint32_t> getNewUSRID(StringRef USR) {
560562
if (USRMap.find(USR) == USRMap.end()) {
561563
generator.insert(USRMap.insert(std::make_pair(USR, CurId)).first->getKey(), CurId);
@@ -690,6 +692,10 @@ Result.X.Column = Locs->X.Column;
690692
}
691693

692694
bool walkToDeclPre(Decl *D) override {
695+
SWIFT_DEFER {
696+
assert(USRWriter.peekNextId() * sizeof(DeclLocationsTableData) == Buffer.size() &&
697+
"USR Id has a one-to-one mapping with DeclLocationsTableData");
698+
};
693699
// We shouldn't expose any Decls that .swiftdoc file isn't willing to expose.
694700
// .swiftdoc doesn't include comments for double underscored symbols, but for .swiftsourceinfo,
695701
// having the source location for these symbols isn't a concern becuase these
@@ -706,9 +712,6 @@ Result.X.Column = Locs->X.Column;
706712
auto USR = calculateNewUSRId(D);
707713
if (!USR.hasValue())
708714
return true;
709-
// OK, we get a new USR, now append the associated source location data.
710-
assert(*USR * sizeof(DeclLocationsTableData) == Buffer.size() &&
711-
"USR id is used as an index to access basic location array");
712715
appendToBuffer(*LocData);
713716
return true;
714717
}

0 commit comments

Comments
 (0)