They could pass also on msvc if they were -fms-compatibility tolerant.
Manuel, I would be happier if you could tweak tests with -target i686-win32.
---
clang/lib/Tooling/CompilationDatabase.cpp | 8 ++++++--
clang/lib/Tooling/Tooling.cpp | 8 ++++++--
clang/test/Tooling/clang-check-builtin-headers.cpp | 2 +-
clang/test/Tooling/clang-check-chdir.cpp | 2 +-
clang/test/Tooling/clang-check-pwd.cpp | 2 +-
clang/test/Tooling/clang-check.cpp | 2 +-
llvm/lib/Support/PathV2.cpp | 3 +++
7 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/clang/lib/Tooling/CompilationDatabase.cpp b/clang/lib/Tooling/CompilationDatabase.cpp
index c87833f..1b8032e 100644
--- a/clang/lib/Tooling/CompilationDatabase.cpp
+++ b/clang/lib/Tooling/CompilationDatabase.cpp
@@ -179,8 +179,10 @@ JSONCompilationDatabase::loadFromBuffer(StringRef DatabaseString,
std::vector<CompileCommand>
JSONCompilationDatabase::getCompileCommands(StringRef FilePath) const {
+ llvm::SmallString<8> NativeFilePath;
+ llvm::sys::path::native(FilePath, NativeFilePath);
llvm::StringMap< std::vector<CompileCommandRef> >::const_iterator
- CommandsRefI = IndexByFile.find(FilePath);
+ CommandsRefI = IndexByFile.find(NativeFilePath);
if (CommandsRefI == IndexByFile.end())
return std::vector<CompileCommand>();
const std::vector<CompileCommandRef> &CommandsRef = CommandsRefI->getValue();
@@ -271,7 +273,9 @@ bool JSONCompilationDatabase::parse(std::string &ErrorMessage) {
return false;
}
llvm::SmallString<8> FileStorage;
- IndexByFile[File->getValue(FileStorage)].push_back(
+ llvm::SmallString<8> NativeFilePath;
+ llvm::sys::path::native(File->getValue(FileStorage), NativeFilePath);
+ IndexByFile[NativeFilePath].push_back(
CompileCommandRef(Directory, Command));
}
return true;
diff --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp
index abd6703..e2109fc 100644
--- a/clang/lib/Tooling/Tooling.cpp
+++ b/clang/lib/Tooling/Tooling.cpp
@@ -142,17 +142,21 @@ bool runToolOnCode(clang::FrontendAction *ToolAction, const Twine &Code,
/// \param BaseDirectory An absolute path.
static std::string getAbsolutePath(
StringRef File, StringRef BaseDirectory) {
+ SmallString<1024> PathStorage;
assert(llvm::sys::path::is_absolute(BaseDirectory));
if (llvm::sys::path::is_absolute(File)) {
- return File;
+ llvm::sys::path::native(File, PathStorage);
+ return PathStorage.str();
}
StringRef RelativePath(File);
+ // FIXME: Does Win32 accept '.\\'?
if (RelativePath.startswith("./")) {
RelativePath = RelativePath.substr(strlen("./"));
}
llvm::SmallString<1024> AbsolutePath(BaseDirectory);
llvm::sys::path::append(AbsolutePath, RelativePath);
- return AbsolutePath.str();
+ llvm::sys::path::native(Twine(AbsolutePath), PathStorage);
+ return PathStorage.str();
}
ToolInvocation::ToolInvocation(
diff --git a/clang/test/Tooling/clang-check-builtin-headers.cpp b/clang/test/Tooling/clang-check-builtin-headers.cpp
index 4324dec..b640d05 100644
--- a/clang/test/Tooling/clang-check-builtin-headers.cpp
+++ b/clang/test/Tooling/clang-check-builtin-headers.cpp
@@ -1,7 +1,7 @@
// RUN: rm -rf %t
// RUN: mkdir %t
// Add a path that doesn't exist as argv[0] for the compile command line:
-// RUN: echo '[{"directory":".","command":"/random/tool -c %t/test.cpp","file":"%t/test.cpp"}]' > %t/compile_commands.json
+// RUN: echo '[{"directory":".","command":"/random/tool -c %t/test.cpp","file":"%t/test.cpp"}]' | sed -e 's/\\/\//g' > %t/compile_commands.json
// RUN: cp "%s" "%t/test.cpp"
// RUN: clang-check "%t" "%t/test.cpp" 2>&1|FileCheck %s
// FIXME: Make the above easier.
diff --git a/clang/test/Tooling/clang-check-chdir.cpp b/clang/test/Tooling/clang-check-chdir.cpp
index 5d02c95..7c465f3 100644
--- a/clang/test/Tooling/clang-check-chdir.cpp
+++ b/clang/test/Tooling/clang-check-chdir.cpp
@@ -2,7 +2,7 @@
// compilation database.
// RUN: rm -rf %t
// RUN: mkdir %t
-// RUN: echo "[{\"directory\":\"%t\",\"command\":\"clang -c test.cpp -I.\",\"file\":\"%t/test.cpp\"}]" > %t/compile_commands.json
+// RUN: echo "[{\"directory\":\"%t\",\"command\":\"clang -c test.cpp -I.\",\"file\":\"%t/test.cpp\"}]" | sed -e 's/\\/\//g' > %t/compile_commands.json
// RUN: cp "%s" "%t/test.cpp"
// RUN: touch "%t/clang-check-test.h"
// RUN: clang-check "%t" "%t/test.cpp" 2>&1|FileCheck %s
diff --git a/clang/test/Tooling/clang-check-pwd.cpp b/clang/test/Tooling/clang-check-pwd.cpp
index 96417df..40336cb 100644
--- a/clang/test/Tooling/clang-check-pwd.cpp
+++ b/clang/test/Tooling/clang-check-pwd.cpp
@@ -1,6 +1,6 @@
// RUN: rm -rf %t
// RUN: mkdir %t
-// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c %t/test.cpp\",\"file\":\"%t/test.cpp\"}]" > %t/compile_commands.json
+// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c %t/test.cpp\",\"file\":\"%t/test.cpp\"}]" | sed -e 's/\\/\\\\/g' > %t/compile_commands.json
// RUN: cp "%s" "%t/test.cpp"
// RUN: PWD="%t" clang-check "%t" "test.cpp" 2>&1|FileCheck %s
// FIXME: Make the above easier.
diff --git a/clang/test/Tooling/clang-check.cpp b/clang/test/Tooling/clang-check.cpp
index d197078..d37d14d 100644
--- a/clang/test/Tooling/clang-check.cpp
+++ b/clang/test/Tooling/clang-check.cpp
@@ -1,6 +1,6 @@
// RUN: rm -rf %t
// RUN: mkdir %t
-// RUN: echo '[{"directory":".","command":"clang++ -c %t/test.cpp","file":"%t/test.cpp"}]' > %t/compile_commands.json
+// RUN: echo '[{"directory":".","command":"clang++ -c %t/test.cpp","file":"%t/test.cpp"}]' | sed -e 's/\\/\//g' > %t/compile_commands.json
// RUN: cp "%s" "%t/test.cpp"
// RUN: clang-check "%t" "%t/test.cpp" 2>&1|FileCheck %s
// FIXME: Make the above easier.
diff --git a/llvm/lib/Support/PathV2.cpp b/llvm/lib/Support/PathV2.cpp
index e2a69a6..55d3e03 100644
--- a/llvm/lib/Support/PathV2.cpp
+++ b/llvm/lib/Support/PathV2.cpp
@@ -444,6 +444,9 @@ void native(const Twine &path, SmallVectorImpl<char> &result) {
else
result.push_back(*i);
}
+ // Canonicalize drive letter to upper case.
+ if (p.size() >= 2 && p[1] == ':' && islower(p[0]))
+ result[0] = toupper(p[0]);
#else
path.toVector(result);
#endif
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits