Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

152 lines
4.5 KiB

  1. /*===-- clang-c/CXCompilationDatabase.h - Compilation database ---*- C -*-===*\
  2. |* *|
  3. |* The LLVM Compiler Infrastructure *|
  4. |* *|
  5. |* This file is distributed under the University of Illinois Open Source *|
  6. |* License. See LICENSE.TXT for details. *|
  7. |* *|
  8. |*===----------------------------------------------------------------------===*|
  9. |* *|
  10. |* This header provides a public inferface to use CompilationDatabase without *|
  11. |* the full Clang C++ API. *|
  12. |* *|
  13. \*===----------------------------------------------------------------------===*/
  14. #ifndef CLANG_CXCOMPILATIONDATABASE_H
  15. #define CLANG_CXCOMPILATIONDATABASE_H
  16. #include "clang-c/Platform.h"
  17. #include "clang-c/CXString.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. /** \defgroup COMPILATIONDB CompilationDatabase functions
  22. * \ingroup CINDEX
  23. *
  24. * @{
  25. */
  26. /**
  27. * A compilation database holds all information used to compile files in a
  28. * project. For each file in the database, it can be queried for the working
  29. * directory or the command line used for the compiler invocation.
  30. *
  31. * Must be freed by \c clang_CompilationDatabase_dispose
  32. */
  33. typedef void * CXCompilationDatabase;
  34. /**
  35. * \brief Contains the results of a search in the compilation database
  36. *
  37. * When searching for the compile command for a file, the compilation db can
  38. * return several commands, as the file may have been compiled with
  39. * different options in different places of the project. This choice of compile
  40. * commands is wrapped in this opaque data structure. It must be freed by
  41. * \c clang_CompileCommands_dispose.
  42. */
  43. typedef void * CXCompileCommands;
  44. /**
  45. * \brief Represents the command line invocation to compile a specific file.
  46. */
  47. typedef void * CXCompileCommand;
  48. /**
  49. * \brief Error codes for Compilation Database
  50. */
  51. typedef enum {
  52. /*
  53. * \brief No error occured
  54. */
  55. CXCompilationDatabase_NoError = 0,
  56. /*
  57. * \brief Database can not be loaded
  58. */
  59. CXCompilationDatabase_CanNotLoadDatabase = 1
  60. } CXCompilationDatabase_Error;
  61. /**
  62. * \brief Creates a compilation database from the database found in directory
  63. * buildDir. For example, CMake can output a compile_commands.json which can
  64. * be used to build the database.
  65. *
  66. * It must be freed by \c clang_CompilationDatabase_dispose.
  67. */
  68. CINDEX_LINKAGE CXCompilationDatabase
  69. clang_CompilationDatabase_fromDirectory(const char *BuildDir,
  70. CXCompilationDatabase_Error *ErrorCode);
  71. /**
  72. * \brief Free the given compilation database
  73. */
  74. CINDEX_LINKAGE void
  75. clang_CompilationDatabase_dispose(CXCompilationDatabase);
  76. /**
  77. * \brief Find the compile commands used for a file. The compile commands
  78. * must be freed by \c clang_CompileCommands_dispose.
  79. */
  80. CINDEX_LINKAGE CXCompileCommands
  81. clang_CompilationDatabase_getCompileCommands(CXCompilationDatabase,
  82. const char *CompleteFileName);
  83. /**
  84. * \brief Get all the compile commands in the given compilation database.
  85. */
  86. CINDEX_LINKAGE CXCompileCommands
  87. clang_CompilationDatabase_getAllCompileCommands(CXCompilationDatabase);
  88. /**
  89. * \brief Free the given CompileCommands
  90. */
  91. CINDEX_LINKAGE void clang_CompileCommands_dispose(CXCompileCommands);
  92. /**
  93. * \brief Get the number of CompileCommand we have for a file
  94. */
  95. CINDEX_LINKAGE unsigned
  96. clang_CompileCommands_getSize(CXCompileCommands);
  97. /**
  98. * \brief Get the I'th CompileCommand for a file
  99. *
  100. * Note : 0 <= i < clang_CompileCommands_getSize(CXCompileCommands)
  101. */
  102. CINDEX_LINKAGE CXCompileCommand
  103. clang_CompileCommands_getCommand(CXCompileCommands, unsigned I);
  104. /**
  105. * \brief Get the working directory where the CompileCommand was executed from
  106. */
  107. CINDEX_LINKAGE CXString
  108. clang_CompileCommand_getDirectory(CXCompileCommand);
  109. /**
  110. * \brief Get the number of arguments in the compiler invocation.
  111. *
  112. */
  113. CINDEX_LINKAGE unsigned
  114. clang_CompileCommand_getNumArgs(CXCompileCommand);
  115. /**
  116. * \brief Get the I'th argument value in the compiler invocations
  117. *
  118. * Invariant :
  119. * - argument 0 is the compiler executable
  120. */
  121. CINDEX_LINKAGE CXString
  122. clang_CompileCommand_getArg(CXCompileCommand, unsigned I);
  123. /**
  124. * @}
  125. */
  126. #ifdef __cplusplus
  127. }
  128. #endif
  129. #endif