Skip to content

Commit 55075eb

Browse files
committed
---
yaml --- r: 345215 b: refs/heads/master c: 36b766e h: refs/heads/master i: 345213: fb13b49 345211: 6dd1347 345207: 9335546 345199: bbb788a 345183: 03db506 345151: 660994a 345087: 88749b1
1 parent 6d73dff commit 55075eb

File tree

16 files changed

+39
-61
lines changed

16 files changed

+39
-61
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: 015f4ba8cfaf9f5170b6a1d34025887d1d96b25f
2+
refs/heads/master: 36b766e7930d00437cac8a04dfd6a6e4855b4de0
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/include/swift/Basic/SourceManager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ class SourceManager {
3131
unsigned CodeCompletionOffset;
3232

3333
/// Associates buffer identifiers to buffer IDs.
34-
llvm::StringMap<unsigned> BufIdentIDMap;
34+
llvm::DenseMap<StringRef, unsigned> BufIdentIDMap;
3535

3636
/// A cache mapping buffer identifiers to vfs Status entries.
3737
///
3838
/// This is as much a hack to prolong the lifetime of status objects as it is
3939
/// to speed up stats.
40-
mutable llvm::StringMap<clang::vfs::Status> StatusCache;
40+
mutable llvm::DenseMap<StringRef, clang::vfs::Status> StatusCache;
4141

4242
// \c #sourceLocation directive handling.
4343
struct VirtualFile {

trunk/include/swift/Driver/DependencyGraph.h

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -143,33 +143,6 @@ class DependencyGraphImpl {
143143

144144
LoadResult loadFromBuffer(const void *node, llvm::MemoryBuffer &buffer);
145145

146-
// FIXME: We should be able to use llvm::mapped_iterator for this, but
147-
// StringMapConstIterator isn't quite an InputIterator (no ->).
148-
class StringSetIterator {
149-
llvm::StringSet<>::const_iterator I;
150-
public:
151-
using value_type = llvm::StringSet<>::const_iterator::value_type;
152-
using iterator_category = std::input_iterator_tag;
153-
using difference_type = ptrdiff_t;
154-
using reference = value_type &;
155-
using pointer = value_type *;
156-
157-
/*implicit*/ StringSetIterator(llvm::StringSet<>::const_iterator base)
158-
: I(base) {}
159-
160-
StringSetIterator &operator++() {
161-
++I;
162-
return *this;
163-
}
164-
165-
StringRef operator*() const {
166-
return I->getKey();
167-
}
168-
169-
bool operator==(StringSetIterator other) const { return I == other.I; }
170-
bool operator!=(StringSetIterator other) const { return I != other.I; }
171-
};
172-
173146
protected:
174147
LoadResult loadFromString(const void *node, StringRef data);
175148
LoadResult loadFromPath(const void *node, StringRef path);
@@ -195,9 +168,8 @@ class DependencyGraphImpl {
195168
}
196169

197170
public:
198-
llvm::iterator_range<StringSetIterator> getExternalDependencies() const {
199-
return llvm::make_range(StringSetIterator(ExternalDependencies.begin()),
200-
StringSetIterator(ExternalDependencies.end()));
171+
decltype(ExternalDependencies.keys()) getExternalDependencies() const {
172+
return ExternalDependencies.keys();
201173
}
202174
};
203175

trunk/lib/AST/ASTContext.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ struct ASTContext::Implementation {
124124
/// lazy parsers for imported module files and source files.
125125
llvm::SmallPtrSet<LazyMemberParser*, 2> lazyParsers;
126126

127+
// FIXME: This is a StringMap rather than a StringSet because StringSet
128+
// doesn't allow passing in a pre-existing allocator.
127129
llvm::StringMap<char, llvm::BumpPtrAllocator&> IdentifierTable;
128130

129131
/// The declaration of Swift.AssignmentPrecedence.

trunk/lib/ClangImporter/ClangImporter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3289,7 +3289,7 @@ bool ClangImporter::Implementation::forEachLookupTable(
32893289
// Collect and sort the set of module names.
32903290
SmallVector<StringRef, 4> moduleNames;
32913291
for (const auto &entry : LookupTables) {
3292-
moduleNames.push_back(entry.first());
3292+
moduleNames.push_back(entry.first);
32933293
}
32943294
llvm::array_pod_sort(moduleNames.begin(), moduleNames.end());
32953295

@@ -3597,7 +3597,7 @@ void ClangImporter::Implementation::dumpSwiftLookupTables() {
35973597
// Sort the module names so we can print in a deterministic order.
35983598
SmallVector<StringRef, 4> moduleNames;
35993599
for (const auto &lookupTable : LookupTables) {
3600-
moduleNames.push_back(lookupTable.first());
3600+
moduleNames.push_back(lookupTable.first);
36013601
}
36023602
array_pod_sort(moduleNames.begin(), moduleNames.end());
36033603

trunk/lib/ClangImporter/ImporterImpl.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ struct PlatformAvailability {
279279
};
280280
}
281281

282-
using LookupTableMap = llvm::StringMap<std::unique_ptr<SwiftLookupTable>>;
282+
using LookupTableMap =
283+
llvm::DenseMap<StringRef, std::unique_ptr<SwiftLookupTable>>;
283284

284285
/// The result of importing a clang type. It holds both the Swift Type
285286
/// as well as a bool in which 'true' indicates either:
@@ -489,10 +490,6 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation
489490
return getNameImporter().getEnumKind(decl);
490491
}
491492

492-
// TODO: drop this accessor as soon as we further de-couple the swift name
493-
// lookup tables from the Impl.
494-
LookupTableMap &getLookupTables() { return LookupTables; }
495-
496493
private:
497494
/// A mapping from imported declarations to their "alternate" declarations,
498495
/// for cases where a single Clang declaration is imported to two

trunk/lib/Driver/Driver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ static bool populateOutOfDateMap(InputInfoMap &map,
591591
// If a file was removed, we've lost its dependency info. Rebuild everything.
592592
// FIXME: Can we do better?
593593
if (ShowIncrementalBuildDecisions) {
594-
llvm::StringSet<> inputArgs;
594+
llvm::DenseSet<StringRef> inputArgs;
595595
for (auto &inputPair : inputs) {
596596
inputArgs.insert(inputPair.second->getValue());
597597
}
@@ -1186,7 +1186,7 @@ static bool checkInputExistence(const Driver &D, const DerivedArgList &Args,
11861186
void Driver::buildInputs(const ToolChain &TC,
11871187
const DerivedArgList &Args,
11881188
InputFileList &Inputs) const {
1189-
llvm::StringMap<StringRef> SourceFileNames;
1189+
llvm::DenseMap<StringRef, StringRef> SourceFileNames;
11901190

11911191
for (Arg *A : Args) {
11921192
if (A->getOption().getKind() == Option::InputClass) {

trunk/lib/Driver/ToolChain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ static void
296296
sortJobsToMatchCompilationInputs(ArrayRef<const Job *> unsortedJobs,
297297
SmallVectorImpl<const Job *> &sortedJobs,
298298
Compilation &C) {
299-
llvm::StringMap<const Job *> jobsByInput;
299+
llvm::DenseMap<StringRef, const Job *> jobsByInput;
300300
for (const Job *J : unsortedJobs) {
301301
const CompileJobAction *CJA = cast<CompileJobAction>(&J->getSource());
302302
const InputAction *IA = findSingleSwiftInput(CJA);

trunk/lib/Driver/ToolChains.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ void ToolChain::JobContext::addFrontendCommandLineInputArguments(
504504
const bool mayHavePrimaryInputs, const bool useFileList,
505505
const bool usePrimaryFileList, const bool filterByType,
506506
ArgStringList &arguments) const {
507-
llvm::StringSet<> primaries;
507+
llvm::DenseSet<StringRef> primaries;
508508

509509
if (mayHavePrimaryInputs) {
510510
for (const Action *A : InputActions) {

trunk/lib/IDE/Refactoring.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,15 +387,17 @@ class RenameRangeDetailCollector : public Renamer {
387387
};
388388

389389
class TextReplacementsRenamer : public Renamer {
390-
llvm::StringMap<char> &ReplaceTextContext;
390+
llvm::StringSet<> &ReplaceTextContext;
391391
std::vector<Replacement> Replacements;
392392

393393
public:
394394
const DeclNameViewer New;
395395

396396
private:
397397
StringRef registerText(StringRef Text) {
398-
return ReplaceTextContext.insert({Text, char()}).first->getKey();
398+
if (Text.empty())
399+
return Text;
400+
return ReplaceTextContext.insert(Text).first->getKey();
399401
}
400402

401403
StringRef getCallArgLabelReplacement(StringRef OldLabelRange,
@@ -497,7 +499,7 @@ class TextReplacementsRenamer : public Renamer {
497499
public:
498500
TextReplacementsRenamer(const SourceManager &SM, StringRef OldName,
499501
StringRef NewName,
500-
llvm::StringMap<char> &ReplaceTextContext)
502+
llvm::StringSet<> &ReplaceTextContext)
501503
: Renamer(SM, OldName), ReplaceTextContext(ReplaceTextContext),
502504
New(NewName) {
503505
assert(Old.isValid() && New.isValid());
@@ -3295,7 +3297,7 @@ int swift::ide::syntacticRename(SourceFile *SF, ArrayRef<RenameLoc> RenameLocs,
32953297
return true; // Already diagnosed.
32963298

32973299
size_t index = 0;
3298-
llvm::StringMap<char> ReplaceTextContext;
3300+
llvm::StringSet<> ReplaceTextContext;
32993301
for(const RenameLoc &Rename: RenameLocs) {
33003302
ResolvedLoc &Resolved = ResolvedLocs[index++];
33013303
TextReplacementsRenamer Renamer(SM, Rename.OldName, Rename.NewName,

trunk/lib/IRGen/IRGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ static void performParallelIRGeneration(
10101010
PrimaryGM->addLinkLibrary(linkLib);
10111011
});
10121012

1013-
llvm::StringSet<> referencedGlobals;
1013+
llvm::DenseSet<StringRef> referencedGlobals;
10141014

10151015
for (auto it = irgen.begin(); it != irgen.end(); ++it) {
10161016
IRGenModule *IGM = it->second;

trunk/lib/PrintAsObjC/PrintAsObjC.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ static bool isAnyObjectOrAny(Type type) {
6565

6666
/// Returns true if \p name matches a keyword in any Clang language mode.
6767
static bool isClangKeyword(Identifier name) {
68-
static const llvm::StringSet<> keywords = []{
69-
llvm::StringSet<> set;
68+
static const llvm::DenseSet<StringRef> keywords = []{
69+
llvm::DenseSet<StringRef> set;
7070
// FIXME: clang::IdentifierInfo /nearly/ has the API we need to do this
7171
// in a more principled way, but not quite.
7272
#define KEYWORD(SPELLING, FLAGS) \

trunk/lib/SIL/SILVerifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5065,7 +5065,7 @@ void SILModule::verify() const {
50655065
return;
50665066
#endif
50675067
// Uniquing set to catch symbol name collisions.
5068-
llvm::StringSet<> symbolNames;
5068+
llvm::DenseSet<StringRef> symbolNames;
50695069

50705070
// When merging partial modules, we only link functions from the current
50715071
// module, without enabling "LinkAll" mode or running the SILLinker pass;

trunk/lib/Serialization/SerializedModuleLoader.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "swift/Basic/SourceManager.h"
2121
#include "swift/Basic/Version.h"
2222
#include "llvm/ADT/SmallString.h"
23+
#include "llvm/ADT/StringSet.h"
2324
#include "llvm/Support/FileSystem.h"
2425
#include "llvm/Support/MemoryBuffer.h"
2526
#include "llvm/Support/Path.h"
@@ -376,19 +377,15 @@ FileUnit *SerializedModuleLoader::loadAST(
376377
// Figure out /which/ dependencies are missing.
377378
// FIXME: Dependencies should be de-duplicated at serialization time,
378379
// not now.
379-
llvm::StringMap<bool> duplicates;
380+
llvm::StringSet<> duplicates;
380381
llvm::SmallVector<ModuleFile::Dependency, 4> missing;
381382
std::copy_if(loadedModuleFile->getDependencies().begin(),
382383
loadedModuleFile->getDependencies().end(),
383384
std::back_inserter(missing),
384385
[&duplicates](const ModuleFile::Dependency &dependency)->bool {
385386
if (dependency.isLoaded() || dependency.isHeader())
386387
return false;
387-
bool &seen = duplicates[dependency.RawPath];
388-
if (seen)
389-
return false;
390-
seen = true;
391-
return true;
388+
return duplicates.insert(dependency.RawPath).second;
392389
});
393390

394391
// FIXME: only show module part of RawAccessPath

trunk/tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,8 +1673,13 @@ ImmutableTextSnapshotRef SwiftEditorDocument::replaceText(
16731673
}
16741674

16751675
void SwiftEditorDocument::updateSemaInfo() {
1676-
if (Impl.SemanticInfo) {
1677-
Impl.SemanticInfo->processLatestSnapshotAsync(Impl.EditableBuffer);
1676+
Impl.AccessMtx.lock();
1677+
auto EditableBuffer = Impl.EditableBuffer;
1678+
auto SemanticInfo = Impl.SemanticInfo;
1679+
Impl.AccessMtx.unlock(); // Not a recursive mutex, so unlock before processing
1680+
1681+
if (SemanticInfo) {
1682+
SemanticInfo->processLatestSnapshotAsync(EditableBuffer);
16781683
}
16791684
}
16801685

@@ -1978,6 +1983,7 @@ void SwiftEditorDocument::expandPlaceholder(unsigned Offset, unsigned Length,
19781983
}
19791984

19801985
ImmutableTextSnapshotRef SwiftEditorDocument::getLatestSnapshot() const {
1986+
llvm::sys::ScopedLock L(Impl.AccessMtx);
19811987
return Impl.EditableBuffer->getSnapshot();
19821988
}
19831989

trunk/unittests/SourceKit/SwiftLang/EditingTest.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ void EditTest::doubleOpenWithDelay(useconds_t delay, bool closeDoc) {
253253
// be queried, since the semantic info from the first open is unreachable.
254254
for (int i = 0; i < 2; ++i) {
255255
bool expired = waitForDocUpdate(/*reset=*/true);
256-
ASSERT_FALSE(expired) << "no second notification";
256+
ASSERT_FALSE(expired) << "no " << (i ? "second " : "") << "notification";
257257
replaceText(DocName, 0, 0, StringRef(), Consumer);
258258
if (!Consumer.Diags.empty())
259259
break;
@@ -262,6 +262,8 @@ void EditTest::doubleOpenWithDelay(useconds_t delay, bool closeDoc) {
262262

263263
ASSERT_EQ(1u, Consumer.Diags.size());
264264
EXPECT_STREQ("use of unresolved identifier 'unknown_name'", Consumer.Diags[0].Description.c_str());
265+
266+
close(DocName);
265267
}
266268

267269
// This test is failing occassionally in CI: rdar://42483323

0 commit comments

Comments
 (0)