File tree 2 files changed +27
-0
lines changed
2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 11
11
// ===----------------------------------------------------------------------===//
12
12
13
13
#include " SemaFixture.h"
14
+ #include " swift/AST/Decl.h"
14
15
#include " swift/AST/Module.h"
15
16
#include " swift/AST/ParseRequests.h"
16
17
#include " swift/AST/SourceFile.h"
18
+ #include " swift/AST/Type.h"
19
+ #include " swift/AST/Types.h"
17
20
#include " swift/Basic/LLVMInitialize.h"
18
21
#include " swift/ClangImporter/ClangImporter.h"
19
22
#include " swift/Serialization/SerializedModuleLoader.h"
@@ -52,3 +55,23 @@ SemaTest::SemaTest()
52
55
53
56
DC = module;
54
57
}
58
+
59
+ Type SemaTest::getStdlibType (StringRef name) const {
60
+ auto typeName = Context.getIdentifier (name);
61
+
62
+ auto *stdlib = Context.getStdlibModule ();
63
+
64
+ llvm::SmallVector<ValueDecl *, 4 > results;
65
+ stdlib->lookupValue (typeName, NLKind::UnqualifiedLookup, results);
66
+
67
+ if (results.size () != 1 )
68
+ return Type ();
69
+
70
+ if (auto *decl = dyn_cast<TypeDecl>(results.front ())) {
71
+ if (auto *NTD = dyn_cast<NominalTypeDecl>(decl))
72
+ return NTD->getDeclaredType ();
73
+ return decl->getDeclaredInterfaceType ();
74
+ }
75
+
76
+ return Type ();
77
+ }
Original file line number Diff line number Diff line change 14
14
#include " swift/AST/DiagnosticEngine.h"
15
15
#include " swift/AST/Module.h"
16
16
#include " swift/AST/SourceFile.h"
17
+ #include " swift/AST/Type.h"
17
18
#include " swift/Basic/LangOptions.h"
18
19
#include " swift/Basic/Platform.h"
19
20
#include " swift/Basic/SourceManager.h"
@@ -58,6 +59,9 @@ class SemaTest : public SemaTestBase {
58
59
DeclContext *DC;
59
60
60
61
SemaTest ();
62
+
63
+ protected:
64
+ Type getStdlibType (StringRef name) const ;
61
65
};
62
66
63
67
} // end namespace unittest
You can’t perform that action at this time.
0 commit comments