diff options
author | John Thompson <John.Thompson.JTSoftware@gmail.com> | 2015-02-17 20:43:47 +0000 |
---|---|---|
committer | John Thompson <John.Thompson.JTSoftware@gmail.com> | 2015-02-17 20:43:47 +0000 |
commit | 3dcb3934c6072f5e2eed15fd63cdc1a35bb5cad4 (patch) | |
tree | a877ceb2278a5932c4ed850d062a1b1849ece1a2 /clang-tools-extra/modularize/ModularizeUtilities.cpp | |
parent | 7fe7e05379e3de07213b4cab2f71c6802d19986b (diff) | |
download | bcm5719-llvm-3dcb3934c6072f5e2eed15fd63cdc1a35bb5cad4.tar.gz bcm5719-llvm-3dcb3934c6072f5e2eed15fd63cdc1a35bb5cad4.zip |
Add canonical path conversion function and use it so paths are consistent.
llvm-svn: 229540
Diffstat (limited to 'clang-tools-extra/modularize/ModularizeUtilities.cpp')
-rw-r--r-- | clang-tools-extra/modularize/ModularizeUtilities.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp b/clang-tools-extra/modularize/ModularizeUtilities.cpp index 14c9f5d2756..d3c48c9f136 100644 --- a/clang-tools-extra/modularize/ModularizeUtilities.cpp +++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp @@ -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; +} |