Opts->ParseArgs(Argv.data(), Argv.data() + Argv.size(), MissingArgIndex,
MissingArgCount, IncludedFlagsBitmask));
std::vector<std::string> Inputs = Args->getAllArgValues(OPT_INPUT);
- return Inputs.back();
+ return ModularizeUtilities::getCanonicalPath(Inputs.back());
}
// This arguments adjuster inserts "-include (file)" arguments for header
llvm::sys::path::append(Dependent, DependentsList[Index]);
}
llvm::sys::path::native(Dependent);
- Dependents.push_back(Dependent.str());
+ Dependents.push_back(getCanonicalPath(Dependent.str()));
}
+ // Get canonical form.
+ HeaderFileName = getCanonicalPath(HeaderFileName);
// Save the resulting header file path and dependencies.
HeaderFileNames.push_back(HeaderFileName.str());
Dependencies[HeaderFileName.str()] = Dependents;
}
return std::error_code();
}
+
+// Convert header path to canonical form.
+// The canonical form is basically just use forward slashes, and remove "./".
+// \param FilePath The file path, relative to the module map directory.
+// \returns The file path in canonical form.
+std::string ModularizeUtilities::getCanonicalPath(StringRef FilePath) {
+ std::string Tmp(FilePath);
+ std::replace(Tmp.begin(), Tmp.end(), '\\', '/');
+ StringRef Tmp2(Tmp);
+ if (Tmp2.startswith("./"))
+ Tmp = Tmp2.substr(2);
+ return Tmp;
+}
/// \returns std::error_code.
std::error_code loadSingleHeaderListsAndDependencies(
llvm::StringRef InputPath);
+
+public:
+
+ // Utility functions.
+
+ /// Convert header path to canonical form.
+ /// The canonical form is basically just use forward slashes,
+ /// and remove "./".
+ /// \param FilePath The file path.
+ /// \returns The file path in canonical form.
+ static std::string getCanonicalPath(llvm::StringRef FilePath);
};
} // end namespace Modularize