diff options
author | dim <dim@FreeBSD.org> | 2013-12-22 00:07:40 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2013-12-22 00:07:40 +0000 |
commit | 952eddef9aff85b1e92626e89baaf7a360e2ac85 (patch) | |
tree | df8df0b0067b381eab470a3b8f28d14a552a6340 /tools/libclang/CXCompilationDatabase.cpp | |
parent | ea266cad53e3d49771fa38103913d3ec7a166694 (diff) | |
download | FreeBSD-src-952eddef9aff85b1e92626e89baaf7a360e2ac85.zip FreeBSD-src-952eddef9aff85b1e92626e89baaf7a360e2ac85.tar.gz |
Vendor import of clang release_34 branch r197841 (effectively, 3.4 RC3):
https://llvm.org/svn/llvm-project/cfe/branches/release_34@197841
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" |