[PATCH] D137901: [Clang] `nothrow`-implying attributes should actually manifest `nothrow` attribute (PR58798)

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 12 18:05:09 PST 2022


lebedev.ri created this revision.
lebedev.ri added reviewers: aaron.ballman, erichkeane, rjmccall.
lebedev.ri added a project: LLVM.
Herald added a project: All.
lebedev.ri requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.
Herald added a project: clang.

This is part of https://reviews.llvm.org/D137381,
i've stumbled into this in https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=52989&q=label%3AProj-librawspeed

Look at the `callee_with_clang_attr()`.
`pure` attribute implies `nounwind`, and we successfully manifest that at IRgen,
and calls from nounwind functions treat it as non-unwinding,
except that when generating function definition,
we'd suddenly forget that it is nounwind...

Here, everything that could go wrong, goes wrong.

`CodeGenFunction::EmitStartEHSpec()` looks at the AST function exception specification,
and not IR attributes, so

You'd think we can inferr the attribute in AST after the fact,
in `Sema::ActOnFunctionDeclarator()`, and while that is sufficient to get the diagnostics,
the function exception specification has already been computed from parsed attributes.

So we also need to adjust `handleFunctionTypeAttr()` (called by `processTypeAttrs()`)
so it considers just-parsed `pure` as if it's `nothrow`...

It would somewhat less ugly if we could just infer `nothrow` attribute
during *attribute parsing* from `pure`/etc. Is that possible?

Also, OpenMP declare variant tests are showing an unexpected error,
looks like i'm missing some attribute propagation?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137901

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGenCXX/pr58798.cpp
  clang/test/OpenMP/declare_variant_messages.cpp
  clang/test/SemaCXX/attr-print.cpp
  clang/test/SemaCXX/cxx11-attr-print.cpp
  clang/test/SemaCXX/warn-throw-out-noexcept-func.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137901.474976.patch
Type: text/x-patch
Size: 9877 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221113/c64308ad/attachment-0001.bin>


More information about the cfe-commits mailing list