[clang-tools-extra] r228845 - Centralize canonical path conversion.
John Thompson
John.Thompson.JTSoftware at gmail.com
Wed Feb 11 08:45:50 PST 2015
Author: jtsoftware
Date: Wed Feb 11 10:45:50 2015
New Revision: 228845
URL: http://llvm.org/viewvc/llvm-project?rev=228845&view=rev
Log:
Centralize canonical path conversion.
Modified:
clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp
Modified: clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp?rev=228845&r1=228844&r2=228845&view=diff
==============================================================================
--- clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp (original)
+++ clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp Wed Feb 11 10:45:50 2015
@@ -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();
More information about the cfe-commits
mailing list