Bug 356178 - Completion helper removes default values in function declaration
Summary: Completion helper removes default values in function declaration
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (Clang-based) (show other bugs)
Version: 4.90.90
Platform: Kubuntu Linux
: VHI normal
Target Milestone: 5.0.0
Assignee: kdevelop-bugs-null
URL:
Keywords: release_blocker
Depends on:
Blocks:
 
Reported: 2015-12-02 01:53 UTC by Piotr Mierzwinski
Modified: 2015-12-04 17:08 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 5.0.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Mierzwinski 2015-12-02 01:53:43 UTC
In class MyClass there is...

Declaration (header file):
QString getText( QWidget *pParent, const QString &sInInitText, bool &bParam, const QString &sInLabel = QString::null, unsigned int par = 2, const QString &sInWndTitle = QString::null );

Definition (cpp file):
QString MyClass::getText( QWidget *pParent, const QString &sInInitText, bool &bParam, const QString &sInLabel, unsigned int par, const QString &sInWndTitle )
{
...
}

Being in cpp file try to remove "unsigned" from "par" argument (second counting from end). Choose "Update declaration signature" (pressing Alt+1) on "Adapt signature" helper window.


Reproducible: Always


Actual Results:  
QString getText(QWidget *pParent, GetTextMode getMode, const QString &sInInitText, bool &bParam, const QString &sInLabel, int par, const QString &sInWndTitle = QString::null);

As you can see disappeared default values from second and third arguments (counting from end)

Expected Results:  
QString getText( QWidget *pParent, GetTextMode getMode, const QString &sInInitText, bool &bParam, const QString &sInLabel = QString::null, int par = 2, const QString &sInWndTitle = QString::null );

Removing both default values could make sense if I would have "par" argument as const and I would removed "const". Then get getting invalid initialization from compile. Or if I would change the type of second (counting from end) argument.
Comment 1 Piotr Mierzwinski 2015-12-02 01:54:18 UTC
kdevelop and kdevplatform cloned at 30.11.2015
Comment 2 Milian Wolff 2015-12-02 11:29:29 UTC
I've seen this myself and it's due to missing API in libclang, we'll have to tokenize probably to find the default arguments and insert them manually. Also, we should add proper API upstream to leverage it in the future for this use-case.
Comment 3 Milian Wolff 2015-12-04 17:08:41 UTC
Git commit ba2ecbaeba206644c1134569e6da40047096487a by Milian Wolff.
Committed on 04/12/2015 at 17:06.
Pushed by mwolff into branch '5.0'.

Keep default arguments when adapting signature from definition side.

Simplify the code, fix the bug, and also keep default arguments
when we prepend an argument. In such cases, default-initialize the
new arg with `= {} /* TODO */`.
FIXED-IN: 5.0.0

M  +11   -6    languages/clang/codegen/adaptsignatureassistant.cpp
M  +26   -0    languages/clang/tests/test_assistants.cpp

http://commits.kde.org/kdevelop/ba2ecbaeba206644c1134569e6da40047096487a