Skip to content

Commit 2720907

Browse files
committed
[AST] Upgrade MainDecl to a ValueDecl
This will make it easier to store in a SILDeclRef.
1 parent c15dde4 commit 2720907

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
@@ -272,7 +272,7 @@ class FileUnit : public DeclContext {
272272
return dyn_cast_or_null<ClassDecl>(getMainDecl());
273273
}
274274
bool hasMainDecl() const { return getMainDecl(); }
275-
virtual Decl *getMainDecl() const { return nullptr; }
275+
virtual ValueDecl *getMainDecl() const { return nullptr; }
276276
FuncDecl *getMainFunc() const {
277277
return dyn_cast_or_null<FuncDecl>(getMainDecl());
278278
}

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;
@@ -479,7 +479,7 @@ class SourceFile final : public FileUnit {
479479
llvm_unreachable("bad SourceFileKind");
480480
}
481481

482-
Decl *getMainDecl() const override { return MainDecl; }
482+
ValueDecl *getMainDecl() const override { return MainDecl; }
483483
SourceLoc getMainDeclDiagLoc() const {
484484
assert(hasMainDecl());
485485
return MainDeclDiagLoc;
@@ -493,7 +493,7 @@ class SourceFile final : public FileUnit {
493493
/// one.
494494
///
495495
/// Should only be called during type-checking.
496-
bool registerMainDecl(Decl *mainDecl, SourceLoc diagLoc);
496+
bool registerMainDecl(ValueDecl *mainDecl, SourceLoc diagLoc);
497497

498498
/// True if this source file has an application entry point.
499499
///

include/swift/Serialization/SerializedModuleLoader.h

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

433433
virtual StringRef getModuleDefiningPath() const override;
434434

435-
Decl *getMainDecl() const override;
435+
ValueDecl *getMainDecl() const override;
436436

437437
bool hasEntryPoint() const override;
438438

lib/AST/Module.cpp

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

1421-
bool SourceFile::registerMainDecl(Decl *mainDecl, SourceLoc diagLoc) {
1421+
bool SourceFile::registerMainDecl(ValueDecl *mainDecl, SourceLoc diagLoc) {
14221422
assert(mainDecl);
14231423
if (mainDecl == MainDecl)
14241424
return false;

lib/Serialization/ModuleFile.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,9 +1237,9 @@ bool SerializedASTFile::getAllGenericSignatures(
12371237
return true;
12381238
}
12391239

1240-
Decl *SerializedASTFile::getMainDecl() const {
1240+
ValueDecl *SerializedASTFile::getMainDecl() const {
12411241
assert(hasEntryPoint());
1242-
return File.getDecl(File.getEntryPointDeclID());
1242+
return cast_or_null<ValueDecl>(File.getDecl(File.getEntryPointDeclID()));
12431243
}
12441244

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

0 commit comments

Comments
 (0)