[clang] [Clang] Prevent null pointer dereference in target attribute mangling (PR #94228)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 3 09:25:12 PDT 2024


================
@@ -1853,18 +1853,26 @@ static std::string getMangledNameImpl(CodeGenModule &CGM, GlobalDecl GD,
         break;
       case MultiVersionKind::Target: {
         auto *Attr = FD->getAttr<TargetAttr>();
+        assert(Attr &&
+               "Expected TargetAttr to be present for attribute mangling");
         const ABIInfo &Info = CGM.getTargetCodeGenInfo().getABIInfo();
         Info.appendAttributeMangling(Attr, Out);
         break;
       }
       case MultiVersionKind::TargetVersion: {
         auto *Attr = FD->getAttr<TargetVersionAttr>();
+        assert(
+            Attr &&
+            "Expected TargetVersionAttr to be present for attribute mangling");
----------------
efriedma-quic wrote:

Please split the string in two so the formatting is less awkward.  Otherwise LGTM

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


More information about the cfe-commits mailing list