]> granicus.if.org Git - clang/commitdiff
[libclang] Now that we have a CXModule object, pass it to the
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 5 Oct 2012 00:22:40 +0000 (00:22 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 5 Oct 2012 00:22:40 +0000 (00:22 +0000)
importedASTFile indexing callback.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165281 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang-c/Index.h
tools/c-index-test/c-index-test.c
tools/libclang/IndexingContext.cpp

index f7a319b5f2b661daee21652be535c52765fbdb09..1b350d8770b2278f71c62e23ea461e2daf67ca22 100644 (file)
@@ -4992,24 +4992,18 @@ typedef struct {
    */
   CXFile file;
   /**
-   * \brief Location where the file is imported. Applicable only for modules.
+   * \brief The imported module or NULL if the AST file is a PCH.
    */
-  CXIdxLoc loc;
+  CXModule module;
   /**
-   * \brief Non-zero if the AST file is a module otherwise it's a PCH.
+   * \brief Location where the file is imported. Applicable only for modules.
    */
-  int isModule;
+  CXIdxLoc loc;
   /**
    * \brief Non-zero if an inclusion directive was automatically turned into
-   * a module import.
+   * a module import. Applicable only for modules.
    */
   int isImplicit;
-  /**
-   * \brief The actual name of the module or submodule being imported.
-   * The syntax is a sequence of identifiers separated by dots, e.g "std.vector"
-   * Applicable only for modules.
-   */
-  const char *moduleName;
 
 } CXIdxImportedASTFileInfo;
 
index caa50d0167cd40027abe211260d2cebc675f3987..c073b8069851c47e4a3fbcb3f30c45b1c3253678 100644 (file)
@@ -2376,11 +2376,14 @@ static CXIdxClientFile index_importedASTFile(CXClientData client_data,
 
   printf("[importedASTFile]: ");
   printCXIndexFile((CXIdxClientFile)info->file);
-  printf(" | loc: ");
-  printCXIndexLoc(info->loc, client_data);
-  printf(" | name: \"%s\"", info->moduleName);
-  printf(" | isModule: %d | isImplicit: %d\n",
-         info->isModule, info->isImplicit);
+  if (info->module) {
+    CXString name = clang_Module_getFullName(info->module);
+    printf(" | loc: ");
+    printCXIndexLoc(info->loc, client_data);
+    printf(" | name: \"%s\"", clang_getCString(name));
+    printf(" | isImplicit: %d\n", info->isImplicit);
+    clang_disposeString(name);
+  }
 
   return (CXIdxClientFile)info->file;
 }
index 1186191cc3701da1dd0eaa88bb4d961762d75a4a..74b3cf362b133fd0f6992d16bdded7976baea032 100644 (file)
@@ -264,10 +264,9 @@ void IndexingContext::importedModule(const ImportDecl *ImportD) {
 
   CXIdxImportedASTFileInfo Info = {
                                     (CXFile)Mod->getASTFile(),
+                                    Mod,
                                     getIndexLoc(ImportD->getLocation()),
-                                    /*isModule=*/true,
-                                    ImportD->isImplicit(),
-                                    ModuleName.c_str(),
+                                    ImportD->isImplicit()
                                   };
   CXIdxClientASTFile astFile = CB.importedASTFile(ClientData, &Info);
   (void)astFile;
@@ -279,10 +278,9 @@ void IndexingContext::importedPCH(const FileEntry *File) {
 
   CXIdxImportedASTFileInfo Info = {
                                     (CXFile)File,
+                                    /*module=*/NULL,
                                     getIndexLoc(SourceLocation()),
-                                    /*isModule=*/false,
-                                    /*isImplicit=*/false,
-                                    /*moduleName=*/NULL
+                                    /*isImplicit=*/false
                                   };
   CXIdxClientASTFile astFile = CB.importedASTFile(ClientData, &Info);
   (void)astFile;