mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Objective-C method unintended override checking is one such case where properly checking unintended overrides requires us to essentially look at the whole module, because one translation unit may declare something that produces an Objective-C method "setFoo:" in a superclass while another translation unit declares something with a distinct name that produces an Objective-C method "setFoo:". So, when we don't have a primary file (e.g., when we're doing the merge-module step), delay such checks until after all the source files for the module have been type-checked. When there is a primary file, we perform the checking that we can based on type checking that primary file (and whatever got touched along the way), so we get a subset of the proper diagnostics. Swift SVN r23179
47 lines
1.7 KiB
C++
47 lines
1.7 KiB
C++
//===-- Helpers.cpp - frontend utility methods ----------------------------===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See http://swift.org/LICENSE.txt for license information
|
|
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "swift/Immediate/Helpers.h"
|
|
|
|
#include "swift/Immediate/Immediate.h"
|
|
#include "swift/SIL/SILModule.h"
|
|
#include "swift/AST/ASTContext.h"
|
|
#include "swift/AST/Module.h"
|
|
#include "swift/Basic/SourceManager.h"
|
|
#include "swift/Parse/PersistentParserState.h"
|
|
#include "swift/Subsystems.h"
|
|
#include "swift/SILPasses/Passes.h"
|
|
using namespace swift;
|
|
|
|
bool swift::appendToREPLFile(SourceFile &SF,
|
|
PersistentParserState &PersistentState,
|
|
REPLContext &RC,
|
|
std::unique_ptr<llvm::MemoryBuffer> Buffer) {
|
|
assert(SF.Kind == SourceFileKind::REPL && "Can't append to a non-REPL file");
|
|
|
|
SourceManager &SrcMgr = SF.getParentModule()->Ctx.SourceMgr;
|
|
RC.CurBufferID = SrcMgr.addNewSourceBuffer(std::move(Buffer));
|
|
|
|
bool FoundAnySideEffects = false;
|
|
unsigned CurElem = RC.CurElem;
|
|
bool Done;
|
|
do {
|
|
FoundAnySideEffects |=
|
|
parseIntoSourceFile(SF, RC.CurBufferID, &Done, nullptr,
|
|
&PersistentState);
|
|
performTypeChecking(SF, PersistentState.getTopLevelContext(), None,
|
|
CurElem);
|
|
CurElem = SF.Decls.size();
|
|
} while (!Done);
|
|
return FoundAnySideEffects;
|
|
}
|