[clang] [Clang] Bugfixes and improved support for `AttributedType`s in lambdas (PR #85325)

Doug Wyatt via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 14 17:17:00 PDT 2024


================
@@ -3140,13 +3140,35 @@ const FunctionType *ASTContext::adjustFunctionType(const FunctionType *T,
   return cast<FunctionType>(Result.getTypePtr());
 }
 
+QualType ASTContext::adjustFunctionResultType(QualType FunctionType,
+                                              QualType ResultType) {
+  // Might be wrapped in a macro qualified type.
+  if (const auto *MQT = dyn_cast<MacroQualifiedType>(FunctionType)) {
+    return getMacroQualifiedType(
+        adjustFunctionResultType(MQT->getUnderlyingType(), ResultType),
+        MQT->getMacroIdentifier());
+  }
+
+  // Might have a calling-convention attribute.
+  if (const auto *AT = dyn_cast<AttributedType>(FunctionType)) {
+    return getAttributedType(
+        AT->getAttrKind(),
+        adjustFunctionResultType(AT->getModifiedType(), ResultType),
+        adjustFunctionResultType(AT->getEquivalentType(), ResultType));
+  }
+
+  // Anything else must be a function type. Rebuild it with the new return
+  // value.
----------------
dougsonos wrote:

> Also, I just noticed, this code seems to be modelled after `getFunctionTypeWithExceptionSpec()`, which is like two functions down in the same file and which does pretty much the same thing that this is doing here. It might make sense to merge the two.

I was hacking just enough to make it work, apologies.

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


More information about the cfe-commits mailing list