Centralize canonical path conversion.

llvm-svn: 228845
This commit is contained in:
John Thompson 2015-02-11 16:45:50 +00:00
parent 5bf72c46b3
commit 9724431c77
1 changed files with 9 additions and 4 deletions

View File

@ -975,11 +975,17 @@ public:
// Lookup/add string.
StringHandle addString(llvm::StringRef Str) { return Strings.intern(Str); }
// Convert to a canonical path.
std::string getCanonicalPath(llvm::StringRef path) const {
std::string CanonicalPath(path);
std::replace(CanonicalPath.begin(), CanonicalPath.end(), '\\', '/');
return CanonicalPath;
}
// Get the handle of a header file entry.
// Return HeaderHandleInvalid if not found.
HeaderHandle findHeaderHandle(llvm::StringRef HeaderPath) const {
std::string CanonicalPath(HeaderPath);
std::replace(CanonicalPath.begin(), CanonicalPath.end(), '\\', '/');
std::string CanonicalPath = getCanonicalPath(HeaderPath);
HeaderHandle H = 0;
for (std::vector<StringHandle>::const_iterator I = HeaderPaths.begin(),
E = HeaderPaths.end();
@ -993,8 +999,7 @@ public:
// Add a new header file entry, or return existing handle.
// Return the header handle.
HeaderHandle addHeader(llvm::StringRef HeaderPath) {
std::string CanonicalPath(HeaderPath);
std::replace(CanonicalPath.begin(), CanonicalPath.end(), '\\', '/');
std::string CanonicalPath = getCanonicalPath(HeaderPath);
HeaderHandle H = findHeaderHandle(CanonicalPath);
if (H == HeaderHandleInvalid) {
H = HeaderPaths.size();