mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
with the groundwork out of the way, we can now namebind types referenced
by the SIL parser. Add a test that covers both local types, and types that require looking through an import decl (Int, from the stdlib). Swift SVN r5249
This commit is contained in:
@@ -77,7 +77,7 @@ public:
|
||||
/// ASTStage - Defines what phases of parsing and semantic analysis are
|
||||
/// complete for the given AST. This should only be used for assertions and
|
||||
/// verification purposes.
|
||||
enum {
|
||||
enum ASTStage_t {
|
||||
/// Parsing is underway.
|
||||
Parsing,
|
||||
/// Parsing has completed.
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace swift {
|
||||
class Component;
|
||||
class Expr;
|
||||
class SILModule;
|
||||
struct TypeLoc;
|
||||
|
||||
namespace irgen {
|
||||
class Options;
|
||||
@@ -68,6 +69,10 @@ namespace swift {
|
||||
/// main module.
|
||||
void performTypeChecking(TranslationUnit *TU, unsigned StartElem = 0);
|
||||
|
||||
/// performTypeLocChecking - recursively validate the specified type. This is
|
||||
/// used when dealing with partial translation units (e.g. SIL parsing).
|
||||
bool performTypeLocChecking(TranslationUnit *TU, TypeLoc &T);
|
||||
|
||||
/// typeCheckCompletionContextExpr - Typecheck an expression parsed as a
|
||||
/// completion context.
|
||||
bool typeCheckCompletionContextExpr(TranslationUnit *TU,
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "Parser.h"
|
||||
#include "swift/Parse/Lexer.h"
|
||||
#include "swift/SIL/SILModule.h"
|
||||
#include "swift/Subsystems.h"
|
||||
#include "llvm/Support/SaveAndRestore.h"
|
||||
using namespace swift;
|
||||
|
||||
|
||||
@@ -148,6 +150,20 @@ bool Parser::parseSILType(SILType &Result) {
|
||||
parseType(Ty, diag::expected_sil_type))
|
||||
return true;
|
||||
|
||||
// If we successfully parsed the type, do some type checking / name binding
|
||||
// of it.
|
||||
{
|
||||
// We have to lie and say we're done with parsing to make this happen.
|
||||
assert(TU->ASTStage == TranslationUnit::Parsing &&
|
||||
"Unexpected stage during parsing!");
|
||||
llvm::SaveAndRestore<Module::ASTStage_t> ASTStage(TU->ASTStage,
|
||||
TranslationUnit::Parsed);
|
||||
if (performTypeLocChecking(TU, Ty))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// FIXME: Stop using TypeConverter when SILType for functions doesn't contain
|
||||
// SILTypes itself.
|
||||
(void)IsSRet;
|
||||
|
||||
@@ -955,6 +955,13 @@ void swift::performTypeChecking(TranslationUnit *TU, unsigned StartElem) {
|
||||
verify(TU);
|
||||
}
|
||||
|
||||
/// performTypeLocChecking - recursively validate the specified type. This is
|
||||
/// used when dealing with partial translation units (e.g. SIL parsing).
|
||||
bool swift::performTypeLocChecking(TranslationUnit *TU, TypeLoc &T) {
|
||||
return TypeChecker(*TU).validateType(T);
|
||||
}
|
||||
|
||||
|
||||
bool swift::typeCheckCompletionContextExpr(TranslationUnit *TU,
|
||||
Expr *&parsedExpr) {
|
||||
// Set up a diagnostics engine that swallows diagnostics.
|
||||
|
||||
@@ -7,10 +7,10 @@ sil clang_thunk @prototype : $() -> ()
|
||||
class Class1 { var a : Class2 }
|
||||
class Class2 { var b : Class1 }
|
||||
|
||||
// CHECK: sil @normal : $() -> ()
|
||||
sil @normal : $() -> () {
|
||||
// CHECK: sil @normal : $(a : Class1) -> ()
|
||||
sil @normal : $(a : Class1) -> () {
|
||||
}
|
||||
|
||||
// CHECK: sil internal @internal_fn : $() -> ()
|
||||
sil internal @internal_fn : $() -> () {
|
||||
// CHECK: sil internal @internal_fn : $() -> Int
|
||||
sil internal @internal_fn : $() -> Int {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user