77
88#include < swift/AST/SourceFile.h>
99#include < swift/AST/Builtins.h>
10- #include < swift/Basic/FileTypes.h>
11- #include < llvm/ADT/SmallString.h>
12- #include < llvm/Support/FileSystem.h>
13- #include < llvm/Support/Path.h>
1410
15- #include " swift/extractor/trap/generated/TrapClasses.h"
1611#include " swift/extractor/trap/TrapDomain.h"
1712#include " swift/extractor/visitors/SwiftVisitor.h"
1813#include " swift/extractor/TargetTrapFile.h"
14+ #include " swift/extractor/SwiftBuiltinSymbols.h"
1915
2016using namespace codeql ;
2117using namespace std ::string_literals;
@@ -68,9 +64,15 @@ static std::string getFilename(swift::ModuleDecl& module, swift::SourceFile* pri
6864 }
6965 if (module .isBuiltinModule ()) {
7066 // The Builtin module has an empty filename, let's fix that
71- return " /<Builtin> " ;
67+ return " /__Builtin__ " ;
7268 }
73- return module .getModuleFilename ().str ();
69+ auto filename = module .getModuleFilename ().str ();
70+ // there is a special case of a module without an actual filename reporting `<imports>`: in this
71+ // case we want to avoid the `<>` characters, in case a dirty DB is imported on Windows
72+ if (filename == " <imports>" ) {
73+ return " /__imports__" ;
74+ }
75+ return filename;
7476}
7577
7678/* The builtin module is special, as it does not publish any top-level declaration
@@ -89,71 +91,7 @@ static std::string getFilename(swift::ModuleDecl& module, swift::SourceFile* pri
8991static void getBuiltinDecls (swift::ModuleDecl& builtinModule,
9092 llvm::SmallVector<swift::Decl*>& decls) {
9193 llvm::SmallVector<swift::ValueDecl*> values;
92- for (auto symbol : {
93- " zeroInitializer" ,
94- " BridgeObject" ,
95- " Word" ,
96- " NativeObject" ,
97- " RawPointer" ,
98- " Executor" ,
99- " Job" ,
100- " RawUnsafeContinuation" ,
101- " addressof" ,
102- " initialize" ,
103- " reinterpretCast" ,
104- " Int1" ,
105- " Int8" ,
106- " Int16" ,
107- " Int32" ,
108- " Int64" ,
109- " IntLiteral" ,
110- " FPIEEE16" ,
111- " FPIEEE32" ,
112- " FPIEEE64" ,
113- " FPIEEE80" ,
114- " Vec2xInt8" ,
115- " Vec4xInt8" ,
116- " Vec8xInt8" ,
117- " Vec16xInt8" ,
118- " Vec32xInt8" ,
119- " Vec64xInt8" ,
120- " Vec2xInt16" ,
121- " Vec4xInt16" ,
122- " Vec8xInt16" ,
123- " Vec16xInt16" ,
124- " Vec32xInt16" ,
125- " Vec64xInt16" ,
126- " Vec2xInt32" ,
127- " Vec4xInt32" ,
128- " Vec8xInt32" ,
129- " Vec16xInt32" ,
130- " Vec32xInt32" ,
131- " Vec64xInt32" ,
132- " Vec2xInt64" ,
133- " Vec4xInt64" ,
134- " Vec8xInt64" ,
135- " Vec16xInt64" ,
136- " Vec32xInt64" ,
137- " Vec64xInt64" ,
138- " Vec2xFPIEEE16" ,
139- " Vec4xFPIEEE16" ,
140- " Vec8xFPIEEE16" ,
141- " Vec16xFPIEEE16" ,
142- " Vec32xFPIEEE16" ,
143- " Vec64xFPIEEE16" ,
144- " Vec2xFPIEEE32" ,
145- " Vec4xFPIEEE32" ,
146- " Vec8xFPIEEE32" ,
147- " Vec16xFPIEEE32" ,
148- " Vec32xFPIEEE32" ,
149- " Vec64xFPIEEE32" ,
150- " Vec2xFPIEEE64" ,
151- " Vec4xFPIEEE64" ,
152- " Vec8xFPIEEE64" ,
153- " Vec16xFPIEEE64" ,
154- " Vec32xFPIEEE64" ,
155- " Vec64xFPIEEE64" ,
156- }) {
94+ for (auto symbol : swiftBuiltins) {
15795 builtinModule.lookupValue (builtinModule.getASTContext ().getIdentifier (symbol),
15896 swift::NLKind::QualifiedLookup, values);
15997 }
0 commit comments