[cfe-commits] r148169 - in /cfe/trunk/tools/libclang: IndexDecl.cpp IndexingContext.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Fri Jan 13 18:05:51 PST 2012


Author: akirtzidis
Date: Fri Jan 13 20:05:51 2012
New Revision: 148169

URL: http://llvm.org/viewvc/llvm-project?rev=148169&view=rev
Log:
[libclang] If CXIndexOpt_IndexFunctionLocalSymbols is enabled, also
index parameters.

Modified:
    cfe/trunk/tools/libclang/IndexDecl.cpp
    cfe/trunk/tools/libclang/IndexingContext.cpp

Modified: cfe/trunk/tools/libclang/IndexDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexDecl.cpp?rev=148169&r1=148168&r2=148169&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexDecl.cpp (original)
+++ cfe/trunk/tools/libclang/IndexDecl.cpp Fri Jan 13 20:05:51 2012
@@ -25,8 +25,20 @@
 
   void handleDeclarator(DeclaratorDecl *D, const NamedDecl *Parent = 0) {
     if (!Parent) Parent = D;
-    IndexCtx.indexTypeSourceInfo(D->getTypeSourceInfo(), Parent);
-    IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent);
+
+    if (!IndexCtx.indexFunctionLocalSymbols()) {
+      IndexCtx.indexTypeSourceInfo(D->getTypeSourceInfo(), Parent);
+      IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent);
+    } else {
+      if (ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) {
+        IndexCtx.handleVar(Parm);
+      } else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+        for (FunctionDecl::param_iterator
+               PI = FD->param_begin(), PE = FD->param_end(); PI != PE; ++PI) {
+          IndexCtx.handleVar(*PI);
+        }
+      }
+    }
   }
 
   bool VisitFunctionDecl(FunctionDecl *D) {

Modified: cfe/trunk/tools/libclang/IndexingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexingContext.cpp?rev=148169&r1=148168&r2=148169&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexingContext.cpp (original)
+++ cfe/trunk/tools/libclang/IndexingContext.cpp Fri Jan 13 20:05:51 2012
@@ -261,7 +261,8 @@
 
   ScratchAlloc SA(*this);
   getEntityInfo(D, DInfo.EntInfo, SA);
-  if (!DInfo.EntInfo.USR || Loc.isInvalid())
+  if ((!indexFunctionLocalSymbols() && !DInfo.EntInfo.USR)
+      || Loc.isInvalid())
     return false;
 
   if (suppressRefs())
@@ -829,6 +830,9 @@
     case Decl::Function:
       EntityInfo.kind = CXIdxEntity_Function;
       break;
+    case Decl::ParmVar:
+      EntityInfo.kind = CXIdxEntity_Variable;
+      break;
     case Decl::Var:
       EntityInfo.kind = CXIdxEntity_Variable;
       if (isa<CXXRecordDecl>(D->getDeclContext())) {





More information about the cfe-commits mailing list