File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 1111// ===----------------------------------------------------------------------===//
1212
1313#include " SemaFixture.h"
14+ #include " swift/AST/Decl.h"
1415#include " swift/AST/Module.h"
1516#include " swift/AST/ParseRequests.h"
1617#include " swift/AST/SourceFile.h"
18+ #include " swift/AST/Type.h"
19+ #include " swift/AST/Types.h"
1720#include " swift/Basic/LLVMInitialize.h"
1821#include " swift/ClangImporter/ClangImporter.h"
1922#include " swift/Serialization/SerializedModuleLoader.h"
@@ -52,3 +55,23 @@ SemaTest::SemaTest()
5255
5356 DC = module ;
5457}
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 1414#include " swift/AST/DiagnosticEngine.h"
1515#include " swift/AST/Module.h"
1616#include " swift/AST/SourceFile.h"
17+ #include " swift/AST/Type.h"
1718#include " swift/Basic/LangOptions.h"
1819#include " swift/Basic/Platform.h"
1920#include " swift/Basic/SourceManager.h"
@@ -58,6 +59,9 @@ class SemaTest : public SemaTestBase {
5859 DeclContext *DC;
5960
6061 SemaTest ();
62+
63+ protected:
64+ Type getStdlibType (StringRef name) const ;
6165};
6266
6367} // end namespace unittest
You can’t perform that action at this time.
0 commit comments