[cfe-dev] Where is clang_CompileCommand_getNumMappedSources?

Alex L via cfe-dev cfe-dev at lists.llvm.org
Mon May 8 03:37:34 PDT 2017


Note that `clang_CompileCommand_getNumMappedSources` and the 2
complementary functions should return 0 / empty strings because the mapped
sources aren't currently used in Clang. In fact, there's a patch at
https://reviews.llvm.org/D32351 that removes them completely (but preserves
the libclang API). So while the fact that
`clang_CompileCommand_getNumMappedSources` is not exposed in the exports
file is bug, should it really be fixed if it was not (and if that patch
will land won't be) used by anyone?

On 8 May 2017 at 11:07, Ranjeet Singh via cfe-dev <cfe-dev at lists.llvm.org>
wrote:

> Hi Charlie,
>
>
> looks like the function 'clang_CompileCommand_getNumMappedSources'
> hasn't been added to the libclang exports file in libclang.exports so isn't
> exposed externally in libclang.so. Patch c519ef864 added the other 2
> complimentary functions but missed '*_getNumMappedSources'.
>
>
>
> Thanks,
>
> Ranjeet
> ------------------------------
> *From:* cfe-dev <cfe-dev-bounces at lists.llvm.org> on behalf of Charlie
> Turner via cfe-dev <cfe-dev at lists.llvm.org>
> *Sent:* 05 May 2017 21:00
> *To:* cfe-dev at lists.llvm.org
> *Subject:* [cfe-dev] Where is clang_CompileCommand_getNumMappedSources?
>
> Hi all,
>
> I'm trying a quick experiment with clang-c and I've noticed something that
> seems weird. If I compile the program at the end of this email like so
>
> $ g++ -Iclang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-16.04/include -g -Wall
> tc.cpp -Lclang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-16.04/lib -lclang -o tc
> tc.cpp:21: error: undefined reference to 'clang_CompileCommand_
> getNumMappedSources'
>
> I'm a tad baffled by this because the complimentary functions
> clang_CompileCommand_getMappedSourcePath and clang_CompileCommand_getMappedSourceContent
> do exist.
>
> In the pre-built package I'm using (4.0.0, see above), it seems the thing
> doesn't exist at all?
>
> $ strings clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-16.04/lib/* | grep
> clang_CompileCommand | sort -u
> clang_CompileCommand_getArg
> clang_CompileCommand_getDirectory
> clang_CompileCommand_getFilename
> clang_CompileCommand_getMappedSourceContent
> clang_CompileCommand_getMappedSourcePath
> clang_CompileCommand_getNumArgs
> clang_CompileCommands_dispose
> clang_CompileCommands_getCommand
> clang_CompileCommands_getSize
>
> Am I going crazy? Where is it? :)
>
> tc.cpp:
> #include <stdlib.h>
> #include <stdio.h>
> #include <assert.h>
> #include <clang-c/CXCompilationDatabase.h>
>
> int main() {
>   CXCompilationDatabase db;
>   CXCompilationDatabase_Error err;
>   const char *build_dir;
>
>   build_dir = ".";
>   db = clang_CompilationDatabase_fromDirectory(build_dir, &err);
>
>   if (err != CXCompilationDatabase_NoError) {
>     exit(1);
>   }
>
>   CXCompileCommands cmds = clang_CompilationDatabase_
> getAllCompileCommands(db);
>   unsigned num_commands = clang_CompileCommand_getNumArgs(cmds);
>   assert(num_commands > 0);
>   printf("%d\n", clang_CompileCommand_getNumMappedSources(clang_
> CompileCommands_getCommand(cmds, 0)));
>
>   return 0;
> }
>
>
> Kind regards & TIA,
>
> /Charlie.
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170508/34c5fb9b/attachment.html>


More information about the cfe-dev mailing list