Skip to content

Commit

Permalink
Merge pull request swiftlang#20458 from graydon/text-interface-format…
Browse files Browse the repository at this point in the history
…-version

Text interface format version
  • Loading branch information
graydon authored Nov 14, 2018
2 parents 9debb38 + 74dc5a1 commit f212d18
Show file tree
Hide file tree
Showing 25 changed files with 341 additions and 85 deletions.
14 changes: 14 additions & 0 deletions include/swift/AST/DiagnosticConsumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

namespace swift {
class DiagnosticArgument;
class DiagnosticEngine;
class SourceManager;
enum class DiagID : uint32_t;

Expand Down Expand Up @@ -122,6 +123,19 @@ class NullDiagnosticConsumer : public DiagnosticConsumer {
const DiagnosticInfo &Info) override;
};

/// \brief DiagnosticConsumer that forwards diagnostics to the consumers of
// another DiagnosticEngine.
class ForwardingDiagnosticConsumer : public DiagnosticConsumer {
DiagnosticEngine &TargetEngine;
public:
ForwardingDiagnosticConsumer(DiagnosticEngine &Target);
void handleDiagnostic(SourceManager &SM, SourceLoc Loc,
DiagnosticKind Kind,
StringRef FormatString,
ArrayRef<DiagnosticArgument> FormatArgs,
const DiagnosticInfo &Info) override;
};

/// \brief DiagnosticConsumer that funnels diagnostics in certain files to
/// particular sub-consumers.
///
Expand Down
5 changes: 5 additions & 0 deletions include/swift/AST/DiagnosticEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,11 @@ namespace swift {
return Result;
}

/// \brief Return all \c DiagnosticConsumers.
ArrayRef<DiagnosticConsumer *> getConsumers() {
return Consumers;
}

/// \brief Emit a diagnostic using a preformatted array of diagnostic
/// arguments.
///
Expand Down
9 changes: 9 additions & 0 deletions include/swift/AST/DiagnosticsFrontend.def
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,17 @@ WARNING(parseable_interface_scoped_import_unsupported,none,
())
ERROR(error_extracting_version_from_parseable_interface,none,
"error extracting version from parseable module interface", ())
ERROR(unsupported_version_of_parseable_interface,none,
"unsupported version of parseable module interface '%0': '%1'",
(StringRef, llvm::VersionTuple))
ERROR(error_extracting_flags_from_parseable_interface,none,
"error extracting flags from parseable module interface", ())
ERROR(missing_dependency_of_parseable_module_interface,none,
"missing dependency '%0' of parseable module interface '%1': %2",
(StringRef, StringRef, StringRef))
ERROR(error_extracting_dependencies_from_cached_module,none,
"error extracting dependencies from cached module '%0'",
(StringRef))

#ifndef DIAG_NO_UNDEF
# if defined(DIAG)
Expand Down
7 changes: 1 addition & 6 deletions include/swift/AST/ModuleLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,12 @@ class DependencyTracker {

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

protected:
DependencyTracker * const dependencyTracker;
ModuleLoader(DependencyTracker *tracker) : dependencyTracker(tracker) {}

void addDependency(StringRef file, bool IsSystem=false) {
if (dependencyTracker)
dependencyTracker->addDependency(file, IsSystem);
}

public:
virtual ~ModuleLoader() = default;

Expand Down
2 changes: 0 additions & 2 deletions include/swift/ClangImporter/ClangImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,6 @@ class ClangImporter final : public ClangModuleLoader {
/// Writes the mangled name of \p clangDecl to \p os.
void getMangledName(raw_ostream &os, const clang::NamedDecl *clangDecl) const;

using ClangModuleLoader::addDependency;

// Print statistics from the Clang AST reader.
void printStatistics() const override;

Expand Down
2 changes: 1 addition & 1 deletion include/swift/Frontend/ParseableInterfaceSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct ParseableInterfaceOptions {
std::string ParseableInterfaceFlags;
};

llvm::Regex getSwiftInterfaceToolsVersionRegex();
llvm::Regex getSwiftInterfaceFormatVersionRegex();
llvm::Regex getSwiftInterfaceModuleFlagsRegex();

/// Emit a stable, parseable interface for \p M, which can be used by a client
Expand Down
5 changes: 3 additions & 2 deletions include/swift/Serialization/ModuleFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
/// describe what change you made. The content of this comment isn't important;
/// it just ensures a conflict if two people change the module format.
/// Don't worry about adhering to the 80-column limit for this line.
const uint16_t SWIFTMODULE_VERSION_MINOR = 466; // Last change: add isAutoClosure flag to param
const uint16_t SWIFTMODULE_VERSION_MINOR = 467; // Last change: switch FILE_DEPENDENCY records to hashes.

using DeclIDField = BCFixed<31>;

Expand Down Expand Up @@ -108,6 +108,7 @@ using CharOffsetField = BitOffsetField;

using FileSizeField = BCVBR<16>;
using FileModTimeField = BCVBR<16>;
using FileHashField = BCVBR<16>;

// These IDs must \em not be renumbered or reordered without incrementing
// the module version.
Expand Down Expand Up @@ -652,7 +653,7 @@ namespace input_block {
IMPORTED_HEADER,
BCFixed<1>, // exported?
FileSizeField, // file size (for validation)
FileModTimeField, // file mtime (for validation)
FileHashField, // file hash (for validation)
BCBlob // file path
>;

Expand Down
4 changes: 2 additions & 2 deletions include/swift/Serialization/SerializationOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ namespace swift {

struct FileDependency {
uint64_t Size;
llvm::sys::TimePoint<> LastModTime;
StringRef Path;
uint64_t Hash;
std::string Path;
};
ArrayRef<FileDependency> Dependencies;

Expand Down
18 changes: 18 additions & 0 deletions lib/AST/DiagnosticConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,21 @@ void NullDiagnosticConsumer::handleDiagnostic(
llvm::dbgs() << "\n";
});
}

ForwardingDiagnosticConsumer::ForwardingDiagnosticConsumer(DiagnosticEngine &Target)
: TargetEngine(Target) {}

void ForwardingDiagnosticConsumer::handleDiagnostic(
SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
StringRef FormatString, ArrayRef<DiagnosticArgument> FormatArgs,
const DiagnosticInfo &Info) {
LLVM_DEBUG({
llvm::dbgs() << "ForwardingDiagnosticConsumer received diagnostic: ";
DiagnosticEngine::formatDiagnosticText(llvm::dbgs(), FormatString,
FormatArgs);
llvm::dbgs() << "\n";
});
for (auto *C : TargetEngine.getConsumers()) {
C->handleDiagnostic(SM, Loc, Kind, FormatString, FormatArgs, Info);
}
}
Loading

0 comments on commit f212d18

Please sign in to comment.