[cfe-commits] r146069 - in /cfe/trunk: include/clang-c/Index.h tools/c-index-test/c-index-test.c tools/libclang/IndexingContext.cpp tools/libclang/IndexingContext.h

Argyrios Kyrtzidis akyrtzi at gmail.com
Wed Dec 7 12:44:19 PST 2011


Author: akirtzidis
Date: Wed Dec  7 14:44:19 2011
New Revision: 146069

URL: http://llvm.org/viewvc/llvm-project?rev=146069&view=rev
Log:
[libclang] Indexing API: provide both the semantic and the lexical container.

They are generally the same except in C++ cases like out-of-line member functions.

Modified:
    cfe/trunk/include/clang-c/Index.h
    cfe/trunk/tools/c-index-test/c-index-test.c
    cfe/trunk/tools/libclang/IndexingContext.cpp
    cfe/trunk/tools/libclang/IndexingContext.h

Modified: cfe/trunk/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=146069&r1=146068&r2=146069&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Wed Dec  7 14:44:19 2011
@@ -4199,7 +4199,12 @@
   const CXIdxEntityInfo *entityInfo;
   CXCursor cursor;
   CXIdxLoc loc;
-  const CXIdxContainerInfo *container;
+  const CXIdxContainerInfo *semanticContainer;
+  /**
+   * \brief Generally same as \see semanticContainer but can be different in
+   * cases like out-of-line C++ member functions.
+   */
+  const CXIdxContainerInfo *lexicalContainer;
   int isRedeclaration;
   int isDefinition;
   int isContainer;
@@ -4279,6 +4284,7 @@
  * \brief Data for \see indexEntityReference callback.
  */
 typedef struct {
+  CXIdxEntityRefKind kind;
   /**
    * \brief Reference cursor.
    */
@@ -4303,7 +4309,6 @@
    * \brief Container context of the reference.
    */
   const CXIdxContainerInfo *container;
-  CXIdxEntityRefKind kind;
 } CXIdxEntityRefInfo;
 
 typedef struct {

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=146069&r1=146068&r2=146069&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Wed Dec  7 14:44:19 2011
@@ -1801,8 +1801,10 @@
   PrintCursor(info->cursor);
   printf(" | loc: ");
   printCXIndexLoc(info->loc);
-  printf(" | container: ");
-  printCXIndexContainer(info->container);
+  printf(" | semantic-container: ");
+  printCXIndexContainer(info->semanticContainer);
+  printf(" | lexical-container: ");
+  printCXIndexContainer(info->lexicalContainer);
   printf(" | isRedecl: %d", info->isRedeclaration);
   printf(" | isDef: %d", info->isDefinition);
   printf(" | isContainer: %d", info->isContainer);

Modified: cfe/trunk/tools/libclang/IndexingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexingContext.cpp?rev=146069&r1=146068&r2=146069&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexingContext.cpp (original)
+++ cfe/trunk/tools/libclang/IndexingContext.cpp Wed Dec  7 14:44:19 2011
@@ -239,8 +239,10 @@
   DInfo.attributes = AttrList.getAttrs();
   DInfo.numAttributes = AttrList.getNumAttrs();
 
-  getContainerInfo(D->getDeclContext(), DInfo.Container);
-  DInfo.container = &DInfo.Container;
+  getContainerInfo(D->getDeclContext(), DInfo.SemanticContainer);
+  getContainerInfo(D->getLexicalDeclContext(), DInfo.LexicalContainer);
+  DInfo.semanticContainer = &DInfo.SemanticContainer;
+  DInfo.lexicalContainer = &DInfo.LexicalContainer;
   if (DInfo.isContainer) {
     getContainerInfo(getEntityContainer(D), DInfo.DeclAsContainer);
     DInfo.declAsContainer = &DInfo.DeclAsContainer;
@@ -506,12 +508,12 @@
   ContainerInfo Container;
   getContainerInfo(DC, Container);
 
-  CXIdxEntityRefInfo Info = { Cursor,
+  CXIdxEntityRefInfo Info = { Kind,
+                              Cursor,
                               getIndexLoc(Loc),
                               &RefEntity,
                               Parent ? &ParentEntity : 0,
-                              &Container,
-                              Kind };
+                              &Container };
   CB.indexEntityReference(ClientData, &Info);
   return true;
 }

Modified: cfe/trunk/tools/libclang/IndexingContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexingContext.h?rev=146069&r1=146068&r2=146069&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexingContext.h (original)
+++ cfe/trunk/tools/libclang/IndexingContext.h Wed Dec  7 14:44:19 2011
@@ -54,7 +54,8 @@
   DInfoKind Kind;
 
   EntityInfo EntInfo;
-  ContainerInfo Container;
+  ContainerInfo SemanticContainer;
+  ContainerInfo LexicalContainer;
   ContainerInfo DeclAsContainer;
 
   DeclInfo(bool isRedeclaration, bool isDefinition, bool isContainer)
@@ -64,7 +65,7 @@
     this->isContainer = isContainer;
     attributes = 0;
     numAttributes = 0;
-    declAsContainer = container = 0;
+    declAsContainer = semanticContainer = lexicalContainer = 0;
   }
   DeclInfo(DInfoKind K,
            bool isRedeclaration, bool isDefinition, bool isContainer)
@@ -74,7 +75,7 @@
     this->isContainer = isContainer;
     attributes = 0;
     numAttributes = 0;
-    declAsContainer = container = 0;
+    declAsContainer = semanticContainer = lexicalContainer = 0;
   }
 
   static bool classof(const DeclInfo *) { return true; }





More information about the cfe-commits mailing list