niosus / EasyClangComplete

:boom: Robust C/C++ code completion for Sublime Text 3/4
https://niosus.github.io/EasyClangComplete/
MIT License
575 stars 78 forks source link

No error but no autocompletion on Apple Clang version > 7.3 #47

Closed fgb closed 8 years ago

fgb commented 8 years ago

I haven't yet set up the include_dirs, which is the crux of the problem, but this is a bit onerous for the projects I'm working with and I'm not even seeing completions based on the default settings yet (i.e. from the h files in the file folder and its parent folder).

Here are my current user settings:

{
  "std_flag" : "-std=c++03",
  "auto_set_sublime_triggers" : false,
  "auto_complete_triggers" :
  [
    {
      "characters": ".:>",
      "selector": "source.c++ - string - comment - constant.numeric"
    }
  ]
}

On a related note, since my project has 4 folders, where does $project_base_path point to?

proj.sublime-project looks something like this:

{
    "folders":
    [
        {
            "path": "to/src"
        },
        {
            "path": "to/other/src"
        },
        {
            "path": "to/yet/another/src"
        }
    ]
}

I'm hoping to coax EasyClangComplete to give me completions, but note that my projects are probably not clang compatible. I build them using VxWorks 6.4/6.8 that run modified versions of GCC 3.4.4/4.1.2.

fgb commented 8 years ago

Also, adding "hide_default_completions": true to my user settings doesn't seem to affect the provided completions, unless the default ones are only hidden when the relevant auto complete triggers are tripped.

fgb commented 8 years ago

Could my problems boil down to our choice of file extensions: .cpp/.h?

niosus commented 8 years ago

Ok, noted. $project_base_path should point to the folder where your project lies. It doesn't care for now about any other path defined in the project. It is up for discussion if this is a good idea. Please open a new issue if you disagree and need to discuss it.

"hide_default_completions": true only affects the plugin. So whenever a trigger is issued the default completions will not popup. It will remove all of them if "autocomplete_all" is true.

As for the absence of simple completions, there is something wrong :) Can you please set "verbose": true in the plugin settings and provide me with a log from the moment you open sublime text to the moment you try to autocomplete a file? I will be able to tell you more then.

And thanks for reporting :)

fgb commented 8 years ago

Here's the log:

startup, version: 3113 osx x64 channel: dev
executable: /Users/user/Applications/Sublime Text.app/Contents/MacOS/Sublime Text
working dir: /
packages path: /Users/user/Library/Application Support/Sublime Text 3/Packages
state path: /Users/user/Library/Application Support/Sublime Text 3/Local
zip path: /Users/user/Applications/Sublime Text.app/Contents/MacOS/Packages
zip path: /Users/user/Library/Application Support/Sublime Text 3/Installed Packages
ignored_packages: ["Vintage"]
pre session restore time: 0.210321
using gpu buffer for window
startup time: 0.297105
first paint time: 0.333414
reloading plugin Default.auto_indent_tag
reloading plugin Default.block
reloading plugin Default.comment
reloading plugin Default.convert_syntax
reloading plugin Default.copy_path
reloading plugin Default.delete_word
reloading plugin Default.detect_indentation
reloading plugin Default.duplicate_line
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.indentation
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_context_url
reloading plugin Default.open_file_settings
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.profile
reloading plugin Default.quick_panel
reloading plugin Default.run_syntax_tests
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.show_scope_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.swap_line
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.trim_trailing_white_space
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin 0_package_control_loader.00-package_control
reloading plugin 0_package_control_loader.01-pygments
reloading plugin 0_package_control_loader.02-bz2
reloading plugin 0_package_control_loader.50-pyyaml
reloading plugin Alignment.Alignment
reloading plugin AlignTab.aligner
reloading plugin AlignTab.aligntab
reloading plugin AlignTab.hist
reloading plugin AlignTab.parser
reloading plugin AlignTab.table
reloading plugin AlignTab.wclen
reloading plugin All Autocomplete.all_views_completions
reloading plugin BracketGuard.BracketGuard
reloading plugin Find++.DirectoryPanel
reloading plugin Find++.FindPlusPlus
reloading plugin FindKeyConflicts.find_key_conflicts
reloading plugin FuzzyFileNav.fuzzy_file_nav
reloading plugin FuzzyFileNav.multiconf
reloading plugin FuzzyFileNav.notify
reloading plugin GitGutter.git_gutter
reloading plugin GitGutter.git_gutter_change
reloading plugin GitGutter.git_gutter_compare
reloading plugin GitGutter.git_gutter_events
reloading plugin GitGutter.git_gutter_handler
reloading plugin GitGutter.git_helper
reloading plugin GitGutter.view_collection
reloading plugin GitSavvy.git_savvy
reloading plugin Keymaps.Keymaps
reloading plugin LineEndings.LineEndings
reloading plugin Markdown Preview.helper
reloading plugin Markdown Preview.markdown_settings
reloading plugin Markdown Preview.markdown_wrapper
reloading plugin Markdown Preview.MarkdownPreview
reloading plugin Origami.origami
reloading plugin Package Control.1_reloader
reloading plugin Package Control.2_bootstrap
reloading plugin Package Control.Package Control
reloading plugin Pretty JSON.PrettyJson
reloading plugin RawLineEdit.raw_line_edit
reloading plugin Smart Delete.SmartDelete
reloading plugin Sublimerge Pro.Sublimerge
reloading plugin WordCount.WordCount
reloading plugin Codecs33.Codecs33
reloading plugin ConvertToUTF8.ConvertToUTF8
reloading plugin EasyClangComplete.EasyClangComplete
reloading plugin LaTeXTools.00_reload_submodules
reloading plugin LaTeXTools.change_environment
reloading plugin LaTeXTools.delete_temp_files
reloading plugin LaTeXTools.detect_spellcheck
reloading plugin LaTeXTools.getRegion
reloading plugin LaTeXTools.getTeXRoot
reloading plugin LaTeXTools.jumpto_tex_file
reloading plugin LaTeXTools.jumpToPDF
reloading plugin LaTeXTools.kpsewhich
reloading plugin LaTeXTools.latex_cite_completions
reloading plugin LaTeXTools.latex_cwl_completions
reloading plugin LaTeXTools.latex_env_completions
reloading plugin LaTeXTools.latex_input_completions
reloading plugin LaTeXTools.latex_installed_packages
reloading plugin LaTeXTools.latex_ref_cite_completions
reloading plugin LaTeXTools.latex_ref_completions
reloading plugin LaTeXTools.latexCommand
reloading plugin LaTeXTools.latexDocumentationViewer
reloading plugin LaTeXTools.latexEnvCloser
reloading plugin LaTeXTools.latexEnvironment
reloading plugin LaTeXTools.latexFillAll
reloading plugin LaTeXTools.latextools_default_settings
reloading plugin LaTeXTools.latextools_plugin
reloading plugin LaTeXTools.makePDF
reloading plugin LaTeXTools.migrate
reloading plugin LaTeXTools.parseTeXlog
reloading plugin LaTeXTools.texMacro
reloading plugin LaTeXTools.texSections
reloading plugin LaTeXTools.texSyntaxListener
reloading plugin LaTeXTools.toggle_auto
reloading plugin LaTeXTools.toggle_focus
reloading plugin LaTeXTools.toggle_fwdsync
reloading plugin LaTeXTools.toggle_show
reloading plugin SublimeCodeIntel.ordereddict
reloading plugin SublimeCodeIntel.SublimeCodeIntel
reloading plugin Terminal.Terminal
plugins loaded
INFO:EasyClangComplete.EasyClangComplete: init completer based on libclang
INFO:EasyClangComplete.plugin.completion.base_complete: Getting version from command: `clang++ --version`
WARNING:EasyClangComplete.plugin.completion.base_complete: OSX version 7.3 reported. Reducing it to 3.8. Info: {'platform': 'Darwin'}
INFO:EasyClangComplete.plugin.completion.base_complete: Found clang version: 3.8
DEBUG:EasyClangComplete.plugin.completion.lib_complete: using bundled cindex: EasyClangComplete.clang.cindex38
INFO:EasyClangComplete.clang.utils: we are on 'Darwin'
INFO:EasyClangComplete.clang.utils: searching for: 'libclang.dylib'
INFO:EasyClangComplete.clang.utils: libclang search output = '/Library/Developer/CommandLineTools/usr/bin/../lib/clang/7.3.0'
INFO:EasyClangComplete.clang.utils: found libclang dir: '/Library/Developer/CommandLineTools/usr/bin/../lib/clang/7.3.0/../..'
INFO:EasyClangComplete.clang.utils: found library file: 'libclang.dylib'
Loading LaTeXTools plugins...
Loaded LaTeXTools plugins [] from path /Users/user/Library/Application Support/Sublime Text 3/Packages/User
Loaded LaTeXTools plugins ['base_viewer'] from path /Users/user/Library/Application Support/Sublime Text 3/Packages/LaTeXTools/viewers/base_viewer.py
Loaded LaTeXTools plugins ['evince_viewer', 'command_viewer', 'preview_viewer', 'skim_viewer', 'okular_viewer', 'sumatra_viewer'] from path /Users/user/Library/Application Support/Sublime Text 3/Packages/LaTeXTools/viewers
Loaded LaTeXTools plugins [] from path /Users/user/Library/Application Support/Sublime Text 3/Packages/User
Loaded LaTeXTools plugins ['new_bibliography', 'traditional_bibliography'] from path /Users/user/Library/Application Support/Sublime Text 3/Packages/LaTeXTools/bibliography_plugins
Loaded LaTeXTools plugins ['pdf_builder'] from path /Users/user/Library/Application Support/Sublime Text 3/Packages/LaTeXTools/builders/pdfBuilder.py
Loaded LaTeXTools plugins ['traditional_builder', 'simple_builder', 'script_builder'] from path /Users/user/Library/Application Support/Sublime Text 3/Packages/LaTeXTools/builders
Loaded LaTeXTools plugins [] from path /Users/user/Library/Application Support/Sublime Text 3/Packages/User
Package Control: Skipping automatic upgrade, last run at 2016-06-10 14:30:21, next run at 2016-06-10 15:30:21 or after
DEBUG:EasyClangComplete.EasyClangComplete: on_activated_async view id 5
DEBUG:EasyClangComplete.plugin.tools: file has unsopported syntax: `Plain text`
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.EasyClangComplete: on_activated_async view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.EasyClangComplete:init completer for view id: 28
DEBUG:EasyClangComplete.plugin.plugin_settings: populating include dirs with current variables:
DEBUG:EasyClangComplete.plugin.plugin_settings: project_base_name = 
DEBUG:EasyClangComplete.plugin.plugin_settings: project_base_folder = 
DEBUG:EasyClangComplete.plugin.plugin_settings: file_parent_folder = /Users/user/source/App/Common
DEBUG:EasyClangComplete.plugin.plugin_settings: include_dirs = ['/usr/include', '/src', '/workspace/src', '/Users/user/source/App/Common/File', '/Users/user/source/App/Common']
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.completion.lib_complete: searching for .clang_complete in /Users/user/source/App/Common/File up to 
DEBUG:EasyClangComplete.plugin.completion.lib_complete: found .clang_complete: /Users/user/source/.clang_complete
DEBUG:EasyClangComplete.plugin.completion.base_complete: .clang_complete contains flags: ['-I/Users/user/source']
DEBUG:EasyClangComplete.plugin.completion.lib_complete: This is a C++ file. Adding `-x c++` to flags
DEBUG:EasyClangComplete.plugin.completion.lib_complete: clang flags are: ['-x', 'c++', '-std=c++03', '-I/usr/include', '-I/src', '-I/workspace/src', '-I/Users/user/source/App/Common/File', '-I/Users/user/source/App/Common', '-I/Users/user/source']
DEBUG:EasyClangComplete.plugin.completion.lib_complete: compilation started for view id: 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.completion.lib_complete: compilation done in 0.27211904525756836 seconds
DEBUG:EasyClangComplete.plugin.error_vis: generating error regions for view 28
DEBUG:EasyClangComplete.plugin.error_vis: 1 error regions ready
DEBUG:EasyClangComplete.plugin.error_vis: showing error regions: []
WARNING:process:Could not import subprocess32 module, falling back to subprocess module
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: no error regions for row: 87
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: no error regions for row: 87
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: no error regions for row: 87
DEBUG:EasyClangComplete.EasyClangComplete: on_modified_async view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: erasing error regions for view 28
DEBUG:EasyClangComplete.EasyClangComplete: on_query_completions view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.tools: no completions needed
DEBUG:EasyClangComplete.EasyClangComplete: hiding default completions
DEBUG:EasyClangComplete.EasyClangComplete: on_modified_async view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: erasing error regions for view 28
DEBUG:EasyClangComplete.EasyClangComplete: on_modified_async view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: erasing error regions for view 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: no error regions for row: 87
DEBUG:EasyClangComplete.EasyClangComplete: on_modified_async view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: erasing error regions for view 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: no error regions for row: 87
DEBUG:EasyClangComplete.EasyClangComplete: on_modified_async view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: erasing error regions for view 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: no error regions for row: 87
DEBUG:EasyClangComplete.EasyClangComplete: on_modified_async view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: erasing error regions for view 28
DEBUG:EasyClangComplete.EasyClangComplete: on_query_completions view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.tools: no completions needed
DEBUG:EasyClangComplete.EasyClangComplete: hiding default completions
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: no error regions for row: 87
DEBUG:EasyClangComplete.EasyClangComplete: on_modified_async view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: erasing error regions for view 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: no error regions for row: 87
DEBUG:EasyClangComplete.EasyClangComplete: on_modified_async view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: erasing error regions for view 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: no error regions for row: 87
DEBUG:EasyClangComplete.EasyClangComplete: on_modified_async view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: erasing error regions for view 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: no error regions for row: 87
DEBUG:EasyClangComplete.EasyClangComplete: on_modified_async view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: erasing error regions for view 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: no error regions for row: 87
DEBUG:EasyClangComplete.EasyClangComplete: on_modified_async view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: erasing error regions for view 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: no error regions for row: 87
DEBUG:EasyClangComplete.EasyClangComplete: on_modified_async view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: erasing error regions for view 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: no error regions for row: 87
DEBUG:EasyClangComplete.EasyClangComplete: on_modified_async view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: erasing error regions for view 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: no error regions for row: 87
DEBUG:EasyClangComplete.EasyClangComplete: on_modified_async view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: erasing error regions for view 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: no error regions for row: 87
DEBUG:EasyClangComplete.EasyClangComplete: on_modified_async view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: erasing error regions for view 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: no error regions for row: 87
DEBUG:EasyClangComplete.EasyClangComplete: on_modified_async view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: erasing error regions for view 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: no error regions for row: 87
DEBUG:EasyClangComplete.EasyClangComplete: on_modified_async view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: erasing error regions for view 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: no error regions for row: 87
DEBUG:EasyClangComplete.EasyClangComplete: on_modified_async view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: erasing error regions for view 28
niosus commented 8 years ago

Well, it looks like it is going to be quite hard to debug :( Everything seems to run nicely, but there are still no completions reported by clang somehow. Does binary completion work for you?

My guess it that apple clang 7.3 is not based on llvm clang 3.8 which I assume. They stopped reporting the llvm version they are basing on from some point. So this is for now the only difference I see between your setup and the one the plugin is tested on.

fgb commented 8 years ago

What do you mean by binary completion?

I'm open to installing llvm via homebrew (latest stable is 3.6.2) if you think that might solve the issue.

niosus commented 8 years ago

There are 2 ways for this plugin to work: 1 uses libclang and the other invokes clang binary and parses the output. The second method should work anyway. You need to set use_libclang to false.

About llvm clang, could you do it? It would help finding the reason. Thanks!

fgb commented 8 years ago

I've set use_libclang to false and the plugin seems to be running better. I haven't been able to autocomplete based on headers in the same/parent folders yet because there are errors on compilation. These are highlighted if errors_on_save is set to true.

Is there any way for autocompletions to work without having the project be fully compilable using clang?

niosus commented 8 years ago

It is already done this way. It can recover from some errors, but apparently yours are too extreme for it.

niosus commented 8 years ago

However, may I still ask you to install llvm version? This will show us if the error is actually in Apple Clang

fgb commented 8 years ago

I'll try this as soon as I get a chance. I don't think it will help much since the compilation errors should persist (at least until I compile the massive include list). I'll probably also check with a simpler project for sanity.

niosus commented 8 years ago

Thanks a lot!

niosus commented 8 years ago

Actually, I have found that Appla Clang 7.3 should correspond to LLVM clang 3.7 and not 3.8 as I thought before. So maybe it has fixed this issue.

niosus commented 8 years ago

Can anybody having Apple Clang 7.3 test this?

fgb commented 8 years ago

So now that the plugin correctly identifies the LLVM version in Apple Clang 7.3 as 3.7, I should not need to install LLVM via homebrew, right?

niosus commented 8 years ago

At least that is my guess. No guarantees though, unfortunately. :(

ghlecl commented 8 years ago

Hello.

Not sure if it is related or not, but I cannot get the plugin to work. I have uninstalled every other plugin (except for a theme, which I believe should not make any difference). I am trying to simply get the STL to auto-complete (i.e. std::_____), but it crashes the whole plugin system every time.

I am on OSX with XCode 7.3.1. I am running the latest dev build of ST (3118). Don't know if it can be related.

Here is the console output.

startup, version: 3118 osx x64 channel: dev
executable: /Applications/Sublime Text.app/Contents/MacOS/Sublime Text
working dir: /
packages path: /Users/ghleclerc/Library/Application Support/Sublime Text 3/Packages
state path: /Users/ghleclerc/Library/Application Support/Sublime Text 3/Local
zip path: /Applications/Sublime Text.app/Contents/MacOS/Packages
zip path: /Users/ghleclerc/Library/Application Support/Sublime Text 3/Installed Packages
ignored_packages: []
pre session restore time: 0.220499
using gpu buffer for window
first paint time: 0.273389
startup time: 0.274372
reloading plugin Default.auto_indent_tag
reloading plugin Default.block
reloading plugin Default.comment
reloading plugin Default.convert_syntax
reloading plugin Default.copy_path
reloading plugin Default.delete_word
reloading plugin Default.detect_indentation
reloading plugin Default.duplicate_line
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.indentation
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_context_url
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.profile
reloading plugin Default.quick_panel
reloading plugin Default.run_syntax_tests
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.settings
reloading plugin Default.show_scope_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.swap_line
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.trim_trailing_white_space
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin Vintage.vintage
reloading plugin Vintage.vintage_commands
reloading plugin Vintage.vintage_motions
reloading plugin 0_package_control_loader.00-package_control
reloading plugin 0_package_control_loader.02-bz2
reloading plugin Package Control.1_reloader
reloading plugin Package Control.2_bootstrap
reloading plugin Package Control.Package Control
reloading plugin EasyClangComplete.EasyClangComplete
plugins loaded
INFO:EasyClangComplete.EasyClangComplete: init completer based on libclang
INFO:EasyClangComplete.plugin.completion.base_complete: Getting version from command: `clang++ --version`
WARNING:EasyClangComplete.plugin.completion.base_complete: OSX version 7.3 reported. Reducing it to 3.7. Info: {'platform': 'Darwin'}
INFO:EasyClangComplete.plugin.completion.base_complete: Found clang version: 3.7
INFO:EasyClangComplete.clang.utils: we are on 'Darwin'
INFO:EasyClangComplete.clang.utils: searching for: 'libclang.dylib'
INFO:EasyClangComplete.clang.utils: libclang search output = '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0'
INFO:EasyClangComplete.clang.utils: found libclang dir: '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0/../..'
INFO:EasyClangComplete.clang.utils: found library file: 'libclang.dylib'
ERROR:EasyClangComplete.plugin.completion.flags_file: cannot get flags from clang_complete_file. No file.
Package Control: Skipping automatic upgrade, last run at 2016-07-20 00:05:03, next run at 2016-07-20 01:05:03 or after
error: plugin_host has exited unexpectedly, plugin functionality won't be available until Sublime Text has been restarted

Currently, the plugin is not usable for me. Will try the use_libclang to false setting.

If I can do anything to help, let me know. If it is not related, I can open another issue.

Thanks.

niosus commented 8 years ago

@ghlecl thanks a lot for reporting. I guess it is related. If this happens every time you try to autocomplete, then probably the bindings are wrong, or the version is still wrong. Because the plugin has clearly found the lib, but is still unusable. The strange part is that I see no indication that the plugin even started completing...

It is quite hard to debug something I don't have first hand access to, but I think in the upcoming days I will create a small test project for you to test out.

ghlecl commented 8 years ago

@niosus Will gladly test if you get around to creating the small test project.

I actually got around to using the use_libclang false setting and it does work. From the documentation, I think it means the functionality is slightly less, but it does work.

ghost commented 8 years ago

I think I have pretty much the same issue. I have Xcode 7.3.1, ST3 stable 3114. This is my test file:

#include <vector>

int main() {
    // Typing the second ':' on the next line either crashes the plugin or
    // doesn't bring up the EasyClangComplete autocompletion list
    std:
    return 0;
}

Here's my console log:

startup, version: 3114 osx x64 channel: stable
executable: /Applications/Sublime Text.app/Contents/MacOS/Sublime Text
working dir: /
packages path: /Users/Me/Library/Application Support/Sublime Text 3/Packages
state path: /Users/Me/Library/Application Support/Sublime Text 3/Local
zip path: /Applications/Sublime Text.app/Contents/MacOS/Packages
zip path: /Users/Me/Library/Application Support/Sublime Text 3/Installed Packages
ignored_packages: ["Vintage"]
pre session restore time: 0.166271
startup time: 0.208516
first paint time: 0.219625
reloading plugin Default.auto_indent_tag
reloading plugin Default.block
reloading plugin Default.comment
reloading plugin Default.convert_syntax
reloading plugin Default.copy_path
reloading plugin Default.delete_word
reloading plugin Default.detect_indentation
reloading plugin Default.duplicate_line
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.indentation
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_context_url
reloading plugin Default.open_file_settings
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.profile
reloading plugin Default.quick_panel
reloading plugin Default.run_syntax_tests
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.show_scope_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.swap_line
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.trim_trailing_white_space
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin 0_package_control_loader.00-package_control
reloading plugin 0_package_control_loader.02-bz2
reloading plugin Package Control.1_reloader
reloading plugin Package Control.2_bootstrap
reloading plugin Package Control.Package Control
reloading plugin EasyClangComplete.EasyClangComplete
plugins loaded
INFO:EasyClangComplete.EasyClangComplete: init completer based on libclang
INFO:EasyClangComplete.plugin.completion.base_complete: Getting version from command: `clang++ --version`
WARNING:EasyClangComplete.plugin.completion.base_complete: OSX version 7.3 reported. Reducing it to 3.7. Info: {'platform': 'Darwin'}
INFO:EasyClangComplete.plugin.completion.base_complete: Found clang version: 3.7
DEBUG:EasyClangComplete.plugin.completion.lib_complete: using bundled cindex: EasyClangComplete.clang.cindex37
DEBUG:EasyClangComplete.clang.utils: platform: ('64bit', '')
DEBUG:EasyClangComplete.clang.utils: python version: 3.3.6
INFO:EasyClangComplete.clang.utils: we are on 'Darwin'
INFO:EasyClangComplete.clang.utils: searching for: 'libclang.dylib'
INFO:EasyClangComplete.clang.utils: libclang search output = '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0'
DEBUG:EasyClangComplete.clang.utils: real output: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0
DEBUG:EasyClangComplete.clang.utils: folder to search: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0/../..
INFO:EasyClangComplete.clang.utils: found libclang dir: '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0/../..'
INFO:EasyClangComplete.clang.utils: found library file: 'libclang.dylib'
DEBUG:EasyClangComplete.EasyClangComplete: on_activated_async view id 5
Package Control: Skipping automatic upgrade, last run at 2016-08-08 15:30:59, next run at 2016-08-08 16:30:59 or after
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.EasyClangComplete: on_activated_async view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.completion.base_complete: .clang_complete file handler not initialized.
DEBUG:EasyClangComplete.EasyClangComplete:init completer for view id: 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.plugin_settings: populating include dirs with current variables:
DEBUG:EasyClangComplete.plugin.plugin_settings: project_base_name = test
DEBUG:EasyClangComplete.plugin.plugin_settings: project_base_folder = /Users/Me/dev/test
DEBUG:EasyClangComplete.plugin.plugin_settings: file_parent_folder = /Users/Me/dev
DEBUG:EasyClangComplete.plugin.plugin_settings: include_dirs = ['/usr/include', '/Users/Me/dev/test/src', '/workspace/test/src', '/Users/Me/dev/test', '/Users/Me/dev']
DEBUG:EasyClangComplete.plugin.completion.flags_file: found .clang_complete file: /Users/Me/dev/test/.clang_complete
DEBUG:EasyClangComplete.plugin.completion.flags_file: .clang_complete contains flags: []
DEBUG:EasyClangComplete.plugin.completion.lib_complete: This is a C++ file. Adding `-x c++` to flags
DEBUG:EasyClangComplete.plugin.completion.lib_complete: clang flags are: ['-x', 'c++', '-std=c++11', '-I/usr/include', '-I/Users/Me/dev/test/src', '-I/workspace/test/src', '-I/Users/Me/dev/test', '-I/Users/Me/dev']
DEBUG:EasyClangComplete.plugin.completion.lib_complete: compilation started for view id: 28
DEBUG:EasyClangComplete.plugin.completion.lib_complete: compilation done in 0.13975214958190918 seconds
DEBUG:EasyClangComplete.plugin.error_vis: generating error regions for view 28
DEBUG:root: adding error {'file': '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iosfwd', 'error': "'wchar.h' file not found", 'col': '10', 'row': '90'}
DEBUG:EasyClangComplete.plugin.error_vis: 1 error regions ready
DEBUG:EasyClangComplete.plugin.error_vis: showing error regions: []
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.error_vis: no error regions for row: 6
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.EasyClangComplete: on_modified_async view id 28
DEBUG:EasyClangComplete.plugin.error_vis: erasing error regions for view 28
DEBUG:EasyClangComplete.EasyClangComplete: on_query_completions view id 28
DEBUG:EasyClangComplete.plugin.tools: file has valid syntax: `C++`
DEBUG:EasyClangComplete.plugin.tools: matched trigger '::'.
DEBUG:EasyClangComplete.EasyClangComplete: starting async auto_complete at pos: 84
DEBUG:EasyClangComplete.plugin.completion.lib_complete: started code complete for view 28
error: plugin_host has exited unexpectedly, plugin functionality won't be available until Sublime Text has been restarted
niosus commented 8 years ago

Ok, so this is a confirmed thing. I am sorry for the lack of communication, I am trying to nail down the issues on Windows for now and I have only that much spare time. I will devote more time to this issue once we manage to solve that one.

For now, I guess you guys could try a small plugin I have created to debug Windows issues. It can be found here. The readme should be clear on how to use it, but feel free to ask if something is not clear. Please also open issues there if something will not work.

That plugin just parses a test file, autocompletes it and then tries to read the statistics. At least there we have a deterministic flow.

ghost commented 8 years ago

@niosus This is my Terminal output from running script.py:

('Clang directory = ', u'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0/../..')
('Platform: ', ('64bit', ''))
('Python version: ', '2.7.10')
('filename = ', u'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0/../../libclang.dylib')
dyld: warning, LC_RPATH @executable_path/../lib in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0/../../libclang.dylib being ignored in restricted program because of @executable_path
YAY! Parsed TranslationUnit
0
0
here
<Diagnostic severity 4, location <SourceLocation file u'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring', line 61, column 10>, spelling u"'string.h' file not found">
ghlecl commented 8 years ago

@niosus Did the same thing: run from Terminal.app and got this output if I run from the folder where script.py is:

Clang directory =  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0/../..
Platform:  ('64bit', '')
Python version:  3.5.2
filename =  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0/../../libclang.dylib
Traceback (most recent call last):
  File "script.py", line 21, in <module>
    tu = TU.from_source(filename=filename, args=clang_flags)
  File "/Users/ghleclerc/Library/Application Support/Sublime Text 3/Packages/test-complete-plugin/clang/cindex38.py", line 2372, in from_source
    raise TranslationUnitLoadError("Error parsing translation unit.")
clang.cindex38.TranslationUnitLoadError: Error parsing translation unit.

Since the output was different from that of @tommit, I figured I might be doing something wrong so ran it from the folder above and got different output:

Clang directory =  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0/../..
Platform:  ('64bit', '')
Python version:  3.5.2
filename =  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0/../../libclang.dylib
YAY! Parsed TranslationUnit
68
68
here
<Diagnostic severity 3, location <SourceLocation file '/Users/ghleclerc/Library/Application Support/Sublime Text 3/Packages/test-complete-plugin/test.cpp', line 5, column 1>, spelling 'expected unqualified-id'>

Thanks for spending any of your spare time on this. As you said, we only have so much of it and it is appreciated. :-)

If there is anything else that can be tested, don't hesitate.

niosus commented 8 years ago

@tommit could you please try it with some flavor of python 3 as this is the version that sublime text uses internally and the code in cindex38.py is intended to be run with python 3?

@ghlecl oh... this is strange that the output changes based on the folder where you run it from. I will look into it. There seem to be problems with clang bindings to clang 3.8 on every platform, which is really annoying :)

I like spending time on it, because in the end it will work (I like believing it). Currently, the time is really few, unfortunately. There is an important deadline at work in a month. But I really want to finish this issue. I will come back to you as soon as I have any new info on what could be a nice test for you to run.

ghost commented 8 years ago

@niosus I used homebrew to install python 3.5.2. Installing it didn't change what gets called by default when issuing the "python" command. But I can use the "python3" command. So, now the Terminal command I used was: python3 /Users/Me/Library/Application\ Support/Sublime\ Text\ 3/Packages/test-complete-plugin-master/script.py

And this was the Terminal output:

Clang directory =  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0/../..
Platform:  ('64bit', '')
Python version:  3.5.2
filename =  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0/../../libclang.dylib
YAY! Parsed TranslationUnit
0
0
here
<Diagnostic severity 4, location <SourceLocation file '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring', line 61, column 10>, spelling "'string.h' file not found">

But if I simply start SublimeText 3 and look at the ST3 console, I can see that the python version reported there is yet somewhat different:

Clang directory =  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0/../..
Platform:  ('64bit', '')
Python version:  3.3.6
filename =  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.3.0/../../libclang.dylib
YAY! Parsed TranslationUnit
0
0
here
<Diagnostic severity 4, location <SourceLocation file '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring', line 61, column 10>, spelling "'string.h' file not found">

The actual error message stays the same though.

niosus commented 8 years ago

Yes, this is ok. Sublime gets bundled with python 3.3.6 which is custom built from 3.3.5 by sublime maintainers.

It's bad that there is no crash though. It would be easier to debug probably. Let's see. I am now focusing on fixing Windows support #4 and that requires changing cindex file which will also influence this issue. Let's see what I can get out of it.

niosus commented 8 years ago

Guys, is it possible to install an older llvm clang version alongside the apple one? This would at least for now solve the issue. It seems that it is something in clang 3.8 and its bindings that is wrong.

rchl commented 8 years ago

One might try using cindex.py from llvm master - https://github.com/llvm-mirror/clang/blob/master/bindings/python/clang/cindex.py It seems it has some small but possibly important fixes comparing to the one bundled with EasyClangComplete.

niosus commented 8 years ago

Damn, I was sure I have the file just copied from there (and run through 2to3). It appears not. It is still not fully compatible to clang-3.8 present in ubuntu 16.04 but generates a new error which is already something. Thanks a lot!

rchl commented 8 years ago

After more in-depth look, I saw that many of those changes are not python 3 compatible and removed decode/encode for strings also causes problems for Sublime. Are you running some custom patches on upstream cindex or they just broke those things recently?

niosus commented 8 years ago

I am running customized cindex. Mostly there is just the compatibility to python 3 things as original ones are for python 2 only. Also some encoding fixes.

The cindex38.py should be taken from here

niosus commented 8 years ago

But I do see some differences between the file you pointed me to and the one I have already and these differences actually correspond to errors processing which is one of the things that breaks. So it may be worth a try.

niosus commented 8 years ago

Ugh... The differences were to the version for libclang 3.9... The version in the plugin is exactly the same as the one from the official llvm github mirror + changed to support python 3. So it is exactly as one in python package index: https://pypi.python.org/pypi/libclang-py3/3.8.2

I guess I will have to build whole clang and try to understand what is going on in debugger at this point. I see no reason why it wouldn't work. And yet it doesn't.

rchl commented 8 years ago

Do you have any more specific information on which API returns unexpected results?

niosus commented 8 years ago

Now that it works for me on linux I expect more troubles finding out what doesn't work on osx, as I dont have a mac (unfortunately).

I would still like somebody to install llvm clang with brew to find out if that way is working.

rchl commented 8 years ago

I have tried using ECC 1.3.5 on Mac with both apple clang (8.0.0) and llvm (3.8.1), using libclang variant.

Both will fail on anything more complicated as they can't find standard library headers.

DEBUG:root: adding error {'error': "'string.h' file not found", 'file': '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring', 'row': '61', 'col': '10'}

To fix that, it's necessary to find SDK location which typically is at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk or more specific variant like MacOSX10.12.sdk. So basically adding compile flag

clang_flags: ["-isysroot", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk]",

Should help.

Of course the question is how to do that automatically. Chromium for example uses this script https://cs.chromium.org/chromium/src/build/mac/find_sdk.py?q=find_sdk&sq=package:chromium&l=1

niosus commented 8 years ago

This should not be too hard to incorporate.

@rchl do you have an idea why it works for older apple clangs? I judge only from the tests, however.

rchl commented 8 years ago

I can test it out. Which version you are saying that was working?

niosus commented 8 years ago

For example the one that the tests are run against. Travis says it is apple clang 6.0.

More precisely: AppleClang 6.0.0.6000054

fgb commented 8 years ago

Hi @niosus, I have some good news to report. The plugin seems to be working on macOS Sierra. It might have started working before that, based on the fixes you've been pushing lately, but I hadn't had the chance to test it until now.

Here's the Apple clang version I'm currently using:

$ clang --version
Apple LLVM version 8.0.0 (clang-800.0.38)
Target: x86_64-apple-darwin16.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

These are my current settings:

{
  "std_flag_cpp" : "-std=c++03",
  "use_libclang" : false,
  "auto_set_sublime_triggers" : false,
  "auto_complete_triggers" :
  [
    {
      "characters": ".:>",
      "selector": "source.c++ - string - comment - constant.numeric"
    }
  ],
  "hide_default_completions": true
}

And here's the source code I used for testing:

test.h

#ifndef TEST_H
#define TEST_H

class Test
{
public:
  void test();
};

#endif

test.cpp

#include <iostream>
#include "test.h"

void Test::test()
{
  std::cout << "hello world!" << std::endl;
}

int main()
{
  Test t;

  t.test();

  return 0;
}

I'm correctly being shown completions for both my Test class and iostream. I've also been getting build errors highlighted.

Now that I see the plugin is working so well, I'll have to generate the list of include_dirs for the massive project I'm working on and hope for the best.

Thanks for this great plugin and all the hard work it took!

ghlecl commented 8 years ago

@fgb I think that with the "use_libclang" : false setting, it has been working all along. The problem is when you set "use_libclang": true.

At least, in my tests on XCode 7.3, that was the case. Havent tested the plugin with XCode 8.

fgb commented 8 years ago

@ghlecl I had never gotten it to work in the past, which was the reason I filed the issue to begin with, but just in case I ran the same test with "use_libclang" : true (restarting sublime text after the change) and the plugin is still working fine for me.

ghlecl commented 8 years ago

@fgb Excellent news then. I will try it out as soon as I can. Thanks !

niosus commented 8 years ago

Any news on this?

fgb commented 8 years ago

@niosus Things have been going quite great. Here are my current settings:

{
  "errors_on_save" : false
}

I've compiled a fairly complete .clang_complete file for my project, but had to disable errors_on_save due to multiple false positives. For instance, if I'm implementing a class that's derived from an interface (pure abstract class), I see errors pop up everywhere telling me that so and so type defined in the interface is aka int and not a class, structure, union, namespace, or enumeration. If I've included things like <string> at the interface level, I get errors for no type named string in the std namespace when I try to implement the class, which don't appear in the h file that directly includes the interface's h file. For clarity, files are usually in the same folder and follow the pattern classInterface.h, class.h, and class.cpp, each of which includes the previous one.

As for the contents of .clang_complete, it can include -Irelative\path\to\include and -DMACRO=definitions, right? How about flags like -std=, -ansi, or -O2? Is there a way to include comments in the file? I'm right now adding # comments, which I've verified EasyClangComplete parses out when assembling the include paths to hand to clang.

Note that I'm using the above types of flags in my current .clang_complete and have been using verbose to verify that EasyClangComplete recognizes them, but I've also seen that it sends things like -std twice, first including the flag from the plugin's default settings.

fgb commented 8 years ago

Actually, I don't think I've tracked down why I see the errors I mentioned. I put together some minimal example code that doesn't generate any errors:

test.h

#ifndef TEST_H
#define TEST_H

#include <string>

class Test
{
public:
  virtual void test( const std::string & s ) = 0;
};

#endif

my_test.h

#ifndef MY_TEST_H
#define MY_TEST_H

#include "test.h"

class MyTest
  : public Test
{
public:
  virtual void test( const std::string & s = "" );
};

#endif

my_test.cpp

#include <iostream>
#include "my_test.h"

void MyTest::test( const std::string & s )
{
  std::cout << s << std::endl;
}

int main()
{
  MyTest t;

  t.test( "hello world!" );

  return 0;
}
niosus commented 8 years ago

Hey @fgb sorry for the delay.

How about flags like -std=, -ansi, or -O2 There is near to no need for the O2 flag. You don't need to have your compiled code to run faster. You need faster compile times on the contrary. Please tell me if you think otherwise.

Currently, I control which flags get parsed and I am quire restrictive on this matter, I only allow -std, -I, -isystem and -D flags. This is probably about to change at some point, but does not stay as urgent in my todo list.

As for the errors, they are usually due to something wrong with includes. Could you tell me which build system are you using? Maybe I could add the support of autogeneration of .clang_complete for that system instead.

Anyway, having errors actually proves, that issue can be closed, as the plugin is generating them and showing them and it seems is completing code as well as it can given the presence of errors. So I guess, I will close this issue for now, but do not hesitate to reopen if needed.

fgb commented 7 years ago

@niosus I agree that you don't need to support -O2. I was just curious as to what flags were being heeded is all. Beyond the previous post, have you documented the flags supported by .clang_complete anywhere else?

I think I'll have to keep tweaking my .clang_complete. My build system is gnu-based but tailored for VxWorks. I doubt it's worth your time supporting autogeneration for it, given its high price tag and thus limited use.

Thanks a lot for your help.

niosus commented 7 years ago

Ok @fgb , this sounds logical to me.

As of version 2.0.1 the plugin should support any arbitrary flags. Just define them in common_flags in your project specific settings. Alternatively, you can also put them in .clang_complete. We modify include paths to allow for relative paths, but do not filter any other flags anymore. You can still have comments in .clang_complete starting with #. But you're right, this needs to be documented. I will probably open an issue for this later today.