diff options
author | John Thompson <John.Thompson.JTSoftware@gmail.com> | 2015-02-11 16:45:50 +0000 |
---|---|---|
committer | John Thompson <John.Thompson.JTSoftware@gmail.com> | 2015-02-11 16:45:50 +0000 |
commit | 9724431c77b7faeeaf0e2db3144e49cab8f36d8d (patch) | |
tree | b21bbf3db4608128cee2986583bd1da513ed6850 /clang-tools-extra/modularize/PreprocessorTracker.cpp | |
parent | 5bf72c46b33c0058b4147fd6bbda4b53322f67ca (diff) | |
download | bcm5719-llvm-9724431c77b7faeeaf0e2db3144e49cab8f36d8d.tar.gz bcm5719-llvm-9724431c77b7faeeaf0e2db3144e49cab8f36d8d.zip |
Centralize canonical path conversion.
llvm-svn: 228845
Diffstat (limited to 'clang-tools-extra/modularize/PreprocessorTracker.cpp')
-rw-r--r-- | clang-tools-extra/modularize/PreprocessorTracker.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/clang-tools-extra/modularize/PreprocessorTracker.cpp b/clang-tools-extra/modularize/PreprocessorTracker.cpp index 4347fdd975f..685e242032c 100644 --- a/clang-tools-extra/modularize/PreprocessorTracker.cpp +++ b/clang-tools-extra/modularize/PreprocessorTracker.cpp @@ -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(); |