8 Commits

Author SHA1 Message Date
Xu Zhang
8995ccc446
[Clang] Add support for [[msvc::noinline]] attribute. (#91720)
Fixes #90941.
Add support for ``[[msvc::noinline]]`` attribute, which is actually an
alias of ``[[clang::noinline]]``.
2024-05-28 06:29:31 -07:00
Erich Keane
01d05bd407 Add warning test to make buildbots happy after 514e4359 2023-03-21 08:34:48 -07:00
Erich Keane
514e4359a5 inline stmt attribute diagnosing in templates
D146089's author discovered that our diagnostics for always/no inline
would null-dereference when used in a template. He fixed that by
skipping in the dependent case.

This patch makes sure we diagnose these after a template instantiation.
It also adds infrastructure for other statement attributes to add
checking/transformation.

Differential Revision: https://reviews.llvm.org/D146323
2023-03-21 08:16:52 -07:00
Craig Topper
e82d2e8c11 Recommit "[Sema] Fix null pointer dereference handleAlwaysInlineAttr."
Remove use of constexpr if that failed on the build bots.

Original commit message:

It's possible for `getCalleeDecl()` to return a null pointer.

This was encountered by a user of our downstream compiler.

The case involved a DependentScopeDeclRefExpr.

Since this seems to only be for a warning diagnostic, I skipped
the diagnostic check if it returned null. But mabye there's a
different way to fix this.
2023-03-16 21:37:35 -07:00
Craig Topper
e8a632dac2 Revert "[Sema] Fix null pointer dereference handleAlwaysInlineAttr."
This reverts commit 10297470e953f4f3968c54c851c8af82b07af00b.

This is failing on a build bot.
2023-03-16 20:05:33 -07:00
Craig Topper
10297470e9 [Sema] Fix null pointer dereference handleAlwaysInlineAttr.
It's possible for `getCalleeDecl()` to return a null pointer.

This was encountered by a user of our downstream compiler.

The case involved a DependentScopeDeclRefExpr.

Since this seems to only be for a warning diagnostic, I skipped
the diagnostic check if it returned null. But mabye there's a
different way to fix this.

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D146089
2023-03-16 17:49:34 -07:00
Dávid Bolvanský
56e7d6bd44 [Clang] noinline stmt attribute - emit warnings rather than errors
Compatible behaviour with always_inline stmt attribute
2022-03-14 23:40:17 +01:00
Dávid Bolvanský
223b824022 [Clang] noinline call site attribute
Motivation:

```
int foo(int x, int y) { // any compiler will happily inline this function
    return x / y;
}

int test(int x, int y) {
    int r = 0;
    [[clang::noinline]] r += foo(x, y); // for some reason we don't want any inlining here
    return r;
}

```

In 2018, @kuhar proposed "Introduce per-callsite inline intrinsics"  in https://reviews.llvm.org/D51200 to solve this motivation case (and many others).

This patch solves this problem with call site attribute. The implementation is "smaller" wrt approach which uses new intrinsics and thanks to https://reviews.llvm.org/D79121 (Add nomerge statement attribute to clang), we have got some basic infrastructure to deal with attrs on statements with call expressions.

GCC devs are more inclined to call attribute solution as well, as builtins are problematic for them - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104187. But they have no patch proposal yet so..  We have free hands here.

If this approach makes sense, next future steps would be support for call site attributes for always_inline / flatten.

Reviewed By: aaron.ballman, kuhar

Differential Revision: https://reviews.llvm.org/D119061
2022-02-28 21:21:17 +01:00