From 9b2d17c6137b5d79c7e1765e24ad35465a7fa095 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Wed, 23 May 2012 22:24:20 +0000 Subject: Tooling: Canonicalize Key in IndexByFile[]. llvm::sys::path::native() may be used here. It fixes test/Tooling on Win32 hosts. llvm-svn: 157350 --- clang/lib/Tooling/CompilationDatabase.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'clang/lib/Tooling/CompilationDatabase.cpp') diff --git a/clang/lib/Tooling/CompilationDatabase.cpp b/clang/lib/Tooling/CompilationDatabase.cpp index c87833fba63..227fa82926c 100644 --- a/clang/lib/Tooling/CompilationDatabase.cpp +++ b/clang/lib/Tooling/CompilationDatabase.cpp @@ -179,8 +179,10 @@ JSONCompilationDatabase::loadFromBuffer(StringRef DatabaseString, std::vector JSONCompilationDatabase::getCompileCommands(StringRef FilePath) const { + llvm::SmallString<128> NativeFilePath; + llvm::sys::path::native(FilePath, NativeFilePath); llvm::StringMap< std::vector >::const_iterator - CommandsRefI = IndexByFile.find(FilePath); + CommandsRefI = IndexByFile.find(NativeFilePath); if (CommandsRefI == IndexByFile.end()) return std::vector(); const std::vector &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<128> NativeFilePath; + llvm::sys::path::native(File->getValue(FileStorage), NativeFilePath); + IndexByFile[NativeFilePath].push_back( CompileCommandRef(Directory, Command)); } return true; -- cgit v1.2.3