Skip to content

Commit f212d18

Browse files
authored
Merge pull request swiftlang#20458 from graydon/text-interface-format-version
Text interface format version
2 parents 9debb38 + 74dc5a1 commit f212d18

25 files changed

+341
-85
lines changed

include/swift/AST/DiagnosticConsumer.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
namespace swift {
2727
class DiagnosticArgument;
28+
class DiagnosticEngine;
2829
class SourceManager;
2930
enum class DiagID : uint32_t;
3031

@@ -122,6 +123,19 @@ class NullDiagnosticConsumer : public DiagnosticConsumer {
122123
const DiagnosticInfo &Info) override;
123124
};
124125

126+
/// \brief DiagnosticConsumer that forwards diagnostics to the consumers of
127+
// another DiagnosticEngine.
128+
class ForwardingDiagnosticConsumer : public DiagnosticConsumer {
129+
DiagnosticEngine &TargetEngine;
130+
public:
131+
ForwardingDiagnosticConsumer(DiagnosticEngine &Target);
132+
void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
133+
DiagnosticKind Kind,
134+
StringRef FormatString,
135+
ArrayRef<DiagnosticArgument> FormatArgs,
136+
const DiagnosticInfo &Info) override;
137+
};
138+
125139
/// \brief DiagnosticConsumer that funnels diagnostics in certain files to
126140
/// particular sub-consumers.
127141
///

include/swift/AST/DiagnosticEngine.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,11 @@ namespace swift {
604604
return Result;
605605
}
606606

607+
/// \brief Return all \c DiagnosticConsumers.
608+
ArrayRef<DiagnosticConsumer *> getConsumers() {
609+
return Consumers;
610+
}
611+
607612
/// \brief Emit a diagnostic using a preformatted array of diagnostic
608613
/// arguments.
609614
///

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,17 @@ WARNING(parseable_interface_scoped_import_unsupported,none,
265265
())
266266
ERROR(error_extracting_version_from_parseable_interface,none,
267267
"error extracting version from parseable module interface", ())
268+
ERROR(unsupported_version_of_parseable_interface,none,
269+
"unsupported version of parseable module interface '%0': '%1'",
270+
(StringRef, llvm::VersionTuple))
268271
ERROR(error_extracting_flags_from_parseable_interface,none,
269272
"error extracting flags from parseable module interface", ())
273+
ERROR(missing_dependency_of_parseable_module_interface,none,
274+
"missing dependency '%0' of parseable module interface '%1': %2",
275+
(StringRef, StringRef, StringRef))
276+
ERROR(error_extracting_dependencies_from_cached_module,none,
277+
"error extracting dependencies from cached module '%0'",
278+
(StringRef))
270279

271280
#ifndef DIAG_NO_UNDEF
272281
# if defined(DIAG)

include/swift/AST/ModuleLoader.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,12 @@ class DependencyTracker {
6363

6464
/// \brief Abstract interface that loads named modules into the AST.
6565
class ModuleLoader {
66-
DependencyTracker * const dependencyTracker;
6766
virtual void anchor();
6867

6968
protected:
69+
DependencyTracker * const dependencyTracker;
7070
ModuleLoader(DependencyTracker *tracker) : dependencyTracker(tracker) {}
7171

72-
void addDependency(StringRef file, bool IsSystem=false) {
73-
if (dependencyTracker)
74-
dependencyTracker->addDependency(file, IsSystem);
75-
}
76-
7772
public:
7873
virtual ~ModuleLoader() = default;
7974

include/swift/ClangImporter/ClangImporter.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,6 @@ class ClangImporter final : public ClangModuleLoader {
326326
/// Writes the mangled name of \p clangDecl to \p os.
327327
void getMangledName(raw_ostream &os, const clang::NamedDecl *clangDecl) const;
328328

329-
using ClangModuleLoader::addDependency;
330-
331329
// Print statistics from the Clang AST reader.
332330
void printStatistics() const override;
333331

include/swift/Frontend/ParseableInterfaceSupport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct ParseableInterfaceOptions {
2929
std::string ParseableInterfaceFlags;
3030
};
3131

32-
llvm::Regex getSwiftInterfaceToolsVersionRegex();
32+
llvm::Regex getSwiftInterfaceFormatVersionRegex();
3333
llvm::Regex getSwiftInterfaceModuleFlagsRegex();
3434

3535
/// Emit a stable, parseable interface for \p M, which can be used by a client

include/swift/Serialization/ModuleFormat.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
5252
/// describe what change you made. The content of this comment isn't important;
5353
/// it just ensures a conflict if two people change the module format.
5454
/// Don't worry about adhering to the 80-column limit for this line.
55-
const uint16_t SWIFTMODULE_VERSION_MINOR = 466; // Last change: add isAutoClosure flag to param
55+
const uint16_t SWIFTMODULE_VERSION_MINOR = 467; // Last change: switch FILE_DEPENDENCY records to hashes.
5656

5757
using DeclIDField = BCFixed<31>;
5858

@@ -108,6 +108,7 @@ using CharOffsetField = BitOffsetField;
108108

109109
using FileSizeField = BCVBR<16>;
110110
using FileModTimeField = BCVBR<16>;
111+
using FileHashField = BCVBR<16>;
111112

112113
// These IDs must \em not be renumbered or reordered without incrementing
113114
// the module version.
@@ -652,7 +653,7 @@ namespace input_block {
652653
IMPORTED_HEADER,
653654
BCFixed<1>, // exported?
654655
FileSizeField, // file size (for validation)
655-
FileModTimeField, // file mtime (for validation)
656+
FileHashField, // file hash (for validation)
656657
BCBlob // file path
657658
>;
658659

include/swift/Serialization/SerializationOptions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ namespace swift {
3737

3838
struct FileDependency {
3939
uint64_t Size;
40-
llvm::sys::TimePoint<> LastModTime;
41-
StringRef Path;
40+
uint64_t Hash;
41+
std::string Path;
4242
};
4343
ArrayRef<FileDependency> Dependencies;
4444

lib/AST/DiagnosticConsumer.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,21 @@ void NullDiagnosticConsumer::handleDiagnostic(
222222
llvm::dbgs() << "\n";
223223
});
224224
}
225+
226+
ForwardingDiagnosticConsumer::ForwardingDiagnosticConsumer(DiagnosticEngine &Target)
227+
: TargetEngine(Target) {}
228+
229+
void ForwardingDiagnosticConsumer::handleDiagnostic(
230+
SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
231+
StringRef FormatString, ArrayRef<DiagnosticArgument> FormatArgs,
232+
const DiagnosticInfo &Info) {
233+
LLVM_DEBUG({
234+
llvm::dbgs() << "ForwardingDiagnosticConsumer received diagnostic: ";
235+
DiagnosticEngine::formatDiagnosticText(llvm::dbgs(), FormatString,
236+
FormatArgs);
237+
llvm::dbgs() << "\n";
238+
});
239+
for (auto *C : TargetEngine.getConsumers()) {
240+
C->handleDiagnostic(SM, Loc, Kind, FormatString, FormatArgs, Info);
241+
}
242+
}

0 commit comments

Comments
 (0)