7
7
8
8
#include < swift/AST/SourceFile.h>
9
9
#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>
14
10
15
- #include " swift/extractor/trap/generated/TrapClasses.h"
16
11
#include " swift/extractor/trap/TrapDomain.h"
17
12
#include " swift/extractor/visitors/SwiftVisitor.h"
18
13
#include " swift/extractor/TargetTrapFile.h"
14
+ #include " swift/extractor/SwiftBuiltinSymbols.h"
19
15
20
16
using namespace codeql ;
21
17
using namespace std ::string_literals;
@@ -68,9 +64,15 @@ static std::string getFilename(swift::ModuleDecl& module, swift::SourceFile* pri
68
64
}
69
65
if (module .isBuiltinModule ()) {
70
66
// The Builtin module has an empty filename, let's fix that
71
- return " /<Builtin> " ;
67
+ return " /__Builtin__ " ;
72
68
}
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;
74
76
}
75
77
76
78
/* 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
89
91
static void getBuiltinDecls (swift::ModuleDecl& builtinModule,
90
92
llvm::SmallVector<swift::Decl*>& decls) {
91
93
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) {
157
95
builtinModule.lookupValue (builtinModule.getASTContext ().getIdentifier (symbol),
158
96
swift::NLKind::QualifiedLookup, values);
159
97
}
0 commit comments