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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 27 10:03:49 PST 2024


================
@@ -713,11 +714,21 @@ 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)
-      return FD->getNameAsString();
+    const auto &LO = Context.getLangOpts();
+    if (ForceElaboratedPrinting) {
+      if ((IK == PredefinedIdentKind::Func ||
+           IK == PredefinedIdentKind ::Function) &&
+          !LO.MicrosoftExt)
+        return FD->getNameAsString();
+      if (IK == PredefinedIdentKind::LFunction && LO.MicrosoftExt)
+        return FD->getNameAsString();
+    } else {
+      if (IK != PredefinedIdentKind::PrettyFunction &&
+          IK != PredefinedIdentKind::PrettyFunctionNoVirtual &&
+          IK != PredefinedIdentKind::FuncSig &&
+          IK != PredefinedIdentKind::LFuncSig)
+        return FD->getNameAsString();
+    }
----------------
AaronBallman wrote:

These are all doing the same thing -- calling `FD->getNameAsString()`; can we simplify the logic?

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


More information about the cfe-commits mailing list