mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-26 07:01:05 +00:00
Add canonical path conversion function and use it so paths are consistent.
llvm-svn: 229540
This commit is contained in:
parent
7fe7e05379
commit
3dcb3934c6
@ -239,7 +239,7 @@ std::string findInputFile(const CommandLineArguments &CLArgs) {
|
||||
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
|
||||
|
@ -114,11 +114,26 @@ std::error_code ModularizeUtilities::loadSingleHeaderListsAndDependencies(
|
||||
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;
|
||||
}
|
||||
|
@ -67,6 +67,17 @@ protected:
|
||||
/// \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
|
||||
|
Loading…
Reference in New Issue
Block a user