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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 6 05:22:05 PST 2024


================
@@ -721,10 +722,21 @@ std::string PredefinedExpr::ComputeName(PredefinedIdentKind IK,
     return std::string(Out.str());
   }
   if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurrentDecl)) {
-    if (IK != PredefinedIdentKind::PrettyFunction &&
+    const auto &LO = Context.getLangOpts();
+    bool isFuncOrFunctionInNonMSVCCompatEnv =
+        ((IK == PredefinedIdentKind::Func ||
+          IK == PredefinedIdentKind ::Function) &&
+         !LO.MSVCCompat);
+    bool isLFunctionInMSVCCommpatEnv =
+        IK == PredefinedIdentKind::LFunction && LO.MSVCCompat;
+    bool isFuncOrFunctionOrLFunctionOrFuncDName =
----------------
AaronBallman wrote:

```suggestion
    bool IsFuncOrFunctionInNonMSVCCompatEnv =
        ((IK == PredefinedIdentKind::Func ||
          IK == PredefinedIdentKind ::Function) &&
         !LO.MSVCCompat);
    bool IsLFunctionInMSVCCommpatEnv =
        IK == PredefinedIdentKind::LFunction && LO.MSVCCompat;
    bool IsFuncOrFunctionOrLFunctionOrFuncDName =
```
Coding style nits, NFC

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


More information about the cfe-commits mailing list