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.

llvm-svn: 194571
diff --git a/clang/tools/libclang/CXCompilationDatabase.cpp b/clang/tools/libclang/CXCompilationDatabase.cpp
index 76e8924..433caec 100644
--- a/clang/tools/libclang/CXCompilationDatabase.cpp
+++ b/clang/tools/libclang/CXCompilationDatabase.cpp
@@ -136,5 +136,41 @@
   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"