diff options
Diffstat (limited to 'tools/libclang/CXCompilationDatabase.cpp')
-rw-r--r-- | tools/libclang/CXCompilationDatabase.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tools/libclang/CXCompilationDatabase.cpp b/tools/libclang/CXCompilationDatabase.cpp index e35ac27..433caec 100644 --- a/tools/libclang/CXCompilationDatabase.cpp +++ b/tools/libclang/CXCompilationDatabase.cpp @@ -1,6 +1,7 @@ #include "clang-c/CXCompilationDatabase.h" #include "CXString.h" #include "clang/Tooling/CompilationDatabase.h" +#include <cstdio> using namespace clang; using namespace clang::tooling; @@ -135,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" |