Skip to content

Commit 3f9a378

Browse files
hamishknightetcwilde
authored andcommitted
[AST] Upgrade MainDecl to a ValueDecl
This will make it easier to store in a SILDeclRef.
1 parent 7ae40f4 commit 3f9a378

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

include/swift/AST/FileUnit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ class FileUnit : public DeclContext {
273273
return dyn_cast_or_null<ClassDecl>(getMainDecl());
274274
}
275275
bool hasMainDecl() const { return getMainDecl(); }
276-
virtual Decl *getMainDecl() const { return nullptr; }
276+
virtual ValueDecl *getMainDecl() const { return nullptr; }
277277
FuncDecl *getMainFunc() const {
278278
return dyn_cast_or_null<FuncDecl>(getMainDecl());
279279
}

include/swift/AST/SourceFile.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class SourceFile final : public FileUnit {
9999

100100
/// Either the class marked \@NS/UIApplicationMain or the synthesized FuncDecl
101101
/// that calls main on the type marked @main.
102-
Decl *MainDecl = nullptr;
102+
ValueDecl *MainDecl = nullptr;
103103

104104
/// The source location of the main type.
105105
SourceLoc MainDeclDiagLoc;
@@ -488,7 +488,7 @@ class SourceFile final : public FileUnit {
488488
llvm_unreachable("bad SourceFileKind");
489489
}
490490

491-
Decl *getMainDecl() const override { return MainDecl; }
491+
ValueDecl *getMainDecl() const override { return MainDecl; }
492492
SourceLoc getMainDeclDiagLoc() const {
493493
assert(hasMainDecl());
494494
return MainDeclDiagLoc;
@@ -502,7 +502,7 @@ class SourceFile final : public FileUnit {
502502
/// one.
503503
///
504504
/// Should only be called during type-checking.
505-
bool registerMainDecl(Decl *mainDecl, SourceLoc diagLoc);
505+
bool registerMainDecl(ValueDecl *mainDecl, SourceLoc diagLoc);
506506

507507
/// True if this source file has an application entry point.
508508
///

include/swift/Serialization/SerializedModuleLoader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ class SerializedASTFile final : public LoadedFile {
433433

434434
virtual StringRef getModuleDefiningPath() const override;
435435

436-
Decl *getMainDecl() const override;
436+
ValueDecl *getMainDecl() const override;
437437

438438
bool hasEntryPoint() const override;
439439

lib/AST/Module.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1587,7 +1587,7 @@ bool ModuleDecl::isBuiltinModule() const {
15871587
return this == getASTContext().TheBuiltinModule;
15881588
}
15891589

1590-
bool SourceFile::registerMainDecl(Decl *mainDecl, SourceLoc diagLoc) {
1590+
bool SourceFile::registerMainDecl(ValueDecl *mainDecl, SourceLoc diagLoc) {
15911591
assert(mainDecl);
15921592
if (mainDecl == MainDecl)
15931593
return false;

lib/Serialization/ModuleFile.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,9 +1262,9 @@ bool SerializedASTFile::getAllGenericSignatures(
12621262
return true;
12631263
}
12641264

1265-
Decl *SerializedASTFile::getMainDecl() const {
1265+
ValueDecl *SerializedASTFile::getMainDecl() const {
12661266
assert(hasEntryPoint());
1267-
return File.getDecl(File.getEntryPointDeclID());
1267+
return cast_or_null<ValueDecl>(File.getDecl(File.getEntryPointDeclID()));
12681268
}
12691269

12701270
const version::Version &SerializedASTFile::getLanguageVersionBuiltWith() const {

0 commit comments

Comments
 (0)