mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #28544 from CodaFi/file-unit-arianism
Add a high-level request to type check a file
This commit is contained in:
@@ -49,6 +49,7 @@ SWIFT_TYPEID_NAMED(ParamDecl *, ParamDecl)
|
||||
SWIFT_TYPEID_NAMED(PatternBindingEntry *, PatternBindingEntry)
|
||||
SWIFT_TYPEID_NAMED(PrecedenceGroupDecl *, PrecedenceGroupDecl)
|
||||
SWIFT_TYPEID_NAMED(ProtocolDecl *, ProtocolDecl)
|
||||
SWIFT_TYPEID_NAMED(SourceFile *, SourceFile)
|
||||
SWIFT_TYPEID_NAMED(TypeAliasDecl *, TypeAliasDecl)
|
||||
SWIFT_TYPEID_NAMED(ValueDecl *, ValueDecl)
|
||||
SWIFT_TYPEID_NAMED(VarDecl *, VarDecl)
|
||||
|
||||
@@ -50,6 +50,7 @@ struct PropertyWrapperMutability;
|
||||
class ProtocolDecl;
|
||||
class Requirement;
|
||||
enum class ResilienceExpansion : unsigned;
|
||||
class SourceFile;
|
||||
class Type;
|
||||
class ValueDecl;
|
||||
class VarDecl;
|
||||
|
||||
@@ -482,6 +482,11 @@ inline bool ModuleDecl::EntryPointInfoTy::markDiagnosedMainClassWithScript() {
|
||||
return !res;
|
||||
}
|
||||
|
||||
inline void simple_display(llvm::raw_ostream &out, const SourceFile *SF) {
|
||||
assert(SF && "Cannot display null source file!");
|
||||
|
||||
out << "source_file " << '\"' << SF->getFilename() << '\"';
|
||||
}
|
||||
} // end namespace swift
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1949,6 +1949,27 @@ public:
|
||||
bool isCached() const { return true; }
|
||||
};
|
||||
|
||||
class TypeCheckSourceFileRequest :
|
||||
public SimpleRequest<TypeCheckSourceFileRequest,
|
||||
bool (SourceFile *, unsigned),
|
||||
CacheKind::SeparatelyCached> {
|
||||
public:
|
||||
using SimpleRequest::SimpleRequest;
|
||||
|
||||
private:
|
||||
friend SimpleRequest;
|
||||
|
||||
// Evaluation.
|
||||
llvm::Expected<bool> evaluate(Evaluator &evaluator,
|
||||
SourceFile *SF, unsigned StartElem) const;
|
||||
|
||||
public:
|
||||
// Separate caching.
|
||||
bool isCached() const { return true; }
|
||||
Optional<bool> getCachedResult() const;
|
||||
void cacheResult(bool result) const;
|
||||
};
|
||||
|
||||
// Allow AnyValue to compare two Type values, even though Type doesn't
|
||||
// support ==.
|
||||
template<>
|
||||
|
||||
@@ -205,6 +205,8 @@ SWIFT_REQUEST(TypeChecker, HasDefaultInitRequest,
|
||||
bool(NominalTypeDecl *), Cached, NoLocationInfo)
|
||||
SWIFT_REQUEST(TypeChecker, SynthesizeDefaultInitRequest,
|
||||
ConstructorDecl *(NominalTypeDecl *), Cached, NoLocationInfo)
|
||||
SWIFT_REQUEST(TypeChecker, TypeCheckSourceFileRequest,
|
||||
bool(SouceFile *, unsigned), SeparatelyCached, NoLocationInfo)
|
||||
SWIFT_REQUEST(TypeChecker, TypeWitnessRequest,
|
||||
TypeWitnessAndDecl(NormalProtocolConformance *,
|
||||
AssociatedTypeDecl *),
|
||||
|
||||
Reference in New Issue
Block a user