1616#include " swift/extractor/invocation/SwiftInvocationExtractor.h"
1717#include " swift/extractor/trap/TrapDomain.h"
1818#include " swift/extractor/infra/file/Path.h"
19- #include " swift/extractor/infra/log/SwiftLogging .h"
19+ #include " swift/extractor/infra/log/SwiftAssert .h"
2020
2121using namespace std ::string_literals;
22+ using namespace codeql ::main_logger;
2223
2324const std::string_view codeql::logRootName = " extractor" ;
2425
@@ -30,9 +31,10 @@ static void lockOutputSwiftModuleTraps(codeql::SwiftExtractorState& state,
3031 !module .empty ()) {
3132 if (auto target = codeql::createTargetTrapDomain (state, codeql::resolvePath (module ),
3233 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 " );
3638 }
3739 }
3840 }
@@ -43,7 +45,6 @@ static void processFrontendOptions(codeql::SwiftExtractorState& state,
4345 auto & inOuts = options.InputsAndOutputs ;
4446 std::vector<swift::InputFile> inputs;
4547 inOuts.forEachInput ([&](const swift::InputFile& input) {
46- std::cerr << input.getFileName () << " :\n " ;
4748 swift::PrimarySpecificPaths psp{};
4849 if (std::filesystem::path output = input.getPrimarySpecificPaths ().OutputFilename ;
4950 !output.empty ()) {
@@ -142,7 +143,7 @@ static bool checkRunUnderFilter(int argc, char* const* argv) {
142143// An example usage is to run the extractor under `gdbserver :1234` when the
143144// arguments match a given source file.
144145static void checkWhetherToRunUnderTool (int argc, char * const * argv) {
145- assert (argc > 0 );
146+ if (argc == 0 ) return ;
146147
147148 auto runUnder = getenv (" CODEQL_EXTRACTOR_SWIFT_RUN_UNDER" );
148149 if (runUnder == nullptr || !checkRunUnderFilter (argc, argv)) {
@@ -168,10 +169,7 @@ codeql::TrapDomain invocationTrapDomain(codeql::SwiftExtractorState& state) {
168169 auto filename = std::to_string (timestamp) + ' -' + std::to_string (getpid ());
169170 auto target = std::filesystem::path (" invocations" ) / std::filesystem::path (filename);
170171 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);
175173 return std::move (maybeDomain.value ());
176174}
177175
@@ -219,11 +217,8 @@ int main(int argc, char** argv, char** envp) {
219217 initializeSwiftModules ();
220218
221219 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));
227222
228223 auto openInterception = codeql::setupFileInterception (configuration);
229224
0 commit comments