[clang] [clang-cl] Fix value of __FUNCTION__ in MSVC mode. (PR #84014)

via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 5 08:03:22 PST 2024


================
@@ -721,10 +722,17 @@ std::string PredefinedExpr::ComputeName(PredefinedIdentKind IK,
     return std::string(Out.str());
   }
   if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurrentDecl)) {
-    if (IK != PredefinedIdentKind::PrettyFunction &&
-        IK != PredefinedIdentKind::PrettyFunctionNoVirtual &&
-        IK != PredefinedIdentKind::FuncSig &&
-        IK != PredefinedIdentKind::LFuncSig)
+    const auto &LO = Context.getLangOpts();
+    if ((ForceElaboratedPrinting &&
+         (((IK == PredefinedIdentKind::Func ||
+            IK == PredefinedIdentKind ::Function) &&
+           !LO.MicrosoftExt) ||
+          (IK == PredefinedIdentKind::LFunction && LO.MicrosoftExt))) ||
+        (!ForceElaboratedPrinting &&
+         (IK != PredefinedIdentKind::PrettyFunction &&
+          IK != PredefinedIdentKind::PrettyFunctionNoVirtual &&
+          IK != PredefinedIdentKind::FuncSig &&
+          IK != PredefinedIdentKind::LFuncSig)))
----------------
Sirraide wrote:

Er, this may just be a me problem, but this is candidly hitting the limits of what I’d consider legible in terms of nested conditions. Maybe there’s a way to write this that makes it more obvious what is actually going on here?

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


More information about the cfe-commits mailing list