Bug 359067

Summary: Auto-completion of method definitions does not follow declaration format or symbols, and breaks convention, and may also break compilation on some systems.
Product: [Applications] kdevelop Reporter: Fredrik Haikarainen <fredrik.haikarainen>
Component: Language Support: CPP (old)Assignee: kdevelop-bugs-null
Status: RESOLVED FIXED    
Severity: major    
Priority: NOR    
Version First Reported In: 4.7.1   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 5.0.0
Sentry Crash Report:

Description Fredrik Haikarainen 2016-02-06 12:28:49 UTC
When you auto-complete method definitions in a source-file, the resulting code does not follow the format or symbol-naming of the declaration.

Example:

    class someClass
    {
        std::string const & getFoo();
    }

using GCC 5.2.1 with -std=c++11 auto-completes to

    const std::__cxx11::string& someClass::getFoo()
    {
    
    }

Problem 1: Different format. The const keyword is now leftsided, and  the & operator is "merged" to the return-type instead of being separated by a space. This breaks convention of the existing codebase.

Problem 2: Different symbols. std::string auto-completes to std::__cxx11::string, which I believe is compiler/libc++-specific (someone please confirm), and will not compile on all systems supporting the C++11 standard.

Reproducible: Always

Steps to Reproduce:
1. Declare a function/method in a headerfile
2. Include said headerfile in a sourcefile and press ctrl+space to autocomplete the declaration to a definition

Actual Results:  
The autocompleted definition is different that the declaration

Expected Results:  
The autocompleted definition follows the exact signature of the declaration, both in terms of conventions/formatting as well as which symbols are used.
Comment 1 Milian Wolff 2016-02-07 15:18:18 UTC
Can you please report the const placement in a separate bug? That should be affected by the source formatter, and from what I saw at a quick glance, astyle does not support it.

The other issue with std::string vs. std::__cxx11::string really looks odd. You are using KDevelop 4? Any chance you can try the KDevelop 5 beta powered by clang? There, I cannot reproduce it.
Comment 2 Fredrik Haikarainen 2016-02-07 15:28:30 UTC
I suspect the __cxx11 thing is highly related to GCC, since its specific to their stdlib, it would make sense that anything that uses clang instead isnt affected. A proper solution would probably be  to somehow detect the __cxx11 namespace in the renaming utility, and  remove any instance of it that werent there before.

Regarding the const placement, I dont have time to open another report atm, but please do so for me if you have time over.
Comment 3 Milian Wolff 2016-09-07 20:30:08 UTC
in kdev 5 with our clang backend, the namespace issues does not arise, even when using libstdc++. I'll report a wishrequest for the placement of const now