Index: tools/clang/plugins/ChromeClassTester.cpp |
diff --git a/tools/clang/plugins/ChromeClassTester.cpp b/tools/clang/plugins/ChromeClassTester.cpp |
index 931da02f3ff54e352a1cbec4337433abb38e449f..3744ef3309930622b5671d469c15d457e554c56c 100644 |
--- a/tools/clang/plugins/ChromeClassTester.cpp |
+++ b/tools/clang/plugins/ChromeClassTester.cpp |
@@ -130,9 +130,7 @@ bool ChromeClassTester::InBannedDirectory(SourceLocation loc) { |
} |
#if defined(LLVM_ON_UNIX) |
- // We need to munge the paths so that they are relative to the repository |
- // srcroot. We first resolve the symlinktastic relative path and then |
- // remove our known srcroot from it if needed. |
+ // Resolve the symlinktastic relative path and make it absolute. |
char resolvedPath[MAXPATHLEN]; |
if (realpath(filename.c_str(), resolvedPath)) { |
filename = resolvedPath; |
@@ -141,6 +139,15 @@ bool ChromeClassTester::InBannedDirectory(SourceLocation loc) { |
#if defined(LLVM_ON_WIN32) |
std::replace(filename.begin(), filename.end(), '\\', '/'); |
+ |
+ // On Posix, realpath() has made the path absolute. On Windows, this isn't |
+ // necessarily true, so prepend a '/' to the path to make sure the |
+ // banned_directories_ loop below works correctly. |
+ // This turns e.g. "gen/dir/file.cc" to "/gen/dir/file.cc" which lets the |
+ // "/gen/" banned_dir work. |
+ // This seems simpler than converting to utf16, calling GetFullPathNameW(), |
+ // and converting back to utf8. |
+ filename.insert(filename.begin(), '/'); |
dcheng
2015/04/27 22:31:21
Would it make sense to use llvm::sys::fs::make_abs
Nico
2015/04/27 22:57:00
That'd work too I suppose. Nothing wrong with "/c:
|
#endif |
for (const std::string& banned_dir : banned_directories_) { |