]> granicus.if.org Git - clang/commitdiff
[libclang] Index C++ constructor initializers, rdar://10732164
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 23 Jan 2012 16:58:36 +0000 (16:58 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 23 Jan 2012 16:58:36 +0000 (16:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148705 91177308-0d34-0410-b5e6-96231b3b80d8

tools/libclang/IndexDecl.cpp

index fb4194c8cd9eb0af32a903f6bebc512f14c14581..c6080df5928f523548623dfdbb3bb84103473e8e 100644 (file)
@@ -44,6 +44,22 @@ public:
   bool VisitFunctionDecl(FunctionDecl *D) {
     IndexCtx.handleFunction(D);
     handleDeclarator(D);
+
+    if (CXXConstructorDecl *Ctor = dyn_cast<CXXConstructorDecl>(D)) {
+      // Constructor initializers.
+      for (CXXConstructorDecl::init_iterator I = Ctor->init_begin(),
+                                             E = Ctor->init_end();
+           I != E; ++I) {
+        CXXCtorInitializer *Init = *I;
+        if (Init->isWritten()) {
+          IndexCtx.indexTypeSourceInfo(Init->getTypeSourceInfo(), D);
+          if (const FieldDecl *Member = Init->getAnyMember())
+            IndexCtx.handleReference(Member, Init->getMemberLocation(), D, D);
+          IndexCtx.indexBody(Init->getInit(), D, D);
+        }
+      }
+    }
+
     if (D->isThisDeclarationADefinition()) {
       const Stmt *Body = D->getBody();
       if (Body) {