Bug 396876 - Generated function definitions should exactly match declarations in headers
Summary: Generated function definitions should exactly match declarations in headers
Status: REPORTED
Alias: None
Product: kdevelop
Classification: Applications
Component: Code completion (show other bugs)
Version: 5.2.1
Platform: Other All
: NOR wishlist
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-26 13:00 UTC by Cyp
Modified: 2023-01-05 06:48 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Cyp 2018-07-26 13:00:40 UTC
If a header contains a declaration

myFunc(char const *str);

then autogenerating the definition in the source file creates

myFunc(const char *str)
{
}

. I think it would be better if the generated signature exactly matched the header, even if "char const" and "const char" are equivalent.

Also, it would be nice if it were possible to set the { to appear on the same line as the ).
Comment 1 Unknown 2023-01-04 20:21:23 UTC
This would also be useful for trailing return types. For example 'auto max(int a, int b) -> int' auto completes to 'int max(int a, int b)'.
Comment 2 Igor Kushnir 2023-01-05 06:48:07 UTC
Generated code is not derived from the textual representation of declarations or typed-in code, but from libclang's code model. That is, matching the declaration or the typed-in code in specific ways (`const char` vs `char const` or keeping the trailing return type) requires separate specific implementations. Generated code is then formatted with currently configured source formatter style. Most formatters/styles don't reorder `const` or affect the trailing return type. Feel free to implement the features you need and create merge requests at https://invent.kde.org/kdevelop/kdevelop/-/merge_requests