mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Record whether a file contains a main entry point in the serialized module.
This isn't being used for much yet, but it will allow us to tell whether something is an app target even at the module-merging stage, which is a better way to tell if something is an app than whether it has a bridging header. We'll also need this if we ever take advantage of reusing "partial modules" (serialized ASTs for other parts of the module that aren't affected by the current source file) for compiling source files in incremental builds; unfortunately that's unlikely given our dependency model. Swift SVN r24531
This commit is contained in:
@@ -1267,19 +1267,16 @@ bool Module::registerEntryPointFile(FileUnit *file, SourceLoc diagLoc,
|
||||
}
|
||||
|
||||
FileUnit *existingFile = MainInfo.getMainFile();
|
||||
const ClassDecl *existingClass = nullptr;
|
||||
const ClassDecl *existingClass = existingFile->getMainClass();
|
||||
SourceLoc existingDiagLoc;
|
||||
|
||||
if (auto *sourceFile = dyn_cast<SourceFile>(existingFile)) {
|
||||
if ((existingClass = sourceFile->getMainClass())) {
|
||||
if (existingClass) {
|
||||
existingDiagLoc = sourceFile->getMainClassDiagLoc();
|
||||
} else {
|
||||
if (auto bufID = sourceFile->getBufferID())
|
||||
existingDiagLoc = Ctx.SourceMgr.getLocForBufferStart(*bufID);
|
||||
}
|
||||
|
||||
} else {
|
||||
// FIXME: Handle the non-source-file case.
|
||||
}
|
||||
|
||||
if (existingClass) {
|
||||
@@ -1303,8 +1300,8 @@ bool Module::registerEntryPointFile(FileUnit *file, SourceLoc diagLoc,
|
||||
// We don't have an existing class, but we /do/ have a file in script mode.
|
||||
// Diagnose that.
|
||||
if (MainInfo.markDiagnosedMainClassWithScript()) {
|
||||
Ctx.Diags.diagnose(diagLoc, diag::attr_ApplicationMain_with_script,
|
||||
mainClassDiagKind);
|
||||
Ctx.Diags.diagnose(diagLoc, diag::attr_ApplicationMain_with_script,
|
||||
mainClassDiagKind);
|
||||
|
||||
if (existingDiagLoc.isValid()) {
|
||||
Ctx.Diags.diagnose(existingDiagLoc,
|
||||
|
||||
Reference in New Issue
Block a user