+static void parseInputFiles(const cl::list<std::string> &Inputs,
+ WeightedFileVector &WeightedInputs) {
+ WeightedInputs.reserve(Inputs.size());
+
+ for (StringRef Input : Inputs) {
+ StringRef FileName;
+ StringRef WeightStr;
+ std::tie(FileName, WeightStr) = Input.rsplit(':');
+ if (WeightStr.empty() || sys::fs::exists(Input)) {
+ // No weight specified or valid path containing delimiter.
+ WeightedInputs.push_back(WeightedFile(Input, 1));
+ } else {
+ // Input weight specified.
+ uint64_t Weight;
+ if (WeightStr.getAsInteger(10, Weight) || Weight < 1) {
+ // Invalid input weight.
+ exitWithError("Input weight must be a positive integer.");
+ }
+ WeightedInputs.push_back(WeightedFile(FileName, Weight));
+ }
+ }
+}
+