[clang-tools-extra] r229540 - Add canonical path conversion function and use it so paths are consistent.
John Thompson
John.Thompson.JTSoftware at gmail.com
Tue Feb 17 12:43:47 PST 2015
Author: jtsoftware
Date: Tue Feb 17 14:43:47 2015
New Revision: 229540
URL: http://llvm.org/viewvc/llvm-project?rev=229540&view=rev
Log:
Add canonical path conversion function and use it so paths are consistent.
Modified:
clang-tools-extra/trunk/modularize/Modularize.cpp
clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp
clang-tools-extra/trunk/modularize/ModularizeUtilities.h
Modified: clang-tools-extra/trunk/modularize/Modularize.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/Modularize.cpp?rev=229540&r1=229539&r2=229540&view=diff
==============================================================================
--- clang-tools-extra/trunk/modularize/Modularize.cpp (original)
+++ clang-tools-extra/trunk/modularize/Modularize.cpp Tue Feb 17 14:43:47 2015
@@ -239,7 +239,7 @@ std::string findInputFile(const CommandL
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
Modified: clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp?rev=229540&r1=229539&r2=229540&view=diff
==============================================================================
--- clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp (original)
+++ clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp Tue Feb 17 14:43:47 2015
@@ -114,11 +114,26 @@ std::error_code ModularizeUtilities::loa
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;
+}
Modified: clang-tools-extra/trunk/modularize/ModularizeUtilities.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/ModularizeUtilities.h?rev=229540&r1=229539&r2=229540&view=diff
==============================================================================
--- clang-tools-extra/trunk/modularize/ModularizeUtilities.h (original)
+++ clang-tools-extra/trunk/modularize/ModularizeUtilities.h Tue Feb 17 14:43:47 2015
@@ -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
More information about the cfe-commits
mailing list