[cfe-dev] Where is clang_CompileCommand_getNumMappedSources?

Ranjeet Singh via cfe-dev cfe-dev at lists.llvm.org
Mon May 8 03:07:43 PDT 2017


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170508/e7f5f14c/attachment.html>


More information about the cfe-dev mailing list