Skip to content

Commit 47c0e4c

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents 6d3cdd0 + 21ca9d4 commit 47c0e4c

File tree

13 files changed

+50
-43
lines changed

13 files changed

+50
-43
lines changed

CMakeLists.txt

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,8 @@ endif()
413413

414414
if(MSVC OR "${CMAKE_SIMULATE_ID}" STREQUAL MSVC)
415415
include(ClangClCompileRules)
416+
elseif(UNIX)
417+
include(UnixCompileRules)
416418
endif()
417419

418420
if(CMAKE_C_COMPILER_ID MATCHES Clang)
@@ -432,19 +434,6 @@ if(SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT)
432434
endif()
433435
endif()
434436

435-
#
436-
# Assume a new enough ar to generate the index at construction time. This avoids
437-
# having to invoke ranlib as a secondary command.
438-
#
439-
440-
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <LINK_FLAGS> <OBJECTS>")
441-
set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> qs <TARGET> <LINK_FLAGS> <OBJECTS>")
442-
set(CMAKE_C_ARCHIVE_FINISH "")
443-
444-
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <LINK_FLAGS> <OBJECTS>")
445-
set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> qs <TARGET> <LINK_FLAGS> <OBJECTS>")
446-
set(CMAKE_CXX_ARCHIVE_FINISH "")
447-
448437
#
449438
# Include CMake modules
450439
#

cmake/modules/UnixCompileRules.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
#
3+
# Assume a new enough ar to generate the index at construction time. This avoids
4+
# having to invoke ranlib as a secondary command.
5+
#
6+
7+
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <LINK_FLAGS> <OBJECTS>")
8+
set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> qs <TARGET> <LINK_FLAGS> <OBJECTS>")
9+
set(CMAKE_C_ARCHIVE_FINISH "")
10+
11+
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <LINK_FLAGS> <OBJECTS>")
12+
set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> qs <TARGET> <LINK_FLAGS> <OBJECTS>")
13+
set(CMAKE_CXX_ARCHIVE_FINISH "")

include/swift/AST/FileUnit.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ class FileUnit : public DeclContext {
107107
/// Find all SPI names imported from \p importedModule by this module,
108108
/// collecting the identifiers in \p spiGroups.
109109
virtual void lookupImportedSPIGroups(
110-
const ModuleDecl *importedModule,
111-
SmallVectorImpl<Identifier> &spiGroups) const {};
110+
const ModuleDecl *importedModule,
111+
SmallSetVector<Identifier, 4> &spiGroups) const {};
112112

113113
protected:
114114
/// Look up an operator declaration. Do not call directly, use

include/swift/AST/Module.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,9 @@ class ModuleDecl : public DeclContext, public TypeDecl {
646646

647647
/// Find all SPI names imported from \p importedModule by this module,
648648
/// collecting the identifiers in \p spiGroups.
649-
void lookupImportedSPIGroups(const ModuleDecl *importedModule,
650-
SmallVectorImpl<Identifier> &spiGroups) const;
649+
void lookupImportedSPIGroups(
650+
const ModuleDecl *importedModule,
651+
llvm::SmallSetVector<Identifier, 4> &spiGroups) const;
651652

652653
/// \sa getImportedModules
653654
enum class ImportFilterKind {

include/swift/AST/SourceFile.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,9 @@ class SourceFile final : public FileUnit {
338338
/// Find all SPI names imported from \p importedModule by this file,
339339
/// collecting the identifiers in \p spiGroups.
340340
virtual void
341-
lookupImportedSPIGroups(const ModuleDecl *importedModule,
342-
SmallVectorImpl<Identifier> &spiGroups) const override;
341+
lookupImportedSPIGroups(
342+
const ModuleDecl *importedModule,
343+
llvm::SmallSetVector<Identifier, 4> &spiGroups) const override;
343344

344345
// Is \p targetDecl accessible as an explictly imported SPI from this file?
345346
bool isImportedAsSPI(const ValueDecl *targetDecl) const;

include/swift/Serialization/SerializedModuleLoader.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,9 @@ class SerializedASTFile final : public LoadedFile {
368368
SmallVectorImpl<AbstractFunctionDecl *> &results) const override;
369369

370370
virtual void
371-
lookupImportedSPIGroups(const ModuleDecl *importedModule,
372-
SmallVectorImpl<Identifier> &spiGroups) const override;
371+
lookupImportedSPIGroups(
372+
const ModuleDecl *importedModule,
373+
llvm::SmallSetVector<Identifier, 4> &spiGroups) const override;
373374

374375
Optional<CommentInfo> getCommentForDecl(const Decl *D) const override;
375376

lib/AST/Module.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,9 @@ void ModuleDecl::lookupObjCMethods(
648648
FORWARD(lookupObjCMethods, (selector, results));
649649
}
650650

651-
void ModuleDecl::lookupImportedSPIGroups(const ModuleDecl *importedModule,
652-
SmallVectorImpl<Identifier> &spiGroups) const {
651+
void ModuleDecl::lookupImportedSPIGroups(
652+
const ModuleDecl *importedModule,
653+
llvm::SmallSetVector<Identifier, 4> &spiGroups) const {
653654
FORWARD(lookupImportedSPIGroups, (importedModule, spiGroups));
654655
}
655656

@@ -1933,31 +1934,29 @@ bool SourceFile::isImportedImplementationOnly(const ModuleDecl *module) const {
19331934
return !imports.isImportedBy(module, getParentModule());
19341935
}
19351936

1936-
void SourceFile::lookupImportedSPIGroups(const ModuleDecl *importedModule,
1937-
SmallVectorImpl<Identifier> &spiGroups) const {
1937+
void SourceFile::lookupImportedSPIGroups(
1938+
const ModuleDecl *importedModule,
1939+
llvm::SmallSetVector<Identifier, 4> &spiGroups) const {
19381940
for (auto &import : *Imports) {
19391941
if (import.importOptions.contains(ImportFlags::SPIAccessControl) &&
19401942
importedModule == import.module.importedModule) {
19411943
auto importedSpis = import.spiGroups;
1942-
spiGroups.append(importedSpis.begin(), importedSpis.end());
1944+
spiGroups.insert(importedSpis.begin(), importedSpis.end());
19431945
}
19441946
}
19451947
}
19461948

19471949
bool SourceFile::isImportedAsSPI(const ValueDecl *targetDecl) const {
19481950
auto targetModule = targetDecl->getModuleContext();
1949-
SmallVector<Identifier, 4> importedSPIGroups;
1951+
llvm::SmallSetVector<Identifier, 4> importedSPIGroups;
19501952
lookupImportedSPIGroups(targetModule, importedSPIGroups);
19511953
if (importedSPIGroups.empty()) return false;
19521954

19531955
auto declSPIGroups = targetDecl->getSPIGroups();
19541956

1955-
// Note: If we reach a point where there are many SPI imports or SPI groups
1956-
// on decls we could optimize this further by using a set.
1957-
for (auto importedSPI : importedSPIGroups)
1958-
for (auto declSPI : declSPIGroups)
1959-
if (importedSPI == declSPI)
1960-
return true;
1957+
for (auto declSPI : declSPIGroups)
1958+
if (importedSPIGroups.count(declSPI))
1959+
return true;
19611960

19621961
return false;
19631962
}

lib/Frontend/ModuleInterfaceSupport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static void printImports(raw_ostream &out,
130130

131131
// SPI attribute on imports
132132
if (Opts.PrintSPIs) {
133-
SmallVector<Identifier, 4> spis;
133+
llvm::SmallSetVector<Identifier, 4> spis;
134134
M->lookupImportedSPIGroups(importedModule, spis);
135135
for (auto spiName : spis)
136136
out << "@_spi(" << spiName << ") ";

lib/Serialization/ModuleFile.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2663,13 +2663,14 @@ void ModuleFile::lookupObjCMethods(
26632663
}
26642664
}
26652665

2666-
void ModuleFile::lookupImportedSPIGroups(const ModuleDecl *importedModule,
2667-
SmallVectorImpl<Identifier> &spiGroups) const {
2666+
void ModuleFile::lookupImportedSPIGroups(
2667+
const ModuleDecl *importedModule,
2668+
llvm::SmallSetVector<Identifier, 4> &spiGroups) const {
26682669
for (auto &dep : Dependencies) {
26692670
auto depSpis = dep.spiGroups;
26702671
if (dep.Import.hasValue() && dep.Import->importedModule == importedModule &&
26712672
!depSpis.empty()) {
2672-
spiGroups.append(depSpis.begin(), depSpis.end());
2673+
spiGroups.insert(depSpis.begin(), depSpis.end());
26732674
}
26742675
}
26752676
}

lib/Serialization/ModuleFile.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,8 +812,9 @@ class ModuleFile
812812

813813
/// Find all SPI names imported from \p importedModule by this module,
814814
/// collecting the identifiers in \p spiGroups.
815-
void lookupImportedSPIGroups(const ModuleDecl *importedModule,
816-
SmallVectorImpl<Identifier> &spiGroups) const;
815+
void lookupImportedSPIGroups(
816+
const ModuleDecl *importedModule,
817+
llvm::SmallSetVector<Identifier, 4> &spiGroups) const;
817818

818819
/// Reports all link-time dependencies.
819820
void collectLinkLibraries(ModuleDecl::LinkLibraryCallback callback) const;

0 commit comments

Comments
 (0)