[cfe-commits] r157350 - in /cfe/trunk/lib/Tooling: CompilationDatabase.cpp Tooling.cpp
NAKAMURA Takumi
geek4civic at gmail.com
Wed May 23 15:24:21 PDT 2012
Author: chapuni
Date: Wed May 23 17:24:20 2012
New Revision: 157350
URL: http://llvm.org/viewvc/llvm-project?rev=157350&view=rev
Log:
Tooling: Canonicalize Key in IndexByFile[]. llvm::sys::path::native() may be used here.
It fixes test/Tooling on Win32 hosts.
Modified:
cfe/trunk/lib/Tooling/CompilationDatabase.cpp
cfe/trunk/lib/Tooling/Tooling.cpp
Modified: cfe/trunk/lib/Tooling/CompilationDatabase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CompilationDatabase.cpp?rev=157350&r1=157349&r2=157350&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/CompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp Wed May 23 17:24:20 2012
@@ -179,8 +179,10 @@
std::vector<CompileCommand>
JSONCompilationDatabase::getCompileCommands(StringRef FilePath) const {
+ llvm::SmallString<128> 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 @@
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;
Modified: cfe/trunk/lib/Tooling/Tooling.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=157350&r1=157349&r2=157350&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/Tooling.cpp (original)
+++ cfe/trunk/lib/Tooling/Tooling.cpp Wed May 23 17:24:20 2012
@@ -142,17 +142,21 @@
/// \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: Should '.\\' be accepted on Win32?
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(
More information about the cfe-commits
mailing list