Skip to content

Commit f0d7859

Browse files
authored
---
yaml --- r: 445651 b: refs/heads/master-rebranch c: 0b7fea6 h: refs/heads/master i: 445649: 4bc5a57 445647: f7d76ae
1 parent d22e3a8 commit f0d7859

File tree

75 files changed

+928
-242
lines changed

Some content is hidden

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

75 files changed

+928
-242
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1701,7 +1701,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-12-19-a: 550bd4128211e1135c31ab186d2a9
17011701
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-12-20-a: f3e865a19683d7e9664718c41e4e956686efb1b3
17021702
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-12-21-a: 0852188b163c7ebd7054379e729cedc41c361f95
17031703
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-12-22-a: 4832e0c5e8723b7b4a2c626ac6a8a523576f1317
1704-
refs/heads/master-rebranch: 3e0e8cec7a5129f3cb7495bbb371085608f52a2f
1704+
refs/heads/master-rebranch: 0b7fea60365b2c3a7648f35a78dcd7fe5f959654
17051705
refs/heads/revert-29064-handle-csdiag-coerce-diagnostics: 69656f1629e2cde21bb7f44179c535c1f3ad5dfd
17061706
refs/heads/swift-5.1-DEVELOPMENT-SNAPSHOT-2018-11-16-a: 51fe19105062bb86b997c7698bb3f83ffc536d2c
17071707
refs/heads/tgmath-derivatives-wip: 00adac82d118281f701c26fe8702ecb4bbe33e82

branches/master-rebranch/include/swift/AST/ASTContext.h

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,6 @@ class ASTContext final {
254254
/// The request-evaluator that is used to process various requests.
255255
Evaluator evaluator;
256256

257-
/// The set of top-level modules we have loaded.
258-
/// This map is used for iteration, therefore it's a MapVector and not a
259-
/// DenseMap.
260-
llvm::MapVector<Identifier, ModuleDecl*> LoadedModules;
261-
262257
/// The builtin module.
263258
ModuleDecl * const TheBuiltinModule;
264259

@@ -787,8 +782,24 @@ class ASTContext final {
787782
/// The loader is owned by the AST context.
788783
ClangModuleLoader *getDWARFModuleLoader() const;
789784

785+
public:
790786
namelookup::ImportCache &getImportCache() const;
791787

788+
/// Returns an iterator over the modules that are known by this context
789+
/// to be loaded.
790+
///
791+
/// Iteration order is guaranteed to match the order in which
792+
/// \c addLoadedModule was called to register the loaded module
793+
/// with this context.
794+
iterator_range<llvm::MapVector<Identifier, ModuleDecl *>::const_iterator>
795+
getLoadedModules() const;
796+
797+
/// Returns the number of loaded modules known by this context to be loaded.
798+
unsigned getNumLoadedModules() const {
799+
auto eltRange = getLoadedModules();
800+
return std::distance(eltRange.begin(), eltRange.end());
801+
}
802+
792803
/// Asks every module loader to verify the ASTs it has loaded.
793804
///
794805
/// Does nothing in non-asserts (NDEBUG) builds.
@@ -828,6 +839,11 @@ class ASTContext final {
828839
return const_cast<ASTContext *>(this)->getStdlibModule(false);
829840
}
830841

842+
/// Insert an externally-sourced module into the set of known loaded modules
843+
/// in this context.
844+
void addLoadedModule(ModuleDecl *M);
845+
846+
public:
831847
/// Retrieve the current generation number, which reflects the
832848
/// number of times a module import has caused mass invalidation of
833849
/// lookup tables.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
swift_install_in_component(DIRECTORY diagnostics
2+
DESTINATION "share/swift/"
3+
COMPONENT compiler)

branches/master-rebranch/include/swift/AST/DiagnosticEngine.h

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ namespace swift {
5858
DiagID ID;
5959
};
6060

61+
struct DiagnosticNode {
62+
DiagID id;
63+
std::string msg;
64+
};
65+
6166
namespace detail {
6267
/// Describes how to pass a diagnostic argument of the given type.
6368
///
@@ -629,7 +634,26 @@ namespace swift {
629634
DiagnosticState(DiagnosticState &&) = default;
630635
DiagnosticState &operator=(DiagnosticState &&) = default;
631636
};
632-
637+
638+
class LocalizationProducer {
639+
public:
640+
/// If the message isn't available/localized in the current `yaml` file,
641+
/// return the fallback default message.
642+
virtual std::string getMessageOr(DiagID id,
643+
std::string defaultMessage) const {
644+
return defaultMessage;
645+
}
646+
647+
virtual ~LocalizationProducer() {}
648+
};
649+
650+
class YAMLLocalizationProducer final : public LocalizationProducer {
651+
public:
652+
std::vector<std::string> diagnostics;
653+
explicit YAMLLocalizationProducer(std::string locale, std::string path);
654+
std::string getMessageOr(DiagID id,
655+
std::string defaultMessage) const override;
656+
};
633657
/// Class responsible for formatting diagnostics and presenting them
634658
/// to the user.
635659
class DiagnosticEngine {
@@ -663,6 +687,10 @@ namespace swift {
663687
/// but rather stored until all transactions complete.
664688
llvm::StringSet<llvm::BumpPtrAllocator &> TransactionStrings;
665689

690+
/// Diagnostic producer to handle the logic behind retriving a localized
691+
/// diagnostic message.
692+
std::unique_ptr<LocalizationProducer> localization;
693+
666694
/// The number of open diagnostic transactions. Diagnostics are only
667695
/// emitted once all transactions have closed.
668696
unsigned TransactionCount = 0;
@@ -734,6 +762,11 @@ namespace swift {
734762
return diagnosticDocumentationPath;
735763
}
736764

765+
void setLocalization(std::string locale, std::string path) {
766+
if (!locale.empty() && !path.empty())
767+
localization = std::make_unique<YAMLLocalizationProducer>(locale, path);
768+
}
769+
737770
void ignoreDiagnostic(DiagID id) {
738771
state.setDiagnosticBehavior(id, DiagnosticState::Behavior::Ignore);
739772
}
@@ -955,8 +988,7 @@ namespace swift {
955988
void emitTentativeDiagnostics();
956989

957990
public:
958-
static const char *diagnosticStringFor(const DiagID id,
959-
bool printDiagnosticName);
991+
const char *diagnosticStringFor(const DiagID id, bool printDiagnosticName);
960992

961993
/// If there is no clear .dia file for a diagnostic, put it in the one
962994
/// corresponding to the SourceLoc given here.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//===--- DiagnosticMessageFormat.h - YAML format for Diagnostic Messages ---*-
2+
//C++ -*-===//
3+
//
4+
// This source file is part of the Swift.org open source project
5+
//
6+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
7+
// Licensed under Apache License v2.0 with Runtime Library Exception
8+
//
9+
// See https://swift.org/LICENSE.txt for license information
10+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
11+
//
12+
//===----------------------------------------------------------------------===//
13+
//
14+
// This file defines the YAML format for diagnostic messages.
15+
//
16+
//===----------------------------------------------------------------------===//
17+
18+
#include "DiagnosticList.cpp"
19+
#include "llvm/Support/YAMLTraits.h"
20+
21+
namespace llvm {
22+
namespace yaml {
23+
24+
template <> struct ScalarEnumerationTraits<swift::DiagID> {
25+
static void enumeration(IO &io, swift::DiagID &value) {
26+
#define DIAG(KIND, ID, Options, Text, Signature) \
27+
io.enumCase(value, #ID, swift::DiagID::ID);
28+
#include "swift/AST/DiagnosticsAll.def"
29+
}
30+
};
31+
32+
template <> struct MappingTraits<swift::DiagnosticNode> {
33+
static void mapping(IO &io, swift::DiagnosticNode &node) {
34+
io.mapRequired("id", node.id);
35+
io.mapRequired("msg", node.msg);
36+
}
37+
};
38+
39+
} // namespace yaml
40+
} // namespace llvm
41+
42+
LLVM_YAML_IS_SEQUENCE_VECTOR(swift::DiagnosticNode)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#===--- fr.yaml - Localized diagnostic messages for French ---*- YAML -*-===#
2+
#
3+
# This source file is part of the Swift.org open source project
4+
#
5+
# Copyright (c) 2014 - 2020 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 the diagnostic messages for French language.
14+
# Each diagnostic is described in the following format:
15+
# - id: <diagnostic-id>
16+
# msg: <diagnostic-message>
17+
#
18+
#===----------------------------------------------------------------------===#
19+

branches/master-rebranch/include/swift/AST/DiagnosticsFrontend.def

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,14 @@ ERROR(previous_installname_map_corrupted,none,
251251
"previous install name map from %0 is malformed",
252252
(StringRef))
253253

254+
ERROR(explicit_swift_module_map_missing,none,
255+
"cannot open explicit Swift module map from %0",
256+
(StringRef))
257+
258+
ERROR(explicit_swift_module_map_corrupted,none,
259+
"explicit Swift module map from %0 is malformed",
260+
(StringRef))
261+
254262
REMARK(default_previous_install_name, none,
255263
"default previous install name for %0 is %1", (StringRef, StringRef))
256264

branches/master-rebranch/include/swift/AST/FineGrainedDependencies.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "swift/Basic/Range.h"
2020
#include "swift/Basic/ReferenceDependencyKeys.h"
2121
#include "llvm/ADT/Hashing.h"
22+
#include "llvm/ADT/SetVector.h"
2223
#include "llvm/Support/MD5.h"
2324
#include "llvm/Support/MemoryBuffer.h"
2425
#include "llvm/Support/YAMLParser.h"
@@ -684,7 +685,7 @@ class SourceFileDepGraphNode : public DepGraphNode {
684685
size_t sequenceNumber = ~0;
685686

686687
/// Holds the sequence numbers of definitions I depend upon.
687-
std::unordered_set<size_t> defsIDependUpon;
688+
llvm::SetVector<size_t> defsIDependUpon;
688689

689690
/// True iff a Decl exists for this node.
690691
/// If a provides and a depends in the existing system both have the same key,

branches/master-rebranch/include/swift/AST/SearchPathOptions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ class SearchPathOptions {
8585
/// The paths to a set of explicitly built modules from interfaces.
8686
std::vector<std::string> ExplicitSwiftModules;
8787

88+
/// A map of explict Swift module information.
89+
std::string ExplicitSwiftModuleMap;
8890
private:
8991
static StringRef
9092
pathStringFromFrameworkSearchPath(const FrameworkSearchPath &next) {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#===--- en.yaml - Localized diagnostic messages for English ---*- YAML -*-===#
2+
#
3+
# This source file is part of the Swift.org open source project
4+
#
5+
# Copyright (c) 2014 - 2020 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 the diagnostic messages for English language.
14+
# Each diagnostic is described in the following format:
15+
# - id: <diagnostic-id>
16+
# msg: <diagnostic-message>
17+
#
18+
#===----------------------------------------------------------------------===#
19+

branches/master-rebranch/include/swift/Frontend/ModuleInterfaceLoader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class ExplicitSwiftModuleLoader: public SerializedModuleLoaderBase {
150150
create(ASTContext &ctx,
151151
DependencyTracker *tracker, ModuleLoadingMode loadMode,
152152
ArrayRef<std::string> ExplicitModulePaths,
153+
StringRef ExplicitSwiftModuleMap,
153154
bool IgnoreSwiftSourceInfoFile);
154155

155156
/// Append visible module names to \p names. Note that names are possibly
@@ -244,7 +245,6 @@ struct InterfaceSubContextDelegateImpl: InterfaceSubContextDelegate {
244245
llvm::StringSaver ArgSaver;
245246
std::vector<StringRef> GenericArgs;
246247
CompilerInvocation subInvocation;
247-
std::vector<SupplementaryOutputPaths> ModuleOutputPaths;
248248

249249
template<typename ...ArgTypes>
250250
InFlightDiagnostic diagnose(StringRef interfacePath,

branches/master-rebranch/include/swift/Option/FrontendOptions.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ def disable_implicit_swift_modules: Flag<["-"], "disable-implicit-swift-modules"
220220
def swift_module_file
221221
: Separate<["-"], "swift-module-file">, MetaVarName<"<path>">,
222222
HelpText<"Specify Swift module explicitly built from textual interface">;
223+
224+
def explict_swift_module_map
225+
: Separate<["-"], "explicit-swift-module-map-file">, MetaVarName<"<path>">,
226+
HelpText<"Specify a JSON file containing information of explict Swift modules">;
223227
}
224228

225229

branches/master-rebranch/include/swift/Reflection/ReflectionContext.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,18 @@ class ReflectionContext
838838
return 0;
839839
}
840840

841+
/// Get the name of a metadata tag, if known.
842+
llvm::Optional<std::string> metadataAllocationTagName(int Tag) {
843+
switch (Tag) {
844+
#define TAG(name, value) \
845+
case value: \
846+
return std::string(#name);
847+
#include "../../../stdlib/public/runtime/MetadataAllocatorTags.def"
848+
default:
849+
return llvm::None;
850+
}
851+
}
852+
841853
/// Iterate the metadata allocations in the target process, calling Call with
842854
/// each allocation found. Returns None on success, and a string describing
843855
/// the error on failure.

branches/master-rebranch/include/swift/Runtime/Metadata.h

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,9 @@ namespace swift {
2929
// allocator. This is encoded in a header on each allocation when metadata
3030
// iteration is enabled, and allows tools to know where each allocation came
3131
// from.
32-
//
33-
// Some of these values are also declared in SwiftRemoteMirrorTypes.h. Those
34-
// values must be kept stable to preserve compatibility.
3532
enum MetadataAllocatorTags : uint16_t {
36-
UnusedTag = 0,
37-
BoxesTag,
38-
ObjCClassWrappersTag,
39-
FunctionTypesTag,
40-
MetatypeTypesTag,
41-
ExistentialMetatypeValueWitnessTablesTag,
42-
ExistentialMetatypesTag,
43-
ExistentialTypesTag,
44-
OpaqueExistentialValueWitnessTablesTag,
45-
ClassExistentialValueWitnessTablesTag,
46-
ForeignWitnessTablesTag,
47-
ResilientMetadataAllocatorTag,
48-
MetadataTag,
49-
TupleCacheTag,
50-
GenericMetadataCacheTag,
51-
ForeignMetadataCacheTag,
52-
GenericWitnessTableCacheTag,
53-
GenericClassMetadataTag,
54-
GenericValueMetadataTag,
33+
#define TAG(name, value) name##Tag = value,
34+
#include "../../../stdlib/public/runtime/MetadataAllocatorTags.def"
5535
};
5636

5737
template <typename Runtime> struct MetadataAllocationBacktraceHeader {

branches/master-rebranch/include/swift/SwiftRemoteMirror/SwiftRemoteMirror.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,16 +324,24 @@ const char *swift_reflection_iterateMetadataAllocations(
324324
/// Given a metadata allocation, return the metadata it points to. Returns NULL
325325
/// on failure. Despite the name, not all allocations point to metadata.
326326
/// Currently, this will return a metadata only for allocations with tag
327-
/// SWIFT_GENERIC_METADATA_CACHE_ALLOCATION. Support for additional tags may be
328-
/// added in the future. The caller must gracefully handle failure.
327+
/// GenericMetadataCache. Support for additional tags may be added in the
328+
/// future. The caller must gracefully handle failure.
329329
SWIFT_REMOTE_MIRROR_LINKAGE
330330
swift_reflection_ptr_t swift_reflection_allocationMetadataPointer(
331331
SwiftReflectionContextRef ContextRef,
332332
swift_metadata_allocation_t Allocation);
333333

334+
/// Return the name of a metadata allocation tag, or NULL if the tag is unknown.
335+
/// This pointer remains valid until the next swift_reflection call on the given
336+
/// context.
337+
SWIFT_REMOTE_MIRROR_LINKAGE
338+
const char *
339+
swift_reflection_metadataAllocationTagName(SwiftReflectionContextRef ContextRef,
340+
swift_metadata_allocation_tag_t Tag);
341+
334342
/// Backtrace iterator callback passed to
335343
/// swift_reflection_iterateMetadataAllocationBacktraces
336-
typedef void (*swift_metadataAllocationIterator)(
344+
typedef void (*swift_metadataAllocationBacktraceIterator)(
337345
swift_reflection_ptr_t AllocationPtr, size_t Count,
338346
const swift_reflection_ptr_t Ptrs[], void *ContextPtr);
339347

@@ -350,8 +358,8 @@ typedef void (*swift_metadataAllocationIterator)(
350358
/// swift_reflection call on the given context.
351359
SWIFT_REMOTE_MIRROR_LINKAGE
352360
const char *swift_reflection_iterateMetadataAllocationBacktraces(
353-
SwiftReflectionContextRef ContextRef, swift_metadataAllocationIterator Call,
354-
void *ContextPtr);
361+
SwiftReflectionContextRef ContextRef,
362+
swift_metadataAllocationBacktraceIterator Call, void *ContextPtr);
355363

356364
#ifdef __cplusplus
357365
} // extern "C"

0 commit comments

Comments
 (0)