[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 10 10:31:14 PDT 2024


================
@@ -1868,6 +1868,28 @@ bool Sema::IsFunctionConversion(QualType FromType, QualType ToType,
       FromFn = QT->getAs<FunctionType>();
       Changed = true;
     }
+
+    if (getLangOpts().CPlusPlus) {
+      // For C, when called from checkPointerTypesForAssignment,
+      // we need not to change the type, or else even an innocuous cast
+      // like dropping effects will fail.
----------------
Sirraide wrote:

> Or is this just a matter of the comment not clearly describing the intent of the code?

Mostly the latter; the comment being inside the `if` statement makes it seem like it is supposed to describe what we’re doing inside the `if`, which only happens in C++ mode; but the actual text of the comment seems to describe that we’re *not* doing in C mode. 

I think the intent here was to point out why this is only supposed to happen in C++ mode, so I’d move the comment outside the `if` and maybe reword it to where that’s a bit clearer, because the way it is right now is a bit confusing, at least to me.

https://github.com/llvm/llvm-project/pull/84983


More information about the cfe-commits mailing list