MCPcopy Create free account
hub / github.com/argotorg/solidity / readInputFiles

Method readInputFiles

solc/CommandLineInterface.cpp:605–711  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

603}
604
605void CommandLineInterface::readInputFiles()
606{
607 solAssert(!m_standardJsonInput.has_value());
608
609 if (m_options.input.noImportCallback)
610 m_universalCallback.resetImportCallback();
611
612 static std::set<frontend::InputMode> const noInputFiles{
613 frontend::InputMode::Help,
614 frontend::InputMode::License,
615 frontend::InputMode::Version
616 };
617
618 if (noInputFiles.count(m_options.input.mode) == 1)
619 return;
620
621 m_fileReader.setBasePath(m_options.input.basePath);
622
623 if (m_fileReader.basePath() != "")
624 {
625 if (!boost::filesystem::exists(m_fileReader.basePath()))
626 solThrow(CommandLineValidationError, "Base path does not exist: \"" + m_fileReader.basePath().string() + '"');
627
628 if (!boost::filesystem::is_directory(m_fileReader.basePath()))
629 solThrow(CommandLineValidationError, "Base path is not a directory: \"" + m_fileReader.basePath().string() + '"');
630 }
631
632 for (boost::filesystem::path const& includePath: m_options.input.includePaths)
633 m_fileReader.addIncludePath(includePath);
634
635 for (boost::filesystem::path const& allowedDirectory: m_options.input.allowedDirectories)
636 m_fileReader.allowDirectory(allowedDirectory);
637
638 std::map<std::string, std::set<boost::filesystem::path>> collisions =
639 m_fileReader.detectSourceUnitNameCollisions(m_options.input.paths);
640 if (!collisions.empty())
641 {
642 auto pathToQuotedString = [](boost::filesystem::path const& _path){ return "\"" + _path.string() + "\""; };
643
644 std::string message =
645 "Source unit name collision detected. "
646 "The specified values of base path and/or include paths would result in multiple "
647 "input files being assigned the same source unit name:\n";
648
649 for (auto const& [sourceUnitName, normalizedInputPaths]: collisions)
650 {
651 message += sourceUnitName + " matches: ";
652 message += util::joinHumanReadable(normalizedInputPaths | ranges::views::transform(pathToQuotedString)) + "\n";
653 }
654
655 solThrow(CommandLineValidationError, message);
656 }
657
658 for (boost::filesystem::path const& infile: m_options.input.paths)
659 {
660 if (!boost::filesystem::exists(infile))
661 {
662 if (!m_options.input.ignoreMissingFiles)

Callers 1

Calls 10

joinHumanReadableFunction · 0.85
resetImportCallbackMethod · 0.80
setBasePathMethod · 0.80
addIncludePathMethod · 0.80
allowDirectoryMethod · 0.80
addOrUpdateFileMethod · 0.80
setStdinMethod · 0.80
countMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected