Skip to content

Commit d6073fe

Browse files
authored
Merge pull request #3624 from swiftwasm/main
2 parents a032d8a + 028b964 commit d6073fe

File tree

65 files changed

+1344
-401
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1344
-401
lines changed

include/swift/AST/ASTContext.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ class ASTContext final {
347347
/// Cache of module names that fail the 'canImport' test in this context.
348348
mutable llvm::SmallPtrSet<Identifier, 8> FailedModuleImportNames;
349349

350+
/// Mapping between aliases and real (physical) names of imported or referenced modules.
351+
mutable llvm::DenseMap<Identifier, Identifier> ModuleAliasMap;
352+
350353
/// Retrieve the allocator for the given arena.
351354
llvm::BumpPtrAllocator &
352355
getAllocator(AllocationArena arena = AllocationArena::Permanent) const;
@@ -471,6 +474,16 @@ class ASTContext final {
471474
/// specified string.
472475
Identifier getIdentifier(StringRef Str) const;
473476

477+
/// Convert a given alias map to a map of Identifiers between module aliases and their actual names.
478+
/// For example, if '-module-alias Foo=X -module-alias Bar=Y' input is passed in, the aliases Foo and Bar are
479+
/// the names of the imported or referenced modules in source files in the main module, and X and Y
480+
/// are the real (physical) module names on disk.
481+
void setModuleAliases(const llvm::StringMap<StringRef> &aliasMap);
482+
483+
/// Retrieve the actual module name if a module alias is used via '-module-alias Foo=X', where Foo is
484+
/// a module alias and X is the real (physical) name. Returns \p key if no aliasing is used.
485+
Identifier getRealModuleName(Identifier key) const;
486+
474487
/// Decide how to interpret two precedence groups.
475488
Associativity associateInfixOperators(PrecedenceGroupDecl *left,
476489
PrecedenceGroupDecl *right) const;

include/swift/AST/DiagnosticsParse.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,8 @@ ERROR(expected_await_not_async,none,
10301030
// Yield Statment
10311031
ERROR(expected_expr_yield,PointsToFirstBadToken,
10321032
"expected expression in 'yield' statement", ())
1033+
ERROR(unexpected_label_yield,none,
1034+
"unexpected label in 'yield' statement", ())
10331035

10341036
// Defer Statement
10351037
ERROR(expected_lbrace_after_defer,PointsToFirstBadToken,

include/swift/AST/Module.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,15 @@ class ModuleDecl
357357
ModuleABIName = name;
358358
}
359359

360+
/// Retrieve the actual module name of an alias used for this module (if any).
361+
///
362+
/// For example, if '-module-alias Foo=Bar' is passed in when building the main module,
363+
/// and this module is (a) not the main module and (b) is named Foo, then it returns
364+
/// the real (physically on-disk) module name Bar.
365+
///
366+
/// If no module aliasing is set, it will return getName(), i.e. Foo.
367+
Identifier getRealName() const;
368+
360369
/// User-defined module version number.
361370
llvm::VersionTuple UserModuleVersion;
362371
void setUserModuleVersion(llvm::VersionTuple UserVer) {
@@ -365,6 +374,7 @@ class ModuleDecl
365374
llvm::VersionTuple getUserModuleVersion() const {
366375
return UserModuleVersion;
367376
}
377+
368378
private:
369379
/// A cache of this module's underlying module and required bystander if it's
370380
/// an underscored cross-import overlay.

include/swift/AST/SearchPathOptions.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define SWIFT_AST_SEARCHPATHOPTIONS_H
1515

1616
#include "swift/Basic/ArrayRefView.h"
17+
#include "swift/Basic/PathRemapper.h"
1718
#include "llvm/ADT/Hashing.h"
1819

1920
#include <string>
@@ -97,6 +98,11 @@ class SearchPathOptions {
9798

9899
/// A file containing modules we should perform batch scanning.
99100
std::string BatchScanInputFilePath;
101+
102+
/// Debug path mappings to apply to serialized search paths. These are
103+
/// specified in LLDB from the target.source-map entries.
104+
PathRemapper SearchPathRemapper;
105+
100106
private:
101107
static StringRef
102108
pathStringFromFrameworkSearchPath(const FrameworkSearchPath &next) {

include/swift/Basic/LangOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,9 @@ namespace swift {
771771
DisableOverlayModules,
772772
EnableClangSPI);
773773
}
774+
775+
std::vector<std::string> getRemappedExtraArgs(
776+
std::function<std::string(StringRef)> pathRemapCallback) const;
774777
};
775778

776779
} // end namespace swift

include/swift/Basic/Statistics.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ FRONTEND_STATISTIC(Sema, NumUnloadedLazyIterableDeclContexts)
268268
#include "swift/AST/TypeCheckerTypeIDZone.def"
269269
#include "swift/Sema/IDETypeCheckingRequestIDZone.def"
270270
#include "swift/IDE/IDERequestIDZone.def"
271+
#include "swift/ClangImporter/ClangImporterTypeIDZone.def"
271272
#undef SWIFT_REQUEST
272273

273274
#define SWIFT_REQUEST(ZONE, NAME, Sig, Caching, LocOptions) FRONTEND_STATISTIC(SILGen, NAME)

include/swift/Basic/TypeIDZones.def

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,39 @@
11
//===--- TypeIDZones.def - List of TypeID Zones -----------------*- C++ -*-===//
2-
//
3-
// This source file is part of the Swift.org open source project
4-
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6-
// Licensed under Apache License v2.0 with Runtime Library Exception
7-
//
8-
// See https://swift.org/LICENSE.txt for license information
9-
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10-
//
11-
//===----------------------------------------------------------------------===//
12-
//
13-
// This definition file describes the zones for TypeID.
14-
//
15-
//===----------------------------------------------------------------------===//
16-
17-
SWIFT_TYPEID_ZONE(C, 0)
18-
SWIFT_TYPEID_ZONE(AST, 1)
19-
20-
SWIFT_TYPEID_ZONE(Parse, 8)
21-
SWIFT_TYPEID_ZONE(NameLookup, 9)
22-
23-
SWIFT_TYPEID_ZONE(TypeChecker, 10)
24-
SWIFT_TYPEID_ZONE(AccessControl, 11)
25-
SWIFT_TYPEID_ZONE(SILGen, 12)
26-
SWIFT_TYPEID_ZONE(SILOptimizer, 13)
27-
SWIFT_TYPEID_ZONE(TBDGen, 14)
28-
29-
SWIFT_TYPEID_ZONE(IRGen, 20)
30-
31-
SWIFT_TYPEID_ZONE(IDETypeChecking, 97)
32-
33-
SWIFT_TYPEID_ZONE(IDETypes, 136)
34-
SWIFT_TYPEID_ZONE(IDE, 137)
35-
36-
// N.B. This is not a formal zone and exists solely to support the unit tests.
37-
SWIFT_TYPEID_ZONE(ArithmeticEvaluator, 255)
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// This definition file describes the zones for TypeID.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
SWIFT_TYPEID_ZONE(C, 0)
18+
SWIFT_TYPEID_ZONE(AST, 1)
19+
20+
SWIFT_TYPEID_ZONE(Parse, 8)
21+
SWIFT_TYPEID_ZONE(NameLookup, 9)
22+
23+
SWIFT_TYPEID_ZONE(TypeChecker, 10)
24+
SWIFT_TYPEID_ZONE(AccessControl, 11)
25+
SWIFT_TYPEID_ZONE(SILGen, 12)
26+
SWIFT_TYPEID_ZONE(SILOptimizer, 13)
27+
SWIFT_TYPEID_ZONE(TBDGen, 14)
28+
29+
SWIFT_TYPEID_ZONE(IRGen, 20)
30+
31+
SWIFT_TYPEID_ZONE(IDETypeChecking, 97)
32+
33+
SWIFT_TYPEID_ZONE(IDETypes, 136)
34+
SWIFT_TYPEID_ZONE(IDE, 137)
35+
36+
SWIFT_TYPEID_ZONE(ClangImporter, 139)
37+
38+
// N.B. This is not a formal zone and exists solely to support the unit tests.
39+
SWIFT_TYPEID_ZONE(ArithmeticEvaluator, 255)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//===--- ClangImporterRequests.h - Clang Importer Requests ------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2021 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// This file defines clang-importer requests.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
#ifndef SWIFT_CLANG_IMPORTER_REQUESTS_H
17+
#define SWIFT_CLANG_IMPORTER_REQUESTS_H
18+
19+
#include "swift/AST/SimpleRequest.h"
20+
#include "swift/AST/ASTTypeIDs.h"
21+
#include "swift/AST/EvaluatorDependencies.h"
22+
23+
namespace swift {
24+
25+
#define SWIFT_TYPEID_ZONE ClangImporter
26+
#define SWIFT_TYPEID_HEADER "swift/ClangImporter/ClangImporterTypeIDZone.def"
27+
#include "swift/Basic/DefineTypeIDZone.h"
28+
#undef SWIFT_TYPEID_ZONE
29+
#undef SWIFT_TYPEID_HEADER
30+
31+
// Set up reporting of evaluated requests.
32+
template<typename Request>
33+
void reportEvaluatedRequest(UnifiedStatsReporter &stats,
34+
const Request &request);
35+
36+
#define SWIFT_REQUEST(Zone, RequestType, Sig, Caching, LocOptions) \
37+
template <> \
38+
inline void reportEvaluatedRequest(UnifiedStatsReporter &stats, \
39+
const RequestType &request) { \
40+
++stats.getFrontendCounters().RequestType; \
41+
}
42+
#include "swift/ClangImporter/ClangImporterTypeIDZone.def"
43+
#undef SWIFT_REQUEST
44+
45+
} // end namespace swift
46+
47+
#endif // SWIFT_CLANG_IMPORTER_REQUESTS_H
48+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===--- ClangImporterTypeIDZone.def ----------------------------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2021 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// This definition file describes the types in the clang importer
14+
// TypeID zone, for use with the TypeID template.
15+
//
16+
//===----------------------------------------------------------------------===//
17+

include/swift/Frontend/FrontendOptions.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ class FrontendOptions {
182182
/// module appears to not be a public module.
183183
Optional<bool> SerializeOptionsForDebugging;
184184

185+
/// When true the debug prefix map entries will be applied to debugging
186+
/// options before serialization. These can be reconstructed at debug time by
187+
/// applying the inverse map in SearchPathOptions.SearchPathRemapper.
188+
bool DebugPrefixSerializedDebuggingOptions = false;
189+
185190
/// When true, check if all required SwiftOnoneSupport symbols are present in
186191
/// the module.
187192
bool CheckOnoneSupportCompleteness = false;

0 commit comments

Comments
 (0)