Bug 462415 - Object-like and function-like macros are mixed up when whitespace is unusual
Summary: Object-like and function-like macros are mixed up when whitespace is unusual
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (Clang-based) (other bugs)
Version First Reported In: 5.9.220803
Platform: Other Linux
: NOR minor
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-29 23:07 UTC by Vitaliy
Modified: 2022-11-30 10:40 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 5.10.221200
Sentry Crash Report:


Attachments
Reproduction examples (107 bytes, text/x-csrc)
2022-11-29 23:07 UTC, Vitaliy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vitaliy 2022-11-29 23:07:46 UTC
Created attachment 154153 [details]
Reproduction examples

SUMMARY
If a macro is defined like this:
#define SOME_MACRO	(1 << 6)
it is an object-like macro due to the whitespace between macro name and the opening parenthesis. But when that whitespace contains no ASCII space characters (e.g. consists of a tab as in this example), KDevelop treats it as a function-like macro.
Conversely, when in a function-like macro definition the parameter list is not followed by an ASCII space, the macro is treated as object-like. See the attachment for examples.

STEPS TO REPRODUCE
1. Open KDevelop
2. Open the attached file

OBSERVED RESULT
OBJ1 and OBJ2:
* are highlighted as function-like macros
* in the tooltip or the code browser,
   - are described as “Function macro”
   - in some cases, the replacement list is shown after the name as if it was a parameter list
   - the body may be shown as empty, or the whole line (including #define) may be shown as the body
FUN1, FUN2, and FUN3:
* are highlighted as object-like macros
* in the tooltip or the code browser
   - are described as “Macro”
   - no parameter list is shown after macro name

EXPECTED RESULT
OBJ1 and OBJ2:
* are highlighted as object-like macros
* In the tooltip or the code browser,
   - described as simply “Macro”
   - the replacement list is shown as the body
FUN1, FUN2, and FUN3:
* are highlighted as function-like macros
* In the tooltip or the code browser,
   - described as “Function macro”
   - the parameter list is shown after macro name
   - the replacement list is shown as the body

SOFTWARE/OS VERSIONS
KDevelop: 5.9.220803 (22.08.3)
Linux/KDE Plasma:
KDE Plasma Version: 5.24.4
KDE Frameworks Version: 5.93.0
Qt Version: 5.15.2
clang, libclang: 12.0.1
Comment 1 Igor Kushnir 2022-11-30 10:40:58 UTC
I just recently fixed this in https://invent.kde.org/kdevelop/kdevelop/-/merge_requests/390. Please verify that it works as you expect now.