Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not completing protected members from parent class #22

Open
cbourjau opened this issue Apr 19, 2016 · 3 comments
Open

Not completing protected members from parent class #22

cbourjau opened this issue Apr 19, 2016 · 3 comments

Comments

@cbourjau
Copy link

Hello,
I am using irony and its company-irony completion every day and I love it. However, today I noticed an issue with protected members. Everything works fine in the class itself, but the protected members are not available for auto-completion in the deriving classes. Public members work fine and flycheck is not showing an error either. Am I missing something here or is this unexpected behaviour? My configuration is as below and I am on Ubuntu 14.04 with clang-3.5.

Thanks,
Christian

(use-package flycheck-irony
  :ensure t
  :config
  (eval-after-load 'flycheck
    '(add-hook 'flycheck-mode-hook #'flycheck-irony-setup))
  )
(use-package irony
  :ensure t
  :init
  (add-hook 'c++-mode-hook 'irony-mode)
  (add-hook 'c-mode-hook 'irony-mode)
  (add-hook 'objc-mode-hook 'irony-mode)
  :config
  ;; replace the `completion-at-point' and `complete-symbol' bindings in
  ;; irony-mode's buffers by irony-mode's function
  (defun my-irony-mode-hook ()
    (define-key irony-mode-map [remap completion-at-point]
      'irony-completion-at-point-async)
    (define-key irony-mode-map [remap complete-symbol]
      'irony-completion-at-point-async))
  (add-hook 'irony-mode-hook 'my-irony-mode-hook)
  (add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
  ;;(eval-after-load 'flycheck
  ;;  '(add-hook 'flycheck-mode-hook #'flycheck-irony-setup))
  (eval-after-load 'company
    '(add-to-list 'company-backends 'company-irony))
  ;; (optional) adds CC special commands to `company-begin-commands' in order to
  ;; trigger completion at interesting places, such as after scope operator
  ;;     std::|
  (add-hook 'irony-mode-hook 'company-irony-setup-begin-commands)
  ;; standard is "clang-3.4" -> not present on ubuntu
  (setq company-clang-executable "clang-3.5")
  )
(use-package company
  :ensure t
  :init (add-hook 'after-init-hook 'global-company-mode)
  :config
  (use-package company-irony :ensure t :defer t)
  :bind ("C-;" . company-complete-common)
  )
@Sarcasm
Copy link
Owner

Sarcasm commented Apr 19, 2016

Minimal reproduction:

class Base
{
public:
  Base();

public:
  int m_public;
protected:
  int m_protected;
private:
  int m_private;
};

class Derived : public Base
{
  Derived()
  {
    this->|  // only provides m_public, not m_protected
  }
};

I can confirm your issue, if I comment the following check in Irony.cpp:

      if (availability == CXAvailability_NotAccessible ||
          availability == CXAvailability_NotAvailable) {
        continue;
      }

The bug seems to be in libclang, CXAvailability_NotAccessible removes the protected members.
Howewer, removing this check also adds private members, not sure which is best.
Ideally we should confirm that the issue is in libclang and report a bug/provide a patch.

@Sarcasm
Copy link
Owner

Sarcasm commented Apr 19, 2016

I look slightly more, this is a known bug: https://llvm.org/bugs/show_bug.cgi?id=24329

@cbourjau
Copy link
Author

Many thanks for your effort! Unfortunately, it seems like that bug did not get a lot of traction since it was posted, but I fond some other reports as well. This one looked most promising: https://llvm.org/bugs/show_bug.cgi?id=20220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants