WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
190819
Cleanup: inline constexpr is redundant as constexpr implies inline
https://bugs.webkit.org/show_bug.cgi?id=190819
Summary
Cleanup: inline constexpr is redundant as constexpr implies inline
Daniel Bates
Reported
2018-10-22 21:37:58 PDT
As per [dcl.constexpr] (2), "constexpr functions and constexpr constructors are implicitly inline" (
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3797.pdf
). So, it is sufficient to annotate a function with "constexpr" instead of annotating with "inline constexpr".
Attachments
Patch
(24.61 KB, patch)
2018-10-25 14:13 PDT
,
Ross Kirsling
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Daniel Bates
Comment 1
2018-10-22 21:46:38 PDT
Bonus points: teach the style checker to recognize "inline constexpr" and provide an informative diagnostic message that suggests using dropping the "inline" keyword.
Ross Kirsling
Comment 2
2018-10-25 13:47:20 PDT
(In reply to Daniel Bates from
comment #1
)
> Bonus points: teach the style checker to recognize "inline constexpr" and > provide an informative diagnostic message that suggests using dropping the > "inline" keyword.
Looks like clang-tidy should support this in the future:
https://reviews.llvm.org/D18914
Ross Kirsling
Comment 3
2018-10-25 13:48:26 PDT
(In reply to Ross Kirsling from
comment #2
)
> (In reply to Daniel Bates from
comment #1
) > > Bonus points: teach the style checker to recognize "inline constexpr" and > > provide an informative diagnostic message that suggests using dropping the > > "inline" keyword. > > Looks like clang-tidy should support this in the future: >
https://reviews.llvm.org/D18914
Er hmm, I posted that before double-checking the date. Guess it's kind of stale. 😓
Ross Kirsling
Comment 4
2018-10-25 14:13:21 PDT
Created
attachment 353108
[details]
Patch
Mark Lam
Comment 5
2018-10-25 14:32:16 PDT
Comment on
attachment 353108
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=353108&action=review
> Source/JavaScriptCore/ChangeLog:3 > + Cleanup: inline constexpr is redundant as constexpr implies inline
Are you sure that this is true? constexpr functions may be called on none const arguments, and therefore produce a non-constexpr value. Marking a function constexpr only means that it *can* produce a constexpr value, not necessarily that it *will* produce a constexpr value. Hence, I'm not sure that constexpr necessarily means the function will be inlined. At least that's my understanding. Am I wrong?
Ross Kirsling
Comment 6
2018-10-25 14:41:22 PDT
(In reply to Mark Lam from
comment #5
)
> Comment on
attachment 353108
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=353108&action=review
> > > Source/JavaScriptCore/ChangeLog:3 > > + Cleanup: inline constexpr is redundant as constexpr implies inline > > Are you sure that this is true? constexpr functions may be called on none > const arguments, and therefore produce a non-constexpr value. Marking a > function constexpr only means that it *can* produce a constexpr value, not > necessarily that it *will* produce a constexpr value. Hence, I'm not sure > that constexpr necessarily means the function will be inlined. At least > that's my understanding. Am I wrong?
According to
https://en.cppreference.com/w/cpp/language/constexpr
:
> A constexpr specifier used in a function ... declaration implies inline.
So that's seems pretty unambiguous... But of course, we wouldn't want to touch any ALWAYS_INLINE cases.
Mark Lam
Comment 7
2018-10-25 14:44:21 PDT
Comment on
attachment 353108
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=353108&action=review
r=me
>>> Source/JavaScriptCore/ChangeLog:3 >>> + Cleanup: inline constexpr is redundant as constexpr implies inline >> >> Are you sure that this is true? constexpr functions may be called on none const arguments, and therefore produce a non-constexpr value. Marking a function constexpr only means that it *can* produce a constexpr value, not necessarily that it *will* produce a constexpr value. Hence, I'm not sure that constexpr necessarily means the function will be inlined. At least that's my understanding. Am I wrong? > > According to
https://en.cppreference.com/w/cpp/language/constexpr
:
Excellent.
WebKit Commit Bot
Comment 8
2018-10-25 15:23:33 PDT
Comment on
attachment 353108
[details]
Patch Clearing flags on attachment: 353108 Committed
r237429
: <
https://trac.webkit.org/changeset/237429
>
WebKit Commit Bot
Comment 9
2018-10-25 15:23:35 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 10
2018-10-25 15:24:30 PDT
<
rdar://problem/45569008
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug