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

via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 3 10:13:22 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");
----------------
smanna12 wrote:

Thank you @efriedma-quic for reviews!

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

Done

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


More information about the cfe-commits mailing list