summaryrefslogtreecommitdiff
path: root/tools/libclang/CXCompilationDatabase.cpp
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2013-11-13 13:23:27 +0000
committerManuel Klimek <klimek@google.com>2013-11-13 13:23:27 +0000
commitf88536af2cbbea3444c6488a1889520538250efb (patch)
treec52f84f742fdbc60b6f41c2e27a1e3a03adfe6e7 /tools/libclang/CXCompilationDatabase.cpp
parentb85a9ec6df63f30bbdef9a3975b1d31a680b15c1 (diff)
downloadclang-f88536af2cbbea3444c6488a1889520538250efb.tar.gz
clang-f88536af2cbbea3444c6488a1889520538250efb.tar.bz2
clang-f88536af2cbbea3444c6488a1889520538250efb.tar.xz
Add an optional mapping from source paths to source contents.
This allows compilation database implementations for distributed build systems to hand all data to the client to make parsing independent of the file system. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194571 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang/CXCompilationDatabase.cpp')
-rw-r--r--tools/libclang/CXCompilationDatabase.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tools/libclang/CXCompilationDatabase.cpp b/tools/libclang/CXCompilationDatabase.cpp
index 76e8924978..433caecd38 100644
--- a/tools/libclang/CXCompilationDatabase.cpp
+++ b/tools/libclang/CXCompilationDatabase.cpp
@@ -136,5 +136,41 @@ clang_CompileCommand_getArg(CXCompileCommand CCmd, unsigned Arg)
return cxstring::createRef(Cmd->CommandLine[Arg].c_str());
}
+unsigned
+clang_CompileCommand_getNumMappedSources(CXCompileCommand CCmd)
+{
+ if (!CCmd)
+ return 0;
+
+ return static_cast<CompileCommand *>(CCmd)->MappedSources.size();
+}
+
+CXString
+clang_CompileCommand_getMappedSourcePath(CXCompileCommand CCmd, unsigned I)
+{
+ if (!CCmd)
+ return cxstring::createNull();
+
+ CompileCommand *Cmd = static_cast<CompileCommand *>(CCmd);
+
+ if (I >= Cmd->MappedSources.size())
+ return cxstring::createNull();
+
+ return cxstring::createRef(Cmd->MappedSources[I].first.c_str());
+}
+
+CXString
+clang_CompileCommand_getMappedSourceContent(CXCompileCommand CCmd, unsigned I)
+{
+ if (!CCmd)
+ return cxstring::createNull();
+
+ CompileCommand *Cmd = static_cast<CompileCommand *>(CCmd);
+
+ if (I >= Cmd->MappedSources.size())
+ return cxstring::createNull();
+
+ return cxstring::createRef(Cmd->MappedSources[I].second.c_str());
+}
} // end: extern "C"