16
16
#include " swift/extractor/invocation/SwiftInvocationExtractor.h"
17
17
#include " swift/extractor/trap/TrapDomain.h"
18
18
#include " swift/extractor/infra/file/Path.h"
19
- #include " swift/extractor/infra/log/SwiftLogging .h"
19
+ #include " swift/extractor/infra/log/SwiftAssert .h"
20
20
21
21
using namespace std ::string_literals;
22
+ using namespace codeql ::main_logger;
22
23
23
24
const std::string_view codeql::logRootName = " extractor" ;
24
25
@@ -30,9 +31,10 @@ static void lockOutputSwiftModuleTraps(codeql::SwiftExtractorState& state,
30
31
!module .empty ()) {
31
32
if (auto target = codeql::createTargetTrapDomain (state, codeql::resolvePath (module ),
32
33
codeql::TrapType::module )) {
33
- target->emit (" // trap file deliberately empty\n "
34
- " // this swiftmodule was created during the build, so its entities must have"
35
- " been extracted directly from source files" );
34
+ target->emitComment (
35
+ " trap file deliberately empty\n "
36
+ " * this swiftmodule was created during the build, so its entities must have\n "
37
+ " * been extracted directly from source files\n " );
36
38
}
37
39
}
38
40
}
@@ -43,7 +45,6 @@ static void processFrontendOptions(codeql::SwiftExtractorState& state,
43
45
auto & inOuts = options.InputsAndOutputs ;
44
46
std::vector<swift::InputFile> inputs;
45
47
inOuts.forEachInput ([&](const swift::InputFile& input) {
46
- std::cerr << input.getFileName () << " :\n " ;
47
48
swift::PrimarySpecificPaths psp{};
48
49
if (std::filesystem::path output = input.getPrimarySpecificPaths ().OutputFilename ;
49
50
!output.empty ()) {
@@ -142,7 +143,7 @@ static bool checkRunUnderFilter(int argc, char* const* argv) {
142
143
// An example usage is to run the extractor under `gdbserver :1234` when the
143
144
// arguments match a given source file.
144
145
static void checkWhetherToRunUnderTool (int argc, char * const * argv) {
145
- assert (argc > 0 );
146
+ if (argc == 0 ) return ;
146
147
147
148
auto runUnder = getenv (" CODEQL_EXTRACTOR_SWIFT_RUN_UNDER" );
148
149
if (runUnder == nullptr || !checkRunUnderFilter (argc, argv)) {
@@ -168,10 +169,7 @@ codeql::TrapDomain invocationTrapDomain(codeql::SwiftExtractorState& state) {
168
169
auto filename = std::to_string (timestamp) + ' -' + std::to_string (getpid ());
169
170
auto target = std::filesystem::path (" invocations" ) / std::filesystem::path (filename);
170
171
auto maybeDomain = codeql::createTargetTrapDomain (state, target, codeql::TrapType::invocation);
171
- if (!maybeDomain) {
172
- std::cerr << " Cannot create invocation trap file: " << target << " \n " ;
173
- abort ();
174
- }
172
+ CODEQL_ASSERT (maybeDomain, " Cannot create invocation trap file for {}" , target);
175
173
return std::move (maybeDomain.value ());
176
174
}
177
175
@@ -219,11 +217,8 @@ int main(int argc, char** argv, char** envp) {
219
217
initializeSwiftModules ();
220
218
221
219
const auto configuration = configure (argc, argv);
222
- {
223
- codeql::Logger logger{" main" };
224
- LOG_INFO (" calling extractor with arguments \" {}\" " , argDump (argc, argv));
225
- LOG_DEBUG (" environment:\n {}\n " , envDump (envp));
226
- }
220
+ LOG_INFO (" calling extractor with arguments \" {}\" " , argDump (argc, argv));
221
+ LOG_DEBUG (" environment:\n {}\n " , envDump (envp));
227
222
228
223
auto openInterception = codeql::setupFileInterception (configuration);
229
224
0 commit comments